/* ═══════════════════════════════════════════════════════════════════════════
   AIHOT Three-Column Layout — aiknow.org.cn
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── App Shell ── */
.app-shell {
  display: grid;
  grid-template-columns: 200px 220px minmax(0, 1fr);
  min-height: 100vh;
  max-width: 100vw;
}

/* ── LEFT SIDEBAR ── */
.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--pm-surface-container);
  border-right: var(--pm-border-thin);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  z-index: 50;
  scrollbar-width: thin;
}
.app-sidebar::-webkit-scrollbar { width: 4px; }
.app-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 2px; }
.app-sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.12); }

.sidebar-close { display: none; }

.sidebar-brand { display: flex; align-items: center; padding: 0 4px 8px; }
.sidebar-logo {
  display: flex; align-items: center; gap: 6px;
  font-size: 1.2rem; font-weight: 800; color: var(--pm-text-primary);
  text-decoration: none; letter-spacing: -0.02em;
}
.sidebar-logo-ai {
  background: linear-gradient(135deg, #6c8cff, #a78bfa);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sidebar-logo-orbit { width: 8px; height: 8px; border: 2px solid #6c8cff; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.sidebar-logo-core { width: 3px; height: 3px; background: #6c8cff; border-radius: 50%; }
.sidebar-logo-hot { color: var(--pm-text-primary); }

.sidebar-divider { height: 1px; background: var(--pm-border-thin); margin: 8px 0; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px;
  font-size: 0.875rem; font-weight: 500;
  color: var(--pm-text-muted); text-decoration: none;
  transition: all var(--pm-transition-fast); white-space: nowrap;
}
.sidebar-link:hover { color: var(--pm-text-primary); background: var(--pm-surface-overlay); }
.sidebar-link--active { color: var(--pm-accent); background: var(--pm-accent-subtle); font-weight: 600; }
.sidebar-icon { flex-shrink: 0; opacity: 0.7; }
.sidebar-link:hover .sidebar-icon, .sidebar-link--active .sidebar-icon { opacity: 1; }
.sidebar-label { overflow: hidden; text-overflow: ellipsis; }

.sidebar-footer { display: flex; flex-direction: column; gap: 2px; padding-top: 8px; }

.sidebar-theme-toggle {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px;
  font-size: 0.875rem; color: var(--pm-text-muted);
  background: none; border: none; cursor: pointer;
  transition: all var(--pm-transition-fast); width: 100%; text-align: left;
}
.sidebar-theme-toggle:hover { color: var(--pm-text-primary); background: var(--pm-surface-overlay); }

.sidebar-overlay { display: none; }
.sidebar-overlay--visible { display: block; }

/* ── MIDDLE COLUMN ── */
.app-middle {
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
  background: var(--pm-surface-container);
  border-right: var(--pm-border-thin);
  display: flex; flex-direction: column;
  z-index: 40;
  scrollbar-width: thin;
}
.app-middle::-webkit-scrollbar { width: 4px; }
.app-middle::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 2px; }
.app-middle::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.12); }

.middle-header {
  padding: 20px 16px 12px;
  font-size: 0.9375rem; font-weight: 700;
  color: var(--pm-text-primary);
  border-bottom: var(--pm-border-thin);
  position: sticky; top: 0; background: var(--pm-surface-container);
  z-index: 1; flex-shrink: 0;
}
.middle-list { flex: 1; overflow-y: auto; padding: 4px 0; }

.middle-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 16px; text-decoration: none;
  color: var(--pm-text-secondary); font-size: 0.8125rem; line-height: 1.45;
  transition: all var(--pm-transition-fast);
  border-bottom: 1px solid rgba(255,255,255,0.03); cursor: pointer;
}
.middle-item:hover { background: var(--pm-surface-overlay); color: var(--pm-text-primary); }
.middle-item--active { background: var(--pm-accent-subtle); color: var(--pm-accent); font-weight: 600; }
.middle-item-date { flex-shrink: 0; font-size: 0.6875rem; color: var(--pm-text-muted); min-width: 36px; text-align: center; padding-top: 1px; }
.middle-item-date .day { display: block; font-size: 1rem; font-weight: 700; color: var(--pm-text-muted); line-height: 1.1; }
.middle-item-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* AIHOT-style collapsible month groups */
.middle-month { margin-bottom: 2px; }
.middle-month[open] { margin-bottom: 8px; }
.middle-month-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px;
  font-size: 0.8125rem; font-weight: 600;
  color: var(--pm-text-secondary);
  cursor: pointer;
  list-style: none;
  border-radius: 6px;
  transition: background 0.15s;
}
.middle-month-head::-webkit-details-marker { display: none; }
.middle-month-head::marker { display: none; content: ""; }
.middle-month-head:hover { background: var(--pm-surface-overlay); }
.middle-month-name { flex: 1; }
.middle-month-count {
  font-size: 0.6875rem; color: var(--pm-text-muted);
  background: var(--pm-surface-overlay);
  padding: 2px 8px; border-radius: 10px;
}
.middle-month-list { padding: 2px 0 4px; }
.middle-month[open] .middle-month-head { color: var(--pm-text-primary); }

