/* The look of the app, on top of the layout in styles.css: warm neutral surfaces, a quiet
   sidebar flush with the window, the content on a rounded panel beside it, small precise
   controls, one warm accent, and short, soft motion. Loaded last, so it has the final word. */

:root {
  --font: Inter, "Inter Variable", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --accent: #e07a5f;
  --accent-hover: #e68b72;
  --accent-press: #d56d52;
  --accent-text: #fff;
  --accent-warm: var(--accent);
  --accent-warm-hover: var(--accent-hover);
  --sidebar-w: 244px;
  --radius-control: 6px;
  --radius-card: 8px;
  --radius-panel: 12px;
  --quick: 120ms cubic-bezier(.2, .8, .2, 1);
  --soft: 180ms cubic-bezier(.22, 1, .36, 1);
}

html[data-theme="dark"] {
  --bg: #1c1c1b;            /* the window and the sidebar */
  --panel: #2b2b29;         /* the content panel */
  --surface: #31312f;       /* cards and fields on the panel */
  --menu: #343432;
  --modal: #2b2b29;
  --sunken: #262624;
  --text: #f9f9f7;
  --text-2: rgba(249, 249, 247, .72);
  --text-3: rgba(249, 249, 247, .52);
  --text-4: rgba(249, 249, 247, .34);
  --border-1: rgba(255, 255, 255, .2);
  --border-2: rgba(255, 255, 255, .12);
  --border-3: rgba(255, 255, 255, .08);
  --divider: rgba(255, 255, 255, .06);
  --fill: rgba(255, 255, 255, .06);
  --fill-hover: rgba(255, 255, 255, .095);
  --selected: rgba(255, 255, 255, .08);
  --track: #232321;
  --raised: #3b3b39;
  --cta: #f9f9f7;
  --cta-hover: #fff;
  --cta-text: #1c1c1b;
  --cta-off: #8d8d8a;
  --composer: #31312f;
  --composer-border: rgba(255, 255, 255, .08);
  --composer-shadow: 0 3px 8px rgba(0, 0, 0, .09), 0 2px 5px rgba(0, 0, 0, .09), 0 1px 1px rgba(0, 0, 0, .1);
  --overlay: rgba(0, 0, 0, .5);
  --shadow-menu: 0 0 0 1px rgba(255, 255, 255, .08), 0 12px 28px -6px rgba(0, 0, 0, .5), 0 4px 8px -4px rgba(0, 0, 0, .35);
  --shadow-modal: 0 0 0 1px rgba(255, 255, 255, .08), 0 24px 48px -12px rgba(0, 0, 0, .6), 0 8px 16px -8px rgba(0, 0, 0, .4);
  --shadow-control: 0 1px 2px rgba(0, 0, 0, .35);
  --panel-ring: 0 0 0 1px rgba(0, 0, 0, .3);
}

html[data-theme="light"] {
  --bg: #f1f0ed;
  --panel: #fdfdfc;
  --surface: #fff;
  --menu: #fff;
  --modal: #fdfdfc;
  --sunken: #f4f3f0;
  --text: #1c1c1b;
  --fill: rgba(28, 28, 27, .05);
  --fill-hover: rgba(28, 28, 27, .08);
  --selected: rgba(28, 28, 27, .07);
  --composer: #fff;
  --composer-border: rgba(28, 28, 27, .1);
  --composer-shadow: 0 3px 8px rgba(0, 0, 0, .04), 0 1px 2px rgba(0, 0, 0, .06);
  --panel-ring: 0 0 0 1px rgba(0, 0, 0, .04);
}

body { font: 400 13px/18px var(--font); letter-spacing: -0.01em; font-feature-settings: "cv11", "ss01"; }

/* ---- Shell: the sidebar sits on the window; the content is a panel of its own beside it. ---- */

#app { background: var(--bg); }
.sidebar { background: transparent; border-right: 0; color: var(--text-2); }
#main {
  margin: 8px 8px 8px 0;
  border-radius: var(--radius-panel);
  background: var(--panel);
  border: 1px solid var(--border-3);
  box-shadow: var(--panel-ring);
  overflow: hidden;
  isolation: isolate;
}
body[data-sidebar="hidden"] #main { margin-left: 8px; }
/* The session's side panel is a second panel, to the right of the conversation. */
.panel { margin: 8px 8px 8px 0; border-radius: var(--radius-panel); background: var(--panel); border: 1px solid var(--border-3); box-shadow: var(--panel-ring); overflow: hidden; }
.panel-head { height: 48px; padding: 0 10px; gap: 4px; }
.panel .icon-btn.md { width: 28px; height: 28px; border-radius: var(--radius-control); color: var(--text-2); }

