/* ===== Topic Tab Bar ===== */
.acl-topic-bar {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  height: 38px;
  min-height: 38px;
  background: var(--md-surface);
  border-bottom: 1px solid var(--md-outline-variant);
  position: relative;
  z-index: 2;
}

.acl-topic-tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.acl-topic-tabs::-webkit-scrollbar { display: none; }

.acl-topic-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  font-size: 12px;
  color: var(--md-on-surface-variant);
  cursor: pointer;
  white-space: nowrap;
  max-width: 180px;
  transition: color .15s, background .15s;
  flex-shrink: 0;
  position: relative;
  user-select: none;
  border-right: 1px solid transparent;
}

.acl-topic-tab::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 8px;
  right: 8px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: transparent;
  transition: background .2s cubic-bezier(.2,0,0,1);
}

.acl-topic-tab:hover {
  color: var(--md-on-surface);
  background: var(--md-surface-1, rgba(255,255,255,.03));
}

.acl-topic-tab.active {
  color: var(--md-on-surface);
  font-weight: 500;
}
.acl-topic-tab.active::after {
  background: var(--md-primary);
}

.acl-topic-tab + .acl-topic-tab {
  border-left: 1px solid var(--md-outline-variant, rgba(255,255,255,.08));
}

.acl-topic-tab.pinned .acl-topic-pin-icon {
  font-size: 11px;
  opacity: .5;
}

.acl-topic-tab--cron {
  opacity: .65;
}
.acl-topic-tab--cron.active { opacity: 1; }

.acl-topic-tab-icon {
  font-size: 14px;
  flex-shrink: 0;
  opacity: .6;
}
.acl-topic-tab.active .acl-topic-tab-icon {
  opacity: .85;
}

.acl-topic-tab-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.acl-topic-tab-close {
  display: none;
  background: none;
  border: none;
  padding: 2px;
  font-size: 16px;
  line-height: 1;
  color: var(--md-on-surface-variant);
  cursor: pointer;
  border-radius: 4px;
  margin-left: 4px;
  flex-shrink: 0;
  opacity: .5;
  transition: opacity .12s, background .12s;
}
.acl-topic-tab:hover .acl-topic-tab-close {
  display: inline-flex;
}
.acl-topic-tab.active .acl-topic-tab-close {
  display: inline-flex;
  opacity: .65;
}
.acl-topic-tab-close:hover {
  opacity: 1;
  background: var(--md-surface-3, rgba(255,255,255,.1));
}

.acl-topic-unread-badge {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--md-primary, #6750a4);
  flex-shrink: 0;
  margin-left: -2px;
}

/* ── Tab Bar Actions ── */
.acl-topic-actions {
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
  padding: 0 6px;
  border-left: 1px solid var(--md-outline-variant, rgba(255,255,255,.08));
  position: relative;
}

.acl-topic-actions button {
  background: none;
  border: none;
  padding: 5px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--md-on-surface-variant);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s;
  opacity: .7;
}
.acl-topic-actions button:hover {
  background: var(--md-surface-2, rgba(255,255,255,.06));
  color: var(--md-on-surface);
  opacity: 1;
}
.acl-topic-actions button .material-symbols-outlined {
  font-size: 18px;
}

/* ===== History Panel ===== */
.acl-history-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 4px;
  width: 300px;
  max-height: 420px;
  background: var(--md-surface-2, #2a2a2a);
  border: 1px solid var(--md-outline-variant);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.24), 0 2px 8px rgba(0,0,0,.12);
  z-index: 100;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: topicPanelIn .18s cubic-bezier(.2,0,0,1);
}
.acl-history-panel.open { display: flex; }

@keyframes topicPanelIn {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.acl-history-search {
  padding: 10px 10px 8px;
}
.acl-history-search input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--md-outline-variant);
  border-radius: 7px;
  font-size: 12px;
  background: var(--md-surface);
  color: var(--md-on-surface);
  outline: none;
  transition: border-color .15s;
  box-sizing: border-box;
}
.acl-history-search input:focus {
  border-color: var(--md-primary);
}

