/* App shell, navigation layout, and responsive grids. */

.app {
        height: 100vh;
        display: grid;
        grid-template-columns: 280px 1fr;
        background: var(--bg);
        overflow: hidden;
      }

.auth-required .app {
        display: none;
      }

.auth-gate {
        min-height: 100vh;
        display: grid;
        place-items: center;
        padding: 32px;
        background: var(--bg);
      }

.auth-gate[hidden] {
        display: none;
      }

.auth-card {
        width: min(560px, 100%);
        display: grid;
        gap: 22px;
        padding: 32px;
        border: 1px solid var(--line-soft);
        border-radius: 16px;
        background: var(--surface);
        box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
      }

.auth-brand {
        display: flex;
        gap: 14px;
        align-items: flex-start;
      }

.auth-brand h1 {
        font-size: 24px;
        line-height: 32px;
        font-weight: 750;
      }

.auth-brand p,
      .auth-note {
        color: var(--muted);
        line-height: 1.6;
      }

.auth-form {
        display: grid;
        gap: 14px;
      }

.auth-form label {
        display: grid;
        gap: 7px;
        color: var(--muted);
        font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
        font-size: 12px;
        font-weight: 700;
        text-transform: uppercase;
      }

.auth-form label[hidden] {
        display: none;
      }

.auth-actions {
        display: grid;
        gap: 10px;
      }

.auth-actions .btn {
        width: 100%;
        min-height: 44px;
      }

.auth-switch {
        margin: -2px 0 0;
        color: var(--muted);
        text-align: center;
        font-size: 14px;
        line-height: 22px;
      }

.auth-switch button {
        padding: 0;
        border: 0;
        color: var(--primary);
        background: transparent;
        cursor: pointer;
        font: inherit;
        font-weight: 700;
      }

.auth-switch button:hover {
        text-decoration: underline;
      }

.auth-demo-panel {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 18px;
        padding-top: 20px;
        border-top: 1px solid var(--line-soft);
      }

.auth-demo-panel strong {
        color: var(--text);
        font-size: 14px;
      }

.auth-demo-panel p {
        margin-top: 4px;
        color: var(--muted);
        font-size: 13px;
        line-height: 20px;
      }

.auth-demo {
        flex: 0 0 auto;
        color: var(--muted);
        background: var(--surface);
      }

.sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        display: flex;
        flex-direction: column;
        gap: 16px;
        padding: 16px;
        border-right: 1px solid var(--line-soft);
        background: var(--bg-soft);
      }

.brand {
        margin-bottom: 0;
        padding: 0 8px 8px;
      }

.brand-mark {
        width: 32px;
        height: 32px;
        display: inline-grid;
        place-items: center;
        margin: 0 12px 0 0;
        border: 0;
        border-radius: 4px;
        color: #ffffff;
        background: #000000;
        vertical-align: middle;
      }

.brand h1 {
        display: inline-block;
        vertical-align: middle;
        font-size: 18px;
        line-height: 24px;
        font-weight: 650;
      }

.brand p {
        margin: 4px 0 0 44px;
        color: var(--muted);
        font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
        font-size: 13px;
        line-height: 16px;
      }

.main {
        height: 100vh;
        min-width: 0;
        display: flex;
        flex-direction: column;
        padding: 0;
        background: var(--bg);
        overflow: hidden;
      }

.topbar {
        flex: 0 0 64px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 18px;
        margin: 0;
        padding: 0 24px;
        border-bottom: 1px solid var(--line-soft);
        background: var(--bg);
      }

.page-title h2 {
        font-size: 18px;
        line-height: 24px;
        font-weight: 700;
      }

.page-title p {
        display: none;
      }

.status-line {
        display: flex;
        align-items: center;
        gap: 8px;
        min-height: 30px;
        padding: 0 13px;
        border: 1px solid var(--line-soft);
        border-radius: 999px;
        background: var(--surface-2);
        color: var(--muted);
        font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
        font-size: 13px;
      }

.status-line.identity {
        min-height: 32px;
        padding: 0;
        border: 0;
        background: transparent;
      }

.status-line.identity .dot {
        display: none;
      }