/* ---- Sidebar ---- */

.side-top { height: 48px; padding: 0 10px 0 12px; gap: 2px; }
.sidebar .icon-btn { width: 26px; height: 26px; border-radius: var(--radius-control); color: var(--text-3); transition: background var(--quick), color var(--quick); }
.sidebar .icon-btn:hover:not(:disabled), .sidebar .icon-btn[aria-expanded="true"] { color: var(--text); }
.surface-toggle { height: 26px; padding: 2px; border-radius: 7px; background: var(--fill); }
.surface-toggle button { width: 26px; height: 22px; border-radius: 5px; transition: background var(--quick), color var(--quick); }
.surface-toggle button[aria-selected="true"] { background: var(--raised); box-shadow: var(--shadow-control); }

.side-nav { gap: 2px; padding: 2px 8px 0; }
.nav-item { height: 28px; padding: 0 8px; gap: 8px; border-radius: var(--radius-control); font-size: 13px; font-weight: 500; letter-spacing: -0.01em; color: var(--text-2); transition: background var(--quick), color var(--quick); }
.nav-item .icon { color: currentColor; opacity: .85; }
.nav-item:hover { background: var(--fill); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--selected); color: var(--text); }
.nav-count { font-weight: 500; }

.side-section { height: 28px; margin-top: 14px; padding: 0 8px 0 16px; }
.side-title { font-size: 12px; font-weight: 500; color: var(--text-3); letter-spacing: 0; }
.side-title:hover { color: var(--text-2); }
.rows { padding: 2px 8px 12px; }
.group-label { min-height: 26px; padding: 6px 4px 0 8px; font-size: 12px; font-weight: 500; color: var(--text-3); }
.srow { padding: 4px 8px 4px 0; border-radius: var(--radius-control); transition: background var(--quick); }
.srow-title { font-size: 13px; font-weight: 500; line-height: 18px; color: var(--text-2); }
.srow:hover .srow-title, .srow[aria-current="page"] .srow-title { color: var(--text); }
.srow-meta { font-size: 11.5px; line-height: 16px; }
.side-empty { font-size: 12px; }