#acl-history-groups {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.acl-history-group-label {
  padding: 8px 12px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--md-on-surface-variant);
  opacity: .7;
}

.acl-history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 12px;
  color: var(--md-on-surface);
  cursor: pointer;
  transition: background .12s;
  border-radius: 6px;
  margin: 0 4px;
}
.acl-history-item:hover { background: var(--md-surface-3, rgba(255,255,255,.06)); }
.acl-history-item.active {
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  font-weight: 500;
}

.acl-history-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.acl-history-empty {
  padding: 32px 16px;
  text-align: center;
  font-size: 12px;
  color: var(--md-on-surface-variant);
  opacity: .6;
}

/* Archived section */
.acl-history-section-archived { border-top: 1px solid var(--md-outline-variant); margin-top: 4px; }
.acl-history-section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--md-on-surface-variant);
  cursor: pointer;
  user-select: none;
  opacity: .7;
}
.acl-history-section-chev {
  margin-left: auto;
  font-size: 14px;
  transition: transform .2s;
}
.acl-history-section-archived.expanded .acl-history-section-chev { transform: rotate(90deg); }
.acl-history-section-body { display: none; }
.acl-history-section-archived.expanded .acl-history-section-body { display: block; }

/* ===== Context Menu ===== */
.acl-context-menu {
  position: fixed;
  z-index: 200;
  background: var(--md-surface-2, #2a2a2a);
  border: 1px solid var(--md-outline-variant);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,.24), 0 2px 8px rgba(0,0,0,.12);
  padding: 4px 0;
  min-width: 140px;
  animation: topicPanelIn .12s cubic-bezier(.2,0,0,1);
}

.acl-context-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 12px;
  color: var(--md-on-surface);
  cursor: pointer;
  transition: background .1s;
}
.acl-context-menu-item:hover { background: var(--md-surface-3, rgba(255,255,255,.06)); }
.acl-context-menu-item .material-symbols-outlined { font-size: 15px; color: var(--md-on-surface-variant); opacity: .7; }

/* ===== Dark Mode Refinements ===== */
[data-theme="dark"] .acl-topic-bar {
  background: var(--md-surface);
  border-bottom-color: rgba(255,255,255,.08);
}
[data-theme="dark"] .acl-topic-tab + .acl-topic-tab {
  border-left-color: rgba(255,255,255,.06);
}
[data-theme="dark"] .acl-topic-tab:hover {
  background: rgba(255,255,255,.04);
}
[data-theme="dark"] .acl-topic-tab-close:hover {
  background: rgba(255,255,255,.1);
}
[data-theme="dark"] .acl-topic-actions {
  border-left-color: rgba(255,255,255,.06);
}
[data-theme="dark"] .acl-history-panel {
  background: var(--md-surface-2, #1e1e1e);
  border-color: rgba(255,255,255,.1);
}
[data-theme="dark"] .acl-history-search input {
  background: var(--md-surface);
  border-color: rgba(255,255,255,.1);
}
[data-theme="dark"] .acl-history-item:hover {
  background: rgba(255,255,255,.05);
}
[data-theme="dark"] .acl-context-menu {
  background: var(--md-surface-2, #1e1e1e);
  border-color: rgba(255,255,255,.1);
}
[data-theme="dark"] .acl-context-menu-item:hover {
  background: rgba(255,255,255,.05);
}

/* ===== Light Mode ===== */
[data-theme="light"] .acl-topic-bar {
  background: #fafafa;
  border-bottom-color: rgba(0,0,0,.08);
}
[data-theme="light"] .acl-topic-tab + .acl-topic-tab {
  border-left-color: rgba(0,0,0,.06);
}
[data-theme="light"] .acl-topic-tab:hover {
  background: rgba(0,0,0,.04);
}
[data-theme="light"] .acl-topic-tab.active::after {
  background: var(--md-primary);
}
[data-theme="light"] .acl-history-panel {
  background: #fff;
  box-shadow: 0 8px 32px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.06);
}
[data-theme="light"] .acl-context-menu {
  background: #fff;
  box-shadow: 0 8px 32px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.06);
}
