  /* ---------- Tokens ---------------------------------------------------- */
  :root {
    --bg:           #1a1715;
    --bg-elev-0:    #1f1c1a;
    --bg-elev-1:    #25211e;
    --bg-elev-2:    #2c2825;
    --bg-elev-3:    #36312d;

    --border:       #383330;
    --border-soft:  #2e2a27;
    --border-strong:#4a433d;

    --text:         #f1ece5;
    --text-muted:   #a59c92;
    --text-dim:     #756c63;
    --text-faint:   #5a5249;

    --accent:       #cc785c;
    --accent-2:     #d88a70;
    --accent-soft:  rgba(204, 120, 92, 0.13);
    --accent-line:  rgba(204, 120, 92, 0.38);

    --user-bg:      #2a3142;
    --user-border:  #38415a;
    --user-text:    #e7ecf5;

    --assistant-bg: #25211e;
    --assistant-border: #322d29;

    --code-bg:      #15120f;
    --code-border:  #2a2622;

    --error:        #d2685c;
    --error-bg:     rgba(210, 104, 92, 0.08);
    --error-border: rgba(210, 104, 92, 0.45);

    --success:      #7aae7a;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.25);
    --shadow-md: 0 4px 14px rgba(0,0,0,0.32), 0 1px 2px rgba(0,0,0,0.4);
    --shadow-lg: 0 24px 60px rgba(0,0,0,0.5), 0 4px 12px rgba(0,0,0,0.4);

    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;
    --r-xl: 18px;

    --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;

    --t-fast: 120ms cubic-bezier(.4,0,.2,1);
    --t-med:  220ms cubic-bezier(.4,0,.2,1);
  }

  * { box-sizing: border-box; }
  [hidden] { display: none !important; }
  /* Phase 2b permission card */
  .permcard {
    background: rgba(210, 104, 92, 0.08);
    border: 1px solid rgba(210, 104, 92, 0.45);
    border-radius: 10px;
    padding: 10px 12px;
    margin: 6px 0;
    font-size: 13px;
    display: flex; flex-direction: column; gap: 8px;
  }
  .permcard .perm-label {
    color: #e57373;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
  .permcard .perm-head {
    display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  }
  .permcard .perm-tool {
    font-weight: 600;
    color: #f1ece5;
  }
  .permcard .perm-preview {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    color: #a59c92;
    font-size: 12px;
    word-break: break-all;
  }
  .permcard .perm-input { font-size: 12px; }
  .permcard .perm-input summary {
    cursor: pointer;
    color: #a59c92;
    list-style: none;
    user-select: none;
  }
  .permcard .perm-input summary::before { content: "▸ "; }
  .permcard .perm-input[open] summary::before { content: "▾ "; }
  .permcard .perm-input pre {
    margin: 6px 0 0;
    padding: 8px 10px;
    background: #15120f;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 12px;
  }
  .permcard .perm-actions {
    display: flex; flex-wrap: wrap; gap: 6px;
  }
  .permcard .perm-btn { padding: 6px 12px; }
  .permcard .perm-btn.perm-deny {
    border-color: #d2685c;
    color: #d2685c;
  }
  .permcard .perm-btn.perm-deny:hover {
    background: rgba(210, 104, 92, 0.15);
  }
  .permcard .perm-btn:disabled { opacity: 0.55; cursor: default; }
  .permcard .perm-status {
    font-size: 11.5px;
    color: #a59c92;
  }
  .permcard .perm-status.done { color: #7aae7a; }
  html, body { height: 100%; }
  body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow: hidden;
  }
  button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
  input, textarea, select { font: inherit; color: inherit; }
  a { color: var(--accent-2); text-decoration: none; }
  a:hover { color: var(--accent); }
  ::selection { background: var(--accent-soft); color: var(--text); }

  /* Scrollbars */
  *::-webkit-scrollbar { width: 10px; height: 10px; }
  *::-webkit-scrollbar-track { background: transparent; }
  *::-webkit-scrollbar-thumb {
    background: #3a342f;
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: padding-box;
  }
  *::-webkit-scrollbar-thumb:hover { background: #4a433d; background-clip: padding-box; border: 2px solid transparent; }

  /* ---------- App shell ------------------------------------------------- */
  .app {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: 100vh;
    height: 100dvh;
  }

  /* ---------- Sidebar -------------------------------------------------- */
  .sidebar {
    background: var(--bg-elev-0);
    border-right: 1px solid var(--border-soft);
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  .sidebar-header {
    padding: 18px 18px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  .sidebar-title {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    text-transform: uppercase;
  }
  .sidebar-title .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 12px var(--accent-line);
  }
  .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: var(--r-sm);
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--border);
    transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
  }
  .btn:hover { color: var(--text); background: var(--bg-elev-2); border-color: var(--border-strong); }
  .btn:active { transform: translateY(1px); }
  .btn.primary {
    background: var(--accent);
    color: #1a1110;
    border-color: var(--accent);
    font-weight: 600;
  }
  .btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: #1a1110; }
  .btn.primary:disabled { opacity: 0.5; cursor: not-allowed; }
  .btn.ghost { border-color: transparent; }
  .btn.ghost:hover { border-color: var(--border); }
  .btn .plus { font-size: 14px; line-height: 1; margin-top: -1px; }

  .session-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .session-item {
    position: relative;
    padding: 10px 12px 10px 14px;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: background var(--t-fast);
    border-left: 2px solid transparent;
  }
  .session-item:hover { background: var(--bg-elev-1); }
  .session-item.active {
    background: var(--bg-elev-2);
    border-left-color: var(--accent);
  }
  .session-item.active .session-title { color: var(--text); }
  .session-title {
    font-size: 13.5px;
    color: var(--text);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
  }
  .session-meta {
    font-size: 11.5px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .session-meta .sep { opacity: 0.6; }
  .session-item.streaming .session-meta::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
    animation: pulse 1.4s ease-in-out infinite;
    margin-right: 2px;
  }
  @keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
  }

  .sidebar-footer {
    padding: 12px 18px 16px;
    border-top: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 11px;
    color: var(--text-faint);
  }
  .sidebar-footer .ver { font-family: var(--font-mono); letter-spacing: -0.01em; }
  .sidebar-footer .ver .perm {
    color: var(--accent);
    opacity: 0.85;
  }
  .sidebar-footer .logout {
    font-size: 11.5px;
    color: var(--text-dim);
    padding: 3px 6px;
    border-radius: 4px;
    transition: color var(--t-fast), background var(--t-fast);
  }
  .sidebar-footer .logout:hover { color: var(--text); background: var(--bg-elev-2); }

  /* ---------- Main panel ----------------------------------------------- */
  .main {
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 0;
    background: var(--bg);
    position: relative;
  }
  .main-header {
    padding: 18px 28px 16px;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    gap: 14px;
    background: linear-gradient(to bottom, rgba(26,23,21,0.85), rgba(26,23,21,0.0));
    backdrop-filter: blur(8px);
  }
  .mobile-toggle {
    display: none;
    padding: 8px;
    border-radius: var(--r-sm);
    color: var(--text-muted);
  }
  .mobile-toggle:hover { background: var(--bg-elev-2); color: var(--text); }
  .header-text { flex: 1; min-width: 0; }
  .session-name {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .session-subtitle {
    margin-top: 3px;
    font-size: 12.5px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .session-subtitle .sep { padding: 0 6px; opacity: 0.5; }
  .session-subtitle .model { color: var(--accent); opacity: 0.9; }
  .stop-btn {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 6px 11px;
    border-radius: var(--r-sm);
    color: var(--text-muted);
    border: 1px solid var(--border);
    font-size: 12.5px;
    transition: all var(--t-fast);
  }
  .stop-btn.visible { display: inline-flex; animation: fadeIn 200ms ease-out; }
  .stop-btn:hover { color: var(--error); border-color: var(--error-border); background: var(--error-bg); }
  .stop-btn .sq { width: 8px; height: 8px; background: currentColor; border-radius: 2px; }

  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* ---------- Messages -------------------------------------------------- */
  .messages {
    overflow-y: auto;
    padding: 24px 28px 40px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    scroll-behavior: smooth;
  }
  .msg-row {
    display: flex;
    width: 100%;
    animation: msgIn 320ms cubic-bezier(.4,0,.2,1);
  }
  .msg-row.user { justify-content: flex-end; }
  .msg-row.assistant { justify-content: flex-start; }

  @keyframes msgIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .bubble {
    max-width: 720px;
    border-radius: var(--r-lg);
    padding: 14px 18px;
    font-size: 14.5px;
    line-height: 1.6;
  }
  .bubble.user {
    background: var(--user-bg);
    border: 1px solid var(--user-border);
    color: var(--user-text);
    border-bottom-right-radius: 6px;
  }
  .bubble.assistant {
    background: var(--assistant-bg);
    border: 1px solid var(--assistant-border);
    color: var(--text);
    border-bottom-left-radius: 6px;
    box-shadow: var(--shadow-sm);
  }

  /* Markdown styling inside assistant */
  .bubble.assistant > *:first-child { margin-top: 0; }
  .bubble.assistant > *:last-child { margin-bottom: 0; }
  .bubble.assistant h2 {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 18px 0 8px;
    color: var(--text);
  }
  .bubble.assistant h3 {
    font-size: 14.5px;
    font-weight: 600;
    margin: 14px 0 6px;
    color: var(--text);
  }
  .bubble.assistant p { margin: 0 0 10px; }
  .bubble.assistant p:last-child { margin-bottom: 0; }
  .bubble.assistant ul, .bubble.assistant ol {
    margin: 6px 0 12px;
    padding-left: 22px;
  }
  .bubble.assistant li { margin: 3px 0; }
  .bubble.assistant li::marker { color: var(--text-dim); }
  .bubble.assistant code:not(pre code) {
    font-family: var(--font-mono);
    font-size: 0.88em;
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    padding: 1px 6px;
    border-radius: 4px;
    color: var(--accent-2);
  }
  .bubble.assistant strong { color: var(--text); font-weight: 600; }
  .bubble.assistant a { border-bottom: 1px solid var(--accent-line); }
  .bubble.assistant hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 14px 0;
  }

  /* Code block */
  .codeblock {
    margin: 10px 0 12px;
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: var(--r-md);
    overflow: hidden;
  }
  .codeblock-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px 7px 14px;
    background: rgba(255,255,255,0.015);
    border-bottom: 1px solid var(--code-border);
  }
  .lang-pill {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
  .copy-btn {
    font-size: 11.5px;
    color: var(--text-dim);
    padding: 3px 7px;
    border-radius: 4px;
    transition: all var(--t-fast);
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }
  .copy-btn:hover { color: var(--text); background: var(--bg-elev-2); }
  .copy-btn.copied { color: var(--success); }
  .codeblock pre {
    margin: 0;
    padding: 12px 14px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.55;
    color: #d8d3cc;
  }
  .codeblock .tok-kw { color: #c98c70; }
  .codeblock .tok-str { color: #9bb38a; }
  .codeblock .tok-fn { color: #d3a86a; }
  .codeblock .tok-com { color: #6a6258; font-style: italic; }
  .codeblock .tok-num { color: #c98c70; }

  /* Tool call card */
  .toolcall {
    margin: 10px 0;
    background: var(--bg-elev-1);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
    transition: border-color var(--t-fast);
  }
  .toolcall.error { border-color: var(--error-border); background: var(--error-bg); }
  .toolcall > summary {
    list-style: none;
    cursor: pointer;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
    transition: background var(--t-fast);
  }
  .toolcall > summary::-webkit-details-marker { display: none; }
  .toolcall > summary:hover { background: rgba(255,255,255,0.02); }
  .toolcall .tool-icon {
    font-size: 14px;
    line-height: 1;
  }
  .toolcall .tool-name {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--text);
    font-weight: 500;
  }
  .toolcall .tool-arg {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
  }
  .toolcall .tool-status {
    font-size: 11px;
    color: var(--text-dim);
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--bg-elev-2);
    border: 1px solid var(--border-soft);
    flex-shrink: 0;
  }
  .toolcall.error .tool-status { color: var(--error); border-color: var(--error-border); background: rgba(210, 104, 92, 0.1); }
  .toolcall .chev {
    color: var(--text-faint);
    transition: transform var(--t-fast);
    flex-shrink: 0;
  }
  .toolcall[open] .chev { transform: rotate(90deg); }
  .toolcall .tool-body {
    padding: 0 14px 12px;
    border-top: 1px solid var(--border-soft);
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .tool-section-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    margin-bottom: 4px;
  }
  .tool-body pre {
    margin: 0;
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: var(--r-sm);
    padding: 9px 11px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: #d4ccc1;
    overflow-x: auto;
    line-height: 1.5;
    max-height: 240px;
    overflow-y: auto;
  }
  .toolcall.error .tool-body pre { color: #e8b9b2; }

  /* Ask-user question card */
  .askcard {
    margin: 10px 0;
    background: linear-gradient(180deg, rgba(204,120,92,0.05), rgba(204,120,92,0.02));
    border: 1px solid var(--accent-line);
    border-radius: var(--r-lg);
    padding: 16px 18px;
  }
  .askcard .ask-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
  }
  .askcard .ask-label::before {
    content: '';
    width: 6px; height: 6px;
    background: var(--accent);
    border-radius: 50%;
  }
  .askcard .ask-q {
    font-weight: 600;
    font-size: 14.5px;
    color: var(--text);
    margin-bottom: 14px;
    line-height: 1.45;
  }
  .ask-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
  }
  .ask-opt {
    padding: 7px 14px;
    border-radius: 999px;
    background: var(--bg-elev-1);
    border: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
    transition: all var(--t-fast);
  }
  .ask-opt:hover { color: var(--text); border-color: var(--border-strong); background: var(--bg-elev-2); }
  .ask-opt.selected {
    background: var(--accent);
    border-color: var(--accent);
    color: #1a1110;
    font-weight: 600;
  }
  .ask-notes {
    width: 100%;
    background: var(--bg-elev-0);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 8px 11px;
    font-size: 13px;
    color: var(--text);
    resize: vertical;
    min-height: 56px;
    font-family: var(--font-sans);
    margin-bottom: 12px;
    outline: none;
    transition: border-color var(--t-fast);
  }
  .ask-notes:focus { border-color: var(--accent); }
  .ask-notes::placeholder { color: var(--text-faint); }
  .ask-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  .ask-status {
    font-size: 12px;
    color: var(--text-dim);
  }
  .ask-status.done { color: var(--success); }

  /* Streaming caret */
  .streaming-caret {
    display: inline-block;
    width: 7px;
    height: 14px;
    background: var(--accent);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 1s steps(2) infinite;
    border-radius: 1px;
  }
  @keyframes blink {
    50% { opacity: 0; }
  }

  /* ---------- Composer + status ---------------------------------------- */
  .composer-wrap {
    border-top: 1px solid var(--border-soft);
    background: var(--bg-elev-0);
    padding: 16px 28px 12px;
  }
  .composer {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg-elev-1);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 8px 8px 8px 14px;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
  }
  .composer:focus-within {
    border-color: var(--accent-line);
    box-shadow: 0 0 0 3px rgba(204,120,92,0.08);
  }
  .composer textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    min-height: 38px;
    max-height: 200px;
    padding: 8px 0;
    color: var(--text);
  }
  .composer textarea::placeholder { color: var(--text-faint); }
  .send-btn {
    padding: 8px 16px;
    border-radius: var(--r-sm);
    background: var(--accent);
    color: #1a1110;
    font-weight: 600;
    font-size: 13px;
    transition: background var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
    align-self: flex-end;
    margin-bottom: 1px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .send-btn:hover:not(:disabled) { background: var(--accent-2); }
  .send-btn:active { transform: translateY(1px); }
  .send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
  .send-btn svg { width: 13px; height: 13px; }

  .status-bar {
    margin-top: 8px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .status-bar .sep { opacity: 0.5; }
  .status-bar .stop-reason { color: var(--text-muted); }
  .status-bar .cost { color: var(--accent); opacity: 0.85; }
  .status-bar.streaming .stop-reason::before {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--accent);
    margin-right: 6px;
    animation: pulse 1.2s ease-in-out infinite;
  }

  /* ---------- Modal ---------------------------------------------------- */
  .modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(10, 8, 7, 0.65);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeBg 180ms ease-out;
    padding: 20px;
  }
  @keyframes fadeBg { from { opacity: 0; } to { opacity: 1; } }
  .modal {
    background: var(--bg-elev-0);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    animation: modalIn 260ms cubic-bezier(.4,0,.2,1);
  }
  @keyframes modalIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }
  .modal-header {
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .modal-title {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
  }
  .modal-close {
    color: var(--text-dim);
    padding: 4px 7px;
    border-radius: 4px;
    font-size: 16px;
    line-height: 1;
    transition: all var(--t-fast);
  }
  .modal-close:hover { color: var(--text); background: var(--bg-elev-2); }

  .modal-body {
    padding: 18px 22px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
  }
  .field {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .field-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .field-label .opt {
    font-size: 10.5px;
    color: var(--text-faint);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  .input, .textarea, .select-input {
    background: var(--bg-elev-1);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 8px 11px;
    font-size: 13.5px;
    color: var(--text);
    outline: none;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
    font-family: var(--font-sans);
  }
  .input:focus, .textarea:focus, .select-input:focus {
    border-color: var(--accent-line);
    box-shadow: 0 0 0 3px rgba(204,120,92,0.08);
  }
  .input::placeholder, .textarea::placeholder { color: var(--text-faint); }
  .textarea { resize: vertical; min-height: 64px; font-family: var(--font-mono); font-size: 12.5px; }
  .input.mono { font-family: var(--font-mono); font-size: 12.5px; }

  /* File browser */
  .browser {
    background: var(--bg-elev-1);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow: hidden;
  }
  .browser-top {
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--bg-elev-0);
  }
  .root-select {
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 4px 8px;
    font-size: 12px;
    color: var(--text);
    font-family: var(--font-mono);
    outline: none;
    cursor: pointer;
  }
  .root-select:focus { border-color: var(--accent-line); }
  .show-hidden {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    color: var(--text-dim);
    cursor: pointer;
    user-select: none;
  }
  .show-hidden input { accent-color: var(--accent); margin: 0; }

  .breadcrumb {
    padding: 8px 12px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
  }
  .crumb {
    padding: 1px 6px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-muted);
    transition: color var(--t-fast), background var(--t-fast);
  }
  .crumb:hover { color: var(--text); background: var(--bg-elev-2); }
  .crumb.current { color: var(--text); }
  .crumb-sep { color: var(--text-faint); }

  .file-list {
    max-height: 220px;
    overflow-y: auto;
    padding: 4px 0;
  }
  .file-row {
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
    cursor: pointer;
    transition: background var(--t-fast);
    color: var(--text-muted);
  }
  .file-row:hover { background: var(--bg-elev-2); color: var(--text); }
  .file-row.up { color: var(--text-dim); }
  .file-row .ficon { width: 16px; text-align: center; opacity: 0.85; flex-shrink: 0; }
  .file-row.hidden-item { opacity: 0.55; }
  .file-row .fname { font-family: var(--font-mono); font-size: 12.5px; }
  .file-row .fname.folder { color: var(--text); }

  .selected-path {
    padding: 9px 12px;
    border-top: 1px solid var(--border-soft);
    background: var(--bg-elev-0);
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .selected-path .label { color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; font-size: 10px; }
  .selected-path .path { color: var(--accent-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }

  .modal-footer {
    padding: 14px 22px 18px;
    border-top: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
  }

  /* ---------- Login overlay ------------------------------------------- */
  .login-overlay {
    position: fixed; inset: 0;
    background: radial-gradient(ellipse at top, #221c19 0%, #15120f 70%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
  }
  .login-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-elev-1);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 32px 28px 26px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
  }
  .login-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-line), transparent);
  }
  .login-logo {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
    box-shadow: 0 4px 16px rgba(204,120,92,0.3);
  }
  .login-logo svg { width: 22px; height: 22px; color: #1a1110; }
  .login-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.015em;
    margin-bottom: 4px;
  }
  .login-sub {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 22px;
  }
  .login-card .field { margin-bottom: 14px; }
  .login-card .btn.primary { width: 100%; justify-content: center; padding: 9px; font-size: 13.5px; }

  /* ---------- Mobile drawer overlay ----------------------------------- */
  .drawer-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 50;
    animation: fadeBg 180ms ease-out;
  }
  .drawer-backdrop.open { display: block; }

  /* ---------- Responsive ----------------------------------------------- */
  @media (max-width: 768px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
      position: fixed;
      top: 0; left: 0; bottom: 0;
      width: 84%;
      max-width: 320px;
      z-index: 60;
      transform: translateX(-100%);
      transition: transform 260ms cubic-bezier(.4,0,.2,1);
      box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: translateX(0); }
    .mobile-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .main-header { padding: 14px 18px; }
    .messages { padding: 18px 16px 30px; gap: 22px; }
    .composer-wrap { padding: 12px 16px 10px; }
    .bubble { max-width: 100%; }
    .session-name { font-size: 16px; }
    .session-subtitle { font-size: 11.5px; }
    .modal-backdrop { padding: 0; }
    .modal {
      max-width: 100%;
      height: 100%;
      max-height: 100%;
      border-radius: 0;
      border: none;
    }
  }