/* The account, at the foot: a small square mark, the name, the hub under it. */
.side-foot { height: 52px; padding: 0 8px; gap: 2px; border-top: 1px solid var(--divider); }
.profile { flex: 1 1 0; height: 40px; padding: 0 8px; gap: 10px; border-radius: var(--radius-control); font-size: 13px; font-weight: 500; text-align: left; transition: background var(--quick); }
.profile .avatar { width: 24px; height: 24px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.profile-text { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; line-height: 15px; }
.profile-text #profile-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-sub { font-size: 11px; font-weight: 400; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile > .icon { color: var(--text-4); }
.side-foot .icon-btn.lg { width: 28px; height: 28px; }
.side-foot .spacer { display: none; }

/* ---- Buttons and small controls ---- */

.btn {
  height: 28px; padding: 0 10px; border-radius: var(--radius-control); background: var(--fill);
  font-size: 13px; font-weight: 500; letter-spacing: -0.01em;
  box-shadow: inset 0 0 0 .5px var(--border-2);
  transition: background var(--quick), color var(--quick), box-shadow var(--quick), transform 80ms ease;
}
.btn:hover:not(:disabled) { background: var(--fill-hover); }
.btn:active:not(:disabled) { transform: translateY(.5px) scale(.985); }
.btn.sm { height: 24px; padding: 0 8px; font-size: 12px; }
.btn.lg { height: 32px; padding: 0 14px; border-radius: 7px; font-size: 13px; }
.btn.block { height: 34px; border-radius: 7px; }
.btn.primary {
  background: var(--accent); color: var(--accent-text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), inset 0 0 0 .5px rgba(0, 0, 0, .18), 0 1px 2px rgba(0, 0, 0, .25);
}
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.primary:active:not(:disabled) { background: var(--accent-press); }
.btn.primary:disabled { background: var(--accent); color: var(--accent-text); opacity: .5; }
.btn.outline { background: transparent; border: 0; box-shadow: inset 0 0 0 .5px var(--border-1); }
.btn.outline:hover:not(:disabled) { background: var(--fill); }
.btn.text { background: none; box-shadow: none; color: var(--text-2); }
.btn.danger { color: var(--danger); }
.btn.danger-solid { background: var(--danger); color: #fff; }

.icon-btn { border-radius: var(--radius-control); transition: background var(--quick), color var(--quick), transform 80ms ease; }
.icon-btn:active:not(:disabled) { transform: scale(.94); }
.select-btn { height: 28px; border-radius: var(--radius-control); border: 0; box-shadow: inset 0 0 0 .5px var(--border-2); background: var(--sunken); font-size: 12px; font-weight: 500; transition: background var(--quick); }
.select-btn:hover, .select-btn[aria-expanded="true"] { background: var(--fill-hover); }
.field { height: 28px; border-radius: var(--radius-control); border: 0; box-shadow: inset 0 0 0 .5px var(--border-2); background: var(--surface); font-size: 13px; transition: box-shadow var(--quick); }
.field:focus { box-shadow: inset 0 0 0 1px var(--border-1); }
textarea.field { padding: 8px 10px; }
.seg { height: 28px; padding: 2px; border-radius: 7px; background: var(--fill); }
.seg button { height: 24px; padding: 0 10px; border-radius: 5px; font-size: 12px; font-weight: 500; transition: background var(--quick), color var(--quick); }

.switch { width: 28px; height: 16px; border-radius: 8px; background: var(--fill-hover); transition: background var(--soft); }
.switch-knob { top: 2px; left: 2px; width: 12px; height: 12px; transition: transform var(--soft); }
.switch[aria-checked="true"], .switch[aria-checked="true"]:hover { background: var(--accent); }
.switch[aria-checked="true"] .switch-knob { transform: translateX(12px); }

.chip-pick, .quiet-pick { transition: background var(--quick), color var(--quick); }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 1px; }

/* ---- Menus, popovers, dialogs ---- */

.menu, .popover { border-radius: 8px; background: var(--menu); box-shadow: var(--shadow-menu); animation: menu-in 140ms cubic-bezier(.2, .9, .3, 1); transform-origin: top center; }
.menu { padding: 4px; }
.menu-item { min-height: 28px; padding: 0 8px; border-radius: 5px; font-size: 13px; font-weight: 450; transition: background 80ms; }
.menu-item + .menu-item { margin-top: 0; }
.menu-divider { margin: 4px -4px; background: var(--border-3); }
.menu-check { color: var(--accent); }
.menu-badge { background: none; padding: 0; font-size: 12px; color: var(--text-3); }
.overlay { background: var(--overlay); animation: fade-in 140ms ease-out; }
.modal { border-radius: var(--radius-panel); background: var(--modal); box-shadow: var(--shadow-modal); animation: modal-in 180ms cubic-bezier(.2, .9, .3, 1); }
.dialog-body h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.015em; }
.dialog-body .field { height: 32px; font-size: 13px; }
.dialog-body textarea.field { height: 88px; }

/* ---- The new-session page ---- */

