/* Academic As — Shell: sidebar, topbar, navigation */

/* Brand */
.brand-lockup { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { display: grid; place-items: center; flex: 0 0 auto; width: 45px; height: 45px; padding: 4px; border-radius: 15px; transition: transform 180ms var(--ease-liquid); }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.brand-button { width: 100%; border: 0; color: inherit; background: transparent; text-align: left; padding: 0; }
.brand-button:hover .brand-mark { transform: translateY(-1px) scale(1.02); }
.brand-copy { display: grid; line-height: 1.1; min-width: 0; }
.brand-copy strong { font-size: 15px; font-weight: 760; letter-spacing: 0; white-space: nowrap; }
.brand-copy small { margin-top: 5px; color: var(--ink-faint); font-size: 11px; font-weight: 600; }

/* Academic app shell */
.academic-app { min-height: 100dvh; position: relative; isolation: isolate; }
.mobile-sidebar-backdrop { display: none; position: fixed; z-index: 70; inset: 0; border: 0; pointer-events: none; opacity: 0; background: rgb(2 5 12 / 58%); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); transition: opacity 220ms ease; }

/* Desktop sidebar */
.desktop-sidebar {
  position: fixed; z-index: 30;
  inset: 14px auto 14px 14px;
  width: var(--sidebar-width);
  display: flex; flex-direction: column;
  padding: 16px 13px 13px;
  border-radius: 28px; overflow: hidden;
  animation: crystal-sidebar-in .72s var(--ease-liquid) both;
}
.desktop-sidebar .brand-lockup { padding: 4px 7px 21px; border-bottom: 1px solid var(--line); }
.desktop-sidebar nav { display: grid; gap: 5px; margin-top: 18px; }
.desktop-sidebar nav button,
.sidebar-foot > button {
  position: relative; display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 47px; padding: 0 13px;
  border: 1px solid transparent; border-radius: 15px;
  color: var(--ink-soft); background: transparent;
  font-size: 14px; font-weight: 620; text-align: left;
  transition: color 260ms var(--ease-liquid), background 260ms var(--ease-liquid), transform 260ms var(--ease-liquid);
}
.desktop-sidebar nav button svg, .sidebar-foot > button svg { width: 19px; height: 19px; stroke-width: 1.8; }
.desktop-sidebar nav button:hover, .sidebar-foot > button:hover { color: var(--ink); background: rgb(255 255 255 / 7%); transform: translateX(3px); }
.desktop-sidebar nav button.is-active, .sidebar-foot > button.is-active {
  color: var(--ink); border-color: var(--line);
  background: linear-gradient(120deg, rgb(110 92 255 / 15%), rgb(54 213 255 / 7%));
  box-shadow: inset 0 1px rgb(255 255 255 / 12%);
}
.desktop-sidebar nav button.is-active::before {
  content: ""; position: absolute; left: 5px; width: 3px; height: 18px;
  border-radius: 4px; background: linear-gradient(var(--violet), var(--cyan));
  box-shadow: 0 0 12px rgb(110 92 255 / 60%);
  animation: crystal-nav-pulse 2.8s ease-in-out infinite;
}
.desktop-sidebar nav button .nav-badge {
  margin-left: auto; display: grid; place-items: center;
  min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 999px; color: white; background: var(--danger); font-size: 11px;
}
.sidebar-foot { display: grid; gap: 10px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.mini-profile { display: grid; grid-template-columns: 38px 1fr; align-items: center; gap: 10px; padding: 8px; border-radius: 16px; background: rgb(255 255 255 / 5%); }
.mini-profile > .profile-avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 13px; color: white; background: linear-gradient(145deg, var(--violet), #2aaee4); font-weight: 800; }
.mini-profile > div { display: grid; min-width: 0; }
.mini-profile strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.mini-profile small { color: var(--ink-faint); font-size: 10px; }

/* App stage */
.app-stage { min-height: 100dvh; margin-left: calc(var(--sidebar-width) + 28px); padding: 14px 14px 60px 0; }

/* Top control bar */
.top-control {
  position: sticky; z-index: 25; top: 14px;
  display: flex; align-items: center; justify-content: space-between;
  min-height: 64px; padding: 8px 10px 8px 18px;
  border-radius: 22px;
  animation: crystal-topbar-in .68s .08s var(--ease-liquid) both;
}
.sidebar-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0;
  border: 1px solid var(--line); border-radius: 13px;
  color: var(--ink-soft); background: rgb(255 255 255 / 5%);
}
.sidebar-toggle-lines { display: flex; flex-direction: column; gap: 4px; width: 16px; }
.sidebar-toggle-lines i { display: block; height: 2px; background: currentColor; border-radius: 2px; transition: transform 200ms ease, opacity 200ms ease; }
.sidebar-toggle.is-open .sidebar-toggle-lines i:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.sidebar-toggle.is-open .sidebar-toggle-lines i:nth-child(2) { opacity: 0; transform: scaleX(0); }
.sidebar-toggle.is-open .sidebar-toggle-lines i:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.mobile-brand { display: none; align-items: center; gap: 10px; }
.mobile-brand .brand-mark { width: 38px; height: 38px; border-radius: 13px; }
.mobile-brand strong { font-size: 13px; }

.evaluation-picker { display: flex; align-items: center; gap: 10px; }
.evaluation-picker > label { color: var(--ink-faint); font-size: 10px; font-weight: 800; }
.top-select {
  min-width: 112px; height: 40px;
  border: 0; border-radius: 13px;
  background: rgb(255 255 255 / 7%); color: var(--ink);
  font-weight: 700; padding: 0 10px;
  box-shadow: inset 0 1px rgb(255 255 255 / 7%);
}

.top-actions { display: flex; align-items: center; gap: 8px; }

/* Sync badge */
.sync-badge {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 28px; padding: 0 9px;
  border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink-faint); background: rgb(255 255 255 / 5%);
  font-size: 10px; font-weight: 700; white-space: nowrap;
}
.sync-badge svg { width: 13px; height: 13px; }
.sync-saving .sync-badge svg, .sync-loading .sync-badge svg { animation: spin 1s linear infinite; }
.sync-badge.is-saved { color: var(--success); }
.sync-badge.is-offline, .sync-badge.is-error { color: var(--warning); }