/* ── RIGHT COLUMN ── */
.app-main { padding: 32px 28px 60px; width: 100%; }
.app-main .aihot-hero { text-align: left; padding: 0 0 20px; max-width: none; margin: 0; }
.app-main .aihot-hero h1 { font-size: 1.5rem; margin-bottom: 4px; }
.app-main .aihot-feed { max-width: none; margin: 0; padding: 4px 0 40px; }
.app-main .aihot-card { margin-bottom: 10px; }

/* ── Mobile bar (hidden on desktop) ── */
.app-mobile-bar, .app-hamburger, .app-mobile-title, .app-mobile-nav { display: none; }

/* ── Footer ── */
footer { text-align: center; padding: 24px; border-top: var(--pm-border-thin); color: var(--pm-text-muted); font-size: 0.75rem; }
.icp a { color: var(--pm-text-muted); }

/* ── Light mode ── */
[data-theme="light"] .sidebar-logo-hot { color: #1a1a2e; }
[data-theme="light"] .sidebar-link:hover { color: #4a4a6a; background: rgba(0,0,0,0.04); }
[data-theme="light"] .sidebar-link--active { color: #2563eb; background: rgba(37,99,235,0.08); }

/* ═══════════════════════════════════════════════════════════════════════════
   TABLET: compact sidebar, no middle column
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 52px minmax(0, 1fr); }
  .app-sidebar { width: 52px; padding: 12px 8px; }
  .sidebar-label, .sidebar-logo-hot, .sidebar-logo-orbit, .sidebar-brand,
  .sidebar-close, .sidebar-divider, .sidebar-footer { display: none; }
  .sidebar-logo { justify-content: center; }
  .sidebar-link { justify-content: center; padding: 10px 0; border-radius: 8px; }
  .sidebar-icon { margin: 0; }
  .app-middle { display: none; }
  .app-main { padding: 24px 16px 40px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE: single column + sidebar overlay
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .app-shell {
    grid-template-columns: 1fr;
    position: relative;
  }

  /* Sidebar: fixed overlay, hidden by default */
  .app-sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 260px; height: 100vh;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 20px 16px;
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
    align-items: stretch;
  }
  .app-sidebar.open { transform: translateX(0); }

  /* Show full sidebar content */
  .sidebar-close {
    display: flex;
    position: absolute; top: 12px; right: 12px;
    width: 32px; height: 32px;
    align-items: center; justify-content: center;
    border-radius: 6px;
    color: var(--pm-text-muted);
    background: none; border: none; cursor: pointer;
    z-index: 1;
  }
  .sidebar-close:hover { background: var(--pm-surface-overlay); color: var(--pm-text-primary); }
  .sidebar-label { display: inline; }
  .sidebar-logo-hot, .sidebar-logo-orbit { display: inline-flex; }
  .sidebar-brand, .sidebar-divider, .sidebar-footer { display: flex; }
  .sidebar-link { justify-content: flex-start; padding: 8px 12px; }
  .sidebar-icon { margin: 0 10px 0 0; }
  .sidebar-logo { justify-content: flex-start; }

  /* Mobile top bar */
  .app-mobile-bar {
    display: flex;
    align-items: center; gap: 12px;
    padding: 8px 12px;
    margin: -16px -12px 16px;
    background: var(--pm-surface-container);
    border-bottom: var(--pm-border-thin);
    position: sticky; top: 0; z-index: 30;
  }
  .app-hamburger {
    display: inline-flex;
    align-items: center; justify-content: center;
    width: 36px; height: 36px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    background: var(--pm-surface-container);
    color: var(--pm-text-primary);
    cursor: pointer; flex-shrink: 0;
  }
  .app-hamburger:active { transform: scale(0.94); }
  .app-mobile-title {
    display: block;
    font-size: 0.9375rem; font-weight: 700;
    color: var(--pm-text-primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }

  .app-middle { display: none; }
  .app-main { padding: 16px 12px 32px; }
}