.backdrop { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; pointer-events: none; z-index: 0; opacity: 0; animation: fade-in 900ms ease-out 80ms forwards; }
.home::before { display: none; }
.home > *:not(.backdrop) { position: relative; z-index: 1; }
.home { overflow: hidden; }
.starter { width: min(712px, 100%); animation: rise-in 420ms cubic-bezier(.2, .9, .3, 1) both; }
.starter-head { margin-bottom: 8px; padding: 0 2px; }
.starter-head .quiet-pick { height: 28px; padding: 0 8px; border-radius: var(--radius-control); font-size: 13px; font-weight: 500; }
.starter-card { min-height: 116px; border-radius: var(--radius-card); background: var(--composer); border: 0; box-shadow: var(--composer-shadow), inset 0 0 0 1px var(--border-3); transition: box-shadow var(--soft); }
html[data-theme="dark"] .starter-card { background: var(--composer); }
.starter-card:focus-within { box-shadow: var(--composer-shadow), inset 0 0 0 1px var(--border-2); }
.starter-card textarea { min-height: 64px; padding: 14px 16px 4px; font-size: 14px; line-height: 20px; }
.starter-tools { gap: 4px; padding: 4px 8px 8px 10px; }
.starter-tools .icon-btn { width: 28px; height: 28px; border-radius: var(--radius-control); }
.starter-tools .chip-pick { height: 28px; padding: 0 8px; border-radius: var(--radius-control); font-size: 13px; font-weight: 500; }
.starter-tools .chip-pick.muted, .starter-tools .chip-pick.muted:hover, .starter-tools .chip-pick.muted[aria-expanded="true"] { padding-left: 8px; }
.starter-tools .send {
  width: 28px; height: 28px; border-radius: var(--radius-control); background: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), inset 0 0 0 .5px rgba(0, 0, 0, .2), 0 1px 2px rgba(0, 0, 0, .3);
  transition: background var(--quick), transform 80ms ease;
}
.starter-tools .send:active:not(:disabled) { transform: scale(.94); }
.starter-tools .send svg { width: 14px; height: 14px; }
.setup-slot { width: min(712px, 100%); animation: rise-in 420ms cubic-bezier(.2, .9, .3, 1) 60ms both; }
.setup-slot .setup-steps { border-radius: var(--radius-card); background: color-mix(in srgb, var(--surface) 70%, transparent); backdrop-filter: blur(6px); }

/* ---- Conversation ---- */

.thread-head { height: 48px; }
.pill-btn { height: 30px; padding: 0 12px 0 6px; border: 0; background: transparent; box-shadow: none; font-size: 13px; font-weight: 500; border-radius: var(--radius-control); transition: background var(--quick); }
.pill-btn:hover, .pill-btn[aria-expanded="true"] { background: var(--fill); }
.composer-pill { border-radius: 10px; }
.messages-inner > * { animation: rise-in 220ms cubic-bezier(.2, .9, .3, 1) both; }

/* ---- Settings: its sections take the sidebar's place; the page is a centred column on the panel. ---- */

.overlay:has(> .modal.settings) { padding: 0; background: var(--bg); animation: none; }
.modal.settings { width: 100%; height: 100%; border-radius: 0; background: var(--bg); box-shadow: none; animation: none; }
.modal.settings > .modal-close { display: none; }
.settings-nav { width: var(--sidebar-w); padding: 0 8px 12px; border-right: 0; }
.back-link { justify-content: flex-start; height: 48px; margin-bottom: 0; padding: 0 4px; }
.back-link button { height: 28px; padding: 0 8px; gap: 8px; border-radius: var(--radius-control); font-size: 13px; font-weight: 500; color: var(--text); }
.set-search { display: flex; align-items: center; gap: 6px; height: 28px; margin: 0 0 6px; padding: 0 8px; border-radius: var(--radius-control); background: var(--surface); box-shadow: inset 0 0 0 .5px var(--border-2); color: var(--text-3); }
.set-search input { flex: 1; min-width: 0; font-size: 13px; }
.set-nav-item { height: 28px; margin-bottom: 2px; padding: 0 8px; gap: 8px; border-radius: var(--radius-control); font-size: 13px; font-weight: 500; color: var(--text-2); transition: background var(--quick), color var(--quick); }
.set-nav-item .icon { color: currentColor; opacity: .85; }
.set-nav-item:hover { color: var(--text); }
.set-nav-item[aria-current="page"] { background: var(--selected); color: var(--text); }
.set-nav-item[hidden] { display: none; }
.set-nav-label { padding: 16px 8px 6px; font-size: 12px; font-weight: 500; color: var(--text-3); }
.settings-body {
  margin: 8px 8px 8px 0; padding: 56px 24px 64px; border-radius: var(--radius-panel);
  background: var(--panel); border: 1px solid var(--border-3); box-shadow: var(--panel-ring);
}
.settings-body > * { width: min(620px, 100%); margin-left: auto; margin-right: auto; animation: rise-in 260ms cubic-bezier(.2, .9, .3, 1) both; }
.set-h { font-size: 22px; line-height: 26px; font-weight: 500; letter-spacing: -0.02em; }
.set-sub { margin-top: 8px; font-size: 13px; color: var(--text-3); }
.set-section { margin-top: 32px; }
.set-label { padding: 0 2px; margin-bottom: 10px; }
.set-label h3 { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--text); }
.set-label p { font-size: 12px; color: var(--text-3); }
.set-label.big h3 { font-size: 13px; color: var(--text); }
.set-card { padding: 0 14px; border: 0; border-radius: var(--radius-card); background: var(--surface); box-shadow: inset 0 0 0 1px var(--border-3); }
.set-card + .set-card { margin-top: 12px; }
.set-card > .set-row + .set-row, .set-card > .set-row + .set-note, .set-card > .set-note + .set-row { border-top: 1px solid var(--border-3); }
.set-card.tight { padding: 0 14px; }
.set-row { min-height: 54px; padding: 9px 0; gap: 16px; }
.set-title { font-size: 13px; line-height: 18px; font-weight: 500; }
.set-desc { font-size: 12px; line-height: 16px; color: var(--text-3); }
.set-control { font-size: 12px; }
.set-note { font-size: 12px; color: var(--text-3); }
.set-row.danger .set-title { color: var(--text); }
.set-avatar { display: flex; align-items: center; gap: 8px; }
.set-avatar .avatar { width: 28px; height: 28px; border-radius: 7px; font-size: 13px; font-weight: 600; }
.set-mono { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); }