/* Command trigger */
.command-trigger {
  display: flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 9px 0 12px;
  border: 1px solid var(--line); border-radius: 13px;
  color: var(--ink-soft); background: rgb(255 255 255 / 5%); font-size: 12px;
}
.command-trigger svg { width: 16px; }
.command-trigger kbd { padding: 3px 6px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink-faint); background: rgb(255 255 255 / 6%); font-size: 10px; }

/* Create button/menu */
.create-wrap { position: relative; }
.create-menu {
  position: absolute; top: calc(100% + 10px); right: 0; width: 292px;
  display: grid; gap: 3px; padding: 7px;
  border-radius: 20px; z-index: 50;
  animation: reveal 180ms var(--ease-liquid);
}
.create-menu button {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px;
  border: 0; border-radius: 14px; color: var(--ink); background: transparent; text-align: left;
}
.create-menu button:hover { background: rgb(110 92 255 / 10%); }
.create-menu button > svg { width: 19px; color: var(--violet-soft); }
.create-menu button > .menu-text { display: grid; }
.create-menu strong { font-size: 13px; }
.create-menu small { margin-top: 2px; color: var(--ink-faint); font-size: 11px; }

/* App content */
.app-content { width: min(100%, 1240px); margin: 0 auto; padding: 44px 26px 30px; }