.status-line.identity::after {
        content: "";
        width: 32px;
        height: 32px;
        border: 1px solid var(--line-soft);
        border-radius: 999px;
        background: #e0e3e5;
        background-size: cover;
        background-position: center;
      }

.status-line.identity.has-avatar::after {
        background-image: var(--session-avatar-image);
      }

.topbar-actions {
        display: flex;
        align-items: center;
        gap: 12px;
      }

.tab-panel {
        display: none;
      }

.tab-panel:focus,
.tab-panel:focus-visible {
        outline: none;
      }

.tab-panel.active {
        display: block;
        flex: 1 1 auto;
        min-height: 0;
        overflow: auto;
        padding: 24px 26.5px 96px;
      }

.grid {
        display: grid;
        gap: 18px;
      }

.grid.two {
        grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
      }

.grid.three {
        grid-template-columns: repeat(3, minmax(0, 1fr));
      }

.study-grid {
        display: grid;
        grid-template-columns: minmax(230px, 288px) minmax(360px, 1fr) minmax(280px, 320px);
        gap: 16px;
        align-items: start;
      }

.study-workspace {
        min-height: calc(100vh - 132px);
      }

.study-chat-panel {
        min-width: 0;
      }

.spacer {
        flex: 1;
      }

body[data-active-tab="study"] {
        overflow: hidden;
      }

body[data-active-tab="study"] .app {
        height: 100vh;
        overflow: hidden;
      }

body[data-active-tab="study"] .main {
        overflow: hidden;
      }

body[data-active-tab="study"] .topbar {
        background: var(--bg);
      }

body[data-active-tab="study"] .status-line {
        gap: 8px;
        min-height: 32px;
        padding: 0;
        border: 0;
        background: transparent;
      }

body[data-active-tab="study"] .status-line .dot,
      body[data-active-tab="study"] .status-line #systemStatus {
        display: none;
      }

body[data-active-tab="study"] .status-line::before {
        content: attr(data-session-label);
        color: var(--muted);
        font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
        font-size: 13px;
        line-height: 16px;
      }

body[data-active-tab="study"] .status-line::after {
        content: "";
        width: 32px;
        height: 32px;
        border: 1px solid var(--line-soft);
        border-radius: 999px;
        background: #e0e3e5;
        background-size: cover;
        background-position: center;
      }

body[data-active-tab="study"] .status-line.has-avatar::after {
        background-image: var(--session-avatar-image);
      }

body.guest-demo[data-active-tab="study"] .status-line::before {
        color: #160f6e;
      }

body.guest-demo[data-active-tab="study"] .status-line::after {
        border-color: #b9b5ff;
        background: #ecebff;
      }

body[data-active-tab="study"] #signOut {
        min-height: 32px;
        padding: 0 12px;
        border-color: var(--line-soft);
        background: #ffffff;
        color: var(--text);
        box-shadow: none;
      }

body.guest-demo[data-active-tab="study"] #signOut {
        border-color: #111111;
        background: #111111;
        color: #ffffff;
      }

body[data-active-tab="study"] .page-title h2 {
        font-size: 18px;
        font-weight: 700;
      }

body[data-active-tab="study"] .page-title p {
        display: none;
      }

body[data-active-tab="study"] #study {
        flex: 1 1 auto;
        min-height: 0;
        padding: 0;
        overflow: hidden;
      }

body[data-active-tab="study"] .study-grid {
        height: 100%;
        min-height: 0;
        grid-template-columns: 288px minmax(0, 1fr) 320px;
        gap: 0;
        align-items: stretch;
      }

body[data-active-tab="study"] .study-history-panel,
      body[data-active-tab="study"] .study-context-panel {
        height: 100%;
        overflow: hidden;
        border-width: 0 1px 0 0;
        border-radius: 0;
        background: #ffffff;
        box-shadow: none;
      }

body[data-active-tab="study"] .study-context-panel {
        border-width: 0 0 0 1px;
      }

body[data-active-tab="study"] .study-chat-panel {
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        border: 0;
        border-radius: 0;
        background: var(--bg);
        box-shadow: none;
      }