/* Appearance: the three ways the app can look, as small pictures of it. */
.look-picks { display: flex; gap: 10px; }
.look-pick { width: 64px; height: 46px; padding: 0; border-radius: 7px; overflow: hidden; position: relative; box-shadow: inset 0 0 0 1px var(--border-2); transition: box-shadow var(--quick), transform 80ms ease; }
.look-pick:active { transform: scale(.97); }
.look-pick[aria-checked="true"] { box-shadow: 0 0 0 1.5px var(--accent); }
.look-pick i { position: absolute; display: block; border-radius: 2px; }
.look-pick[data-look="dark"] { background: #1c1c1b; }
.look-pick[data-look="light"] { background: #f4f3f0; }
.look-pick[data-look="system"] { background: linear-gradient(90deg, #f4f3f0 50%, #1c1c1b 50%); }
.look-pick .lp-panel { inset: 6px 6px 6px 18px; border-radius: 4px; }
.look-pick[data-look="dark"] .lp-panel { background: #2b2b29; }
.look-pick[data-look="light"] .lp-panel { background: #fff; box-shadow: 0 0 0 .5px rgba(0, 0, 0, .1); }
.look-pick[data-look="system"] .lp-panel { background: linear-gradient(90deg, #fff 44%, #2b2b29 44%); }
.look-pick .lp-line { left: 24px; right: 22px; top: 14px; height: 3px; background: rgba(128, 128, 128, .45); }
.look-pick .lp-line.two { top: 21px; right: 30px; }
.look-pick .lp-dot { right: 10px; bottom: 10px; width: 6px; height: 6px; border-radius: 2px; background: var(--accent); }

/* ---- Motion ---- */

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes menu-in { from { opacity: 0; transform: translateY(-3px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

/* ---- Phone: no panels inside panels; the content is the screen. ---- */

@media (max-width: 767px) {
  #main, .panel { margin: 0; border-radius: 0; border: 0; box-shadow: none; }
  body[data-sidebar="hidden"] #main { margin-left: 0; }
  .sidebar { background: var(--bg); }
  .nav-item, .set-nav-item { height: 40px; font-size: 14px; }
  .btn { height: 36px; }
  .btn.sm { height: 32px; }
  .field, .select-btn { height: 40px; font-size: 16px; }
  .starter-tools .icon-btn, .starter-tools .send, .starter-tools .chip-pick { height: 40px; }
  .starter-tools .icon-btn, .starter-tools .send { width: 40px; }
  .settings-nav { width: 100%; padding: 0 8px; }
  .set-search { display: none; }
  .settings-body { margin: 0; padding: 20px 14px 48px; border-radius: 0; border: 0; box-shadow: none; }
  .side-foot { height: 60px; }
  .profile { height: 48px; }
}

/* ---- Messages: what you said sits on a quiet raised tile; what the agent said is plain text on the panel. ---- */
.msg.assistant, .msg.user, .msg.error { border-radius: 10px; }
.msg.user { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 .5px var(--border-2); }
html[data-theme="light"] .msg.user { background: #efeeeb; }
.msg.assistant { background: transparent; padding-left: 2px; padding-right: 2px; }
.msg.assistant, .msg.user { font-size: 14px; line-height: 21px; }