/* View transitions */
.view-stack { display: grid; gap: 28px; animation: page-in 340ms var(--ease-liquid); }
.view-stack > * { animation: crystal-content-in .56s var(--ease-liquid) both; }
.view-stack > :nth-child(2) { animation-delay: .06s; }
.view-stack > :nth-child(3) { animation-delay: .12s; }
.view-stack > :nth-child(4) { animation-delay: .18s; }

.page-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; min-height: 92px; }
.page-intro h1 { margin: 0; font-size: clamp(34px, 4vw, 52px); line-height: .98; letter-spacing: 0; font-weight: 760; }
.page-intro > div > p { max-width: 650px; margin: 10px 0 0; color: var(--ink-soft); font-size: 15px; }
.page-intro--actions { align-items: flex-end; }
.header-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }

/* System status */
.system-status { display: flex; align-items: center; gap: 10px; min-width: 124px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.system-status svg { width: 22px; filter: drop-shadow(0 0 7px currentColor); }
.system-status span { display: grid; font-size: 13px; font-weight: 750; }
.system-status small { color: var(--ink-faint); font-size: 8px; }
.system-status.is-calm svg { color: var(--success); }
.system-status.has-alert svg { color: var(--warning); }

/* Content panels */
.content-panel {
  border: 1px solid var(--line); border-radius: 28px;
  background: var(--surface);
  background-image: linear-gradient(145deg, rgb(255 255 255 / 7%), transparent 38%, rgb(110 92 255 / 3%));
  box-shadow: 0 16px 48px rgb(0 0 0 / 6%), inset 0 1px rgb(255 255 255 / 5%);
  padding: 18px;
  transition: transform .32s var(--ease-liquid), border-color .28s ease, box-shadow .32s ease;
}
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 32px; margin-bottom: 11px; }
.section-heading h2 { margin: 0; font-size: 14px; font-weight: 760; }
.section-heading button { display: flex; align-items: center; gap: 2px; border: 0; color: var(--violet-soft); background: transparent; font-size: 12px; font-weight: 700; }
.section-heading button svg { width: 14px; }
.panel-kicker { color: var(--cyan); font-size: 10px; font-weight: 820; }
.empty-state { min-height: 170px; display: grid; place-items: center; align-content: center; padding: 24px; text-align: center; }
.empty-state > span { display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 10px; border-radius: 16px; color: var(--violet-soft); background: rgb(110 92 255 / 11%); }
.empty-state svg { width: 22px; }
.empty-state strong { font-size: 14px; }
.empty-state p { max-width: 330px; margin: 4px 0 14px; color: var(--ink-faint); font-size: 12px; }

/* Mobile tabbar */
.mobile-tabbar { display: none; }

/* Loading screen */
.loading-screen { min-height: calc(100dvh - 150px); display: grid; place-items: center; align-content: center; gap: 10px; }
.loading-screen .brand-logo { width: 70px; height: 70px; object-fit: contain; animation: float 2s ease-in-out infinite; }
.loading-screen .loading-bar { width: 90px; height: 3px; overflow: hidden; border-radius: 999px; background: var(--line); }
.loading-screen .loading-bar::after { content: ""; display: block; width: 45%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--violet), var(--cyan)); animation: loading-bar 1.2s ease-in-out infinite; }
.loading-screen p { margin: 0; color: var(--ink-faint); font-size: 11px; }

/* Hover effects */
@media (hover: hover) {
  .content-panel:hover { border-color: color-mix(in srgb, var(--violet) 22%, var(--line)); box-shadow: 0 22px 58px rgb(0 0 0 / 9%), inset 0 1px rgb(255 255 255 / 8%); }
  .desktop-sidebar nav button:hover, .sidebar-foot > button:hover { transform: translateX(3px); }
  .mobile-tabbar button:hover > span { transform: translateY(-2px); }
}

/* Responsive — tablet */
@media (max-width: 1100px) {
  .brand-copy small { display: none; }
}

/* Responsive — mobile */
@media (max-width: 860px) {
  :root { --top-height: 68px; }
  .desktop-sidebar {
    display: flex; z-index: 80;
    inset: max(10px, env(safe-area-inset-top)) auto max(10px, env(safe-area-inset-bottom)) 10px;
    width: min(308px, calc(100vw - 46px));
    transform: translateX(calc(-100% - 24px));
    transition: transform 260ms var(--ease-liquid);
    animation: none;
  }
  .academic-app.mobile-sidebar-open .desktop-sidebar { transform: translateX(0); }
  .mobile-sidebar-backdrop { display: block; }
  .academic-app.mobile-sidebar-open .mobile-sidebar-backdrop { pointer-events: auto; opacity: 1; }
  .app-stage { margin-left: 0; padding: max(9px, env(safe-area-inset-top)) 9px calc(96px + env(safe-area-inset-bottom)); }
  .top-control { top: max(9px, env(safe-area-inset-top)); min-height: 58px; padding: 7px 8px 7px 11px; border-radius: 20px; }
  .mobile-brand { display: flex; }
  .evaluation-picker { display: none; }
  .top-actions .sync-badge { display: none; }
  .command-trigger span, .command-trigger kbd { display: none; }
  .command-trigger { width: 40px; justify-content: center; padding: 0; }
  .create-wrap .create-btn-text { display: none; }
  .create-wrap button.btn-primary { min-width: 42px; padding: 0; }
  .create-menu { position: fixed; top: calc(max(9px, env(safe-area-inset-top)) + 68px); right: 12px; width: calc(100% - 24px); }
  .app-content { padding: 35px 7px 20px; }
  .page-intro { min-height: 80px; align-items: flex-end; }
  .page-intro h1 { font-size: 38px; }
  .mobile-tabbar {
    position: fixed; z-index: 40;
    left: 50%; bottom: max(9px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    display: grid; grid-template-columns: repeat(5,1fr);
    width: min(calc(100% - 18px), 540px); min-height: 69px; padding: 6px;
    border-radius: 24px;
    box-shadow: 0 22px 55px rgb(0 0 0 / 34%), inset 0 1px rgb(255 255 255 / 15%);
    -webkit-backdrop-filter: blur(28px) saturate(155%); backdrop-filter: blur(28px) saturate(155%);
  }
  .mobile-tabbar button {
    display: grid; place-items: center; align-content: center; gap: 3px;
    min-width: 0; border: 0; border-radius: 18px;
    color: var(--ink-faint); background: transparent;
    touch-action: manipulation;
  }
  .mobile-tabbar button > span { position: relative; display: grid; place-items: center; width: 31px; height: 27px; border-radius: 12px; transition: transform 260ms var(--ease-liquid); }
  .mobile-tabbar button svg { width: 19px; height: 19px; stroke-width: 1.9; }
  .mobile-tabbar button small { font-size: 9px; font-weight: 680; }
  .mobile-tabbar button.is-active { color: var(--violet-soft); }
  .mobile-tabbar button.is-active > span { background: rgb(110 92 255 / 14%); box-shadow: inset 0 1px rgb(255 255 255 / 9%); }
  .mobile-tabbar button .tab-badge { position: absolute; right: -5px; top: -5px; display: grid; place-items: center; min-width: 16px; height: 16px; padding: 0 4px; border: 2px solid var(--surface-solid); border-radius: 999px; color: white; background: var(--danger); font-size: 7px; }
}

@media (max-width: 660px) {
  .view-stack { gap: 21px; }
  .page-intro h1 { font-size: 35px; }
}

/* Agent view overrides */
.academic-app.is-agent-view .top-control,
.academic-app.is-agent-view .mobile-tabbar { display: none; }
.academic-app.is-agent-view .app-stage { height: 100dvh; padding-bottom: 14px; }
.academic-app.is-agent-view .app-content { height: 100%; padding: 0; }
@media (max-width: 860px) {
  .academic-app.is-agent-view .app-stage { padding: 0; }
}