/* BUDDY EMPIRE — the cloud edition of the approved BUDDY desktop interface.
   Navy canvas, metallic gold, one universal composer, no mode switches. */

:root {
  --b-gold: #e7c879;
  --b-gold-soft: #f2d68e;
  --b-gold-deep: #c0903b;
  --b-canvas: #0a1020;
  --b-canvas-2: #0c1426;
  --b-surface: #101a2d;
  --b-surface-2: #16233a;
  --b-surface-3: #1b2942;
  --b-line: rgba(231, 200, 121, 0.16);
  --b-line-soft: rgba(231, 200, 121, 0.09);
  --b-text: #e9eef7;
  --b-text-soft: #c9d4e5;
  --b-muted: #93a1bb;
  --b-hover: rgba(231, 200, 121, 0.07);
  --b-code: #0b1424;
  --b-danger: #ff8f7a;
  --b-ok: #7fd6a6;
  --b-radius: 16px;
  --b-radius-sm: 11px;
  --b-shadow: 0 18px 48px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  --b-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --b-sans: "Segoe UI", "Inter", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --b-mono: "SFMono-Regular", "Cascadia Code", Consolas, "Liberation Mono", monospace;
  --b-sidebar: 264px;
  --b-titlebar: 42px;
  --b-statusbar: 26px;
  --b-title-bg: #070d19;
  --b-side-bg: #08111f;
  --b-status-bg: #060b15;
}

html[data-theme="light"] {
  --b-canvas: #faf6ec;
  --b-canvas-2: #f6f0e2;
  --b-surface: #fffdf7;
  --b-surface-2: #f3ecdd;
  --b-surface-3: #ece3d2;
  --b-line: rgba(23, 32, 47, 0.12);
  --b-line-soft: rgba(23, 32, 47, 0.07);
  --b-text: #17202f;
  --b-text-soft: #2b3648;
  --b-muted: #6b7484;
  --b-hover: rgba(192, 144, 59, 0.10);
  --b-code: #f4eddd;
  --b-shadow: 0 18px 40px rgba(60, 45, 20, 0.14), 0 1px 0 rgba(255, 255, 255, 0.6) inset;
  --b-title-bg: #f2ead9;
  --b-side-bg: #fbf6e9;
  --b-status-bg: #f0e7d4;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--b-canvas);
  color: var(--b-text);
  font-family: var(--b-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

button, input, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: var(--b-gold); }
::selection { background: rgba(231, 200, 121, 0.28); }

svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- shared wordmark ---------- */
.word-buddy {
  display: inline-block;
  font-family: var(--b-sans);
  font-weight: 800;
  letter-spacing: 0.035em;
  line-height: 0.9;
  text-transform: uppercase;
  background: linear-gradient(180deg, #fff1c9 0%, #f0d18c 30%, #d7a94f 62%, #b87b22 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 8px 22px rgba(231, 200, 121, 0.15));
}

.edition-tag {
  font-size: 8.5px;
  font-weight: 650;
  letter-spacing: 0.28em;
  color: var(--b-gold-deep);
  text-transform: uppercase;
  border: 1px solid var(--b-line);
  border-radius: 99px;
  padding: 4px 9px 3px;
  white-space: nowrap;
}

/* ---------- boot ---------- */
.boot {
  position: fixed; inset: 0; display: grid; place-content: center; gap: 18px;
  justify-items: center; background: var(--b-canvas); z-index: 60;
}
.boot-mark {
  width: 86px; height: 86px;
  filter: drop-shadow(0 10px 30px rgba(231, 200, 121, .28));
  animation: float 3s ease-in-out infinite;
}
.boot p { color: var(--b-muted); letter-spacing: .18em; text-transform: uppercase; font-size: 10.5px; }
@keyframes float { 50% { transform: translateY(-7px); } }

/* ---------- sign in ---------- */
.gate {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(900px 560px at 78% 16%, rgba(231, 200, 121, 0.12), transparent 62%),
    linear-gradient(180deg, #060b15, var(--b-canvas));
  overflow: auto; z-index: 40;
}
.gate-eclipse {
  position: fixed; width: 780px; height: 780px; right: -330px; top: -180px;
  border-radius: 50%; pointer-events: none; opacity: .5;
  background: conic-gradient(from 210deg, #714510, #f8e7b3, #bd8022, #f8e7b3, #714510);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 13px), #000 calc(100% - 12px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 13px), #000 calc(100% - 12px));
  filter: drop-shadow(0 0 28px rgba(231, 200, 121, .25));
}
.gate-card {
  position: relative;
  width: min(430px, 100%);
  background: linear-gradient(180deg, rgba(17, 27, 45, .98), rgba(10, 17, 31, .98));
  border: 1px solid var(--b-line);
  border-radius: 18px;
  box-shadow: var(--b-shadow);
  padding: 36px 34px 26px;
  text-align: center;
  animation: rise .5s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.gate-mark { width: 78px; height: 78px; margin-bottom: 4px; filter: drop-shadow(0 12px 28px rgba(231,200,121,.18)); }
.gate-word { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin: 8px 0 7px; }
.gate-word .word-buddy { font-size: 43px; }
.gate-sub { color: var(--b-muted); margin: 0 0 24px; font-size: 13.5px; }
.field { display: block; text-align: left; margin-bottom: 14px; }
.field span {
  display: block; font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--b-muted); margin-bottom: 7px;
}
.field input {
  width: 100%; padding: 13px 15px; border-radius: 11px;
  background: var(--b-canvas-2); border: 1px solid var(--b-line);
  outline: none; transition: border-color .16s, box-shadow .16s;
}
.field input::placeholder { color: color-mix(in srgb, var(--b-muted) 72%, transparent); }
.field input:focus { border-color: var(--b-gold-deep); box-shadow: 0 0 0 3px rgba(231,200,121,.13); }
.btn-gold {
  width: 100%; margin-top: 8px; padding: 13px 18px; border: 0; border-radius: 11px;
  background: linear-gradient(180deg, #f7e4ae, #e7c879 55%, #c69a4c 100%);
  color: #241a05; font-weight: 650; letter-spacing: .02em; cursor: pointer;
  transition: transform .12s, filter .12s;
}
.btn-gold:hover { filter: brightness(1.05); }
.btn-gold:active { transform: translateY(1px); }
.btn-gold[disabled] { opacity: .6; cursor: progress; }
.gate-error { color: var(--b-danger); font-size: 13px; margin: 10px 0 0; }
.gate-foot { color: var(--b-muted); font-size: 11.5px; margin: 20px 0 0; line-height: 1.55; }

/* ---------- application frame ---------- */
.app {
  display: grid;
  grid-template-columns: var(--b-sidebar) minmax(0, 1fr);
  grid-template-rows: var(--b-titlebar) minmax(0, 1fr) var(--b-statusbar);
  height: 100vh; height: 100dvh;
  background: var(--b-canvas);
}
.app.collapsed { grid-template-columns: 0 minmax(0, 1fr); }
.app.collapsed .sidebar { transform: translateX(-100%); opacity: 0; pointer-events: none; }

/* ---------- title bar ---------- */
.titlebar {
  grid-column: 1 / -1; grid-row: 1;
  display: flex; align-items: center; gap: 10px;
  padding: 0 10px;
  background: linear-gradient(180deg, #08101d, var(--b-title-bg));
  border-bottom: 1px solid rgba(231, 200, 121, .13);
  z-index: 30;
}
.titlebar-brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.title-mark { width: 21px; height: 21px; filter: drop-shadow(0 3px 9px rgba(231,200,121,.18)); }
.title-word {
  font-size: 13.5px; font-weight: 800; letter-spacing: .15em; color: var(--b-gold);
  text-transform: uppercase; line-height: 1;
}
.title-edition {
  font-size: 7.5px; letter-spacing: .22em; color: var(--b-gold-deep);
  border: 1px solid var(--b-line); border-radius: 99px; padding: 2px 6px 1px;
}
.title-caption { font-size: 10.5px; color: var(--b-muted); letter-spacing: .02em; white-space: nowrap; }
.title-caption::before { content: "—"; margin-right: 7px; color: #5e6b80; }
.title-crumb {
  font-size: 10.5px; color: var(--b-text-soft); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 34vw; border-left: 1px solid var(--b-line-soft);
  padding-left: 9px; margin-left: 2px;
}
.title-crumb:empty { display: none; }
.titlebar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.title-status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px; color: var(--b-muted); border: 1px solid var(--b-line-soft);
  border-radius: 99px; padding: 3px 9px; max-width: 260px; min-width: 0;
}
.title-status span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-status .dot {
  width: 5px; height: 5px; border-radius: 50%; background: var(--b-ok);
  box-shadow: 0 0 7px rgba(127,214,166,.6); flex: none;
}
.title-btn {
  width: 30px; height: 30px; border: 1px solid transparent; border-radius: 7px;
  background: transparent; color: var(--b-muted); cursor: pointer;
  display: grid; place-items: center;
}
.title-btn svg { width: 15px; height: 15px; }
.title-btn:hover { background: var(--b-hover); color: var(--b-gold); border-color: var(--b-line-soft); }
.only-mobile { display: none; }

/* ---------- sidebar ---------- */
.sidebar {
  grid-column: 1; grid-row: 2;
  display: flex; flex-direction: column; gap: 7px;
  min-height: 0; padding: 11px 9px 8px;
  background: linear-gradient(180deg, var(--b-side-bg) 0%, #070e1a 100%);
  border-right: 1px solid var(--b-line-soft);
  transition: transform .22s ease, opacity .22s ease;
  z-index: 20;
}
html[data-theme="light"] .sidebar {
  background: linear-gradient(180deg, #fbf6e9 0%, #f6eddc 100%);
}
.new-chat {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border-radius: 9px; min-height: 37px;
  background: linear-gradient(180deg, rgba(231,200,121,.10), rgba(231,200,121,.035));
  border: 1px solid rgba(231, 200, 121, .31);
  color: var(--b-gold); cursor: pointer; font-weight: 550; font-size: 12.5px;
  transition: background .16s, border-color .16s, transform .12s;
}
.new-chat:hover { background: var(--b-hover); border-color: var(--b-gold-deep); }
.new-chat:active { transform: translateY(1px); }
.new-chat svg { width: 15px; height: 15px; flex: none; }
.new-chat .kbd { margin-left: auto; font-size: 7.5px; color: var(--b-muted); letter-spacing: .06em; }

.side-nav { display: grid; gap: 1px; padding: 4px 0 3px; border-bottom: 1px solid var(--b-line-soft); }
.nav-row {
  display: flex; align-items: center; gap: 9px; width: 100%;
  min-height: 31px; padding: 5px 8px; border: 0; border-radius: 7px;
  background: transparent; color: var(--b-text-soft); font-size: 12.3px;
  text-align: left; cursor: pointer;
}
.nav-row svg { width: 15px; height: 15px; color: var(--b-muted); flex: none; stroke-width: 1.55; }
.nav-row:hover { background: var(--b-hover); color: var(--b-text); }
.nav-row:hover svg { color: var(--b-gold); }
.nav-row.is-planned { color: var(--b-muted); cursor: default; }
.nav-row.is-planned:hover { background: transparent; color: var(--b-muted); }
.nav-key, .nav-soon { margin-left: auto; font-size: 7.5px; letter-spacing: .08em; color: #6f7d94; }
.nav-soon { border: 1px solid var(--b-line-soft); border-radius: 99px; padding: 0 5px; }

.search-panel { padding: 1px 3px 4px; }
.search-panel input {
  width: 100%; border: 1px solid var(--b-line); background: var(--b-canvas-2);
  border-radius: 7px; padding: 7px 9px; font-size: 11.5px; outline: none;
}
.search-panel input:focus { border-color: var(--b-gold-deep); box-shadow: 0 0 0 2px rgba(231,200,121,.08); }

.side-section { padding: 3px 0 2px; border-bottom: 1px solid var(--b-line-soft); }
.side-section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 8px; min-height: 23px;
  color: #7c8aa1; font-size: 8.5px; letter-spacing: .16em; text-transform: uppercase;
}
.side-plus {
  border: 0; background: transparent; color: #7c8aa1; cursor: default;
  font-size: 15px; line-height: 1; padding: 0 3px;
}
.side-ellipsis { color: #7c8aa1; letter-spacing: .1em; font-size: 12px; padding-right: 2px; }
.history { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.history-toggle {
  display: flex; align-items: center; gap: 4px;
  border: 0; background: none; cursor: pointer; padding: 0;
  color: inherit; font-size: inherit; letter-spacing: inherit; text-transform: inherit;
}
.history-toggle svg { width: 10px; height: 10px; transition: transform .18s; }
.history-toggle[aria-expanded="false"] svg { transform: rotate(-90deg); }
.history.collapsed .chat-list { display: none; }
.chat-list {
  flex: 1; overflow-y: auto; min-height: 0;
  padding: 0 1px 6px 0;
  scrollbar-width: thin; scrollbar-color: rgba(231,200,121,.16) transparent;
}
.chat-group { margin-top: 5px; }
.chat-group-label {
  padding: 4px 8px 2px; font-size: 7.5px; letter-spacing: .15em;
  text-transform: uppercase; color: #65738a;
}
.chat-row {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 8px; border-radius: 6px; cursor: pointer; border: 0;
  background: transparent; color: var(--b-text-soft);
  font-size: 12px; text-align: left; width: 100%; min-height: 29px;
  transition: background .14s, color .14s;
}
.chat-row:hover { background: var(--b-hover); color: var(--b-text); }
.chat-row.current { background: rgba(231, 200, 121, 0.09); color: var(--b-text); box-shadow: inset 2px 0 0 var(--b-gold); }
.chat-row span.title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.chat-row .when { font-size: 7.5px; color: #6d7a90; flex: none; }
.chat-row .del {
  opacity: 0; border: 0; background: none; color: var(--b-muted);
  cursor: pointer; padding: 0 2px; font-size: 13px; line-height: 1;
  transition: color .14s, opacity .14s;
}
.chat-row:hover .del, .chat-row.current .del { opacity: 1; }
.chat-row .del:hover { color: var(--b-danger); }
.chat-list .empty { color: var(--b-muted); font-size: 11.5px; padding: 7px 8px; line-height: 1.5; }

.side-bottom { margin-top: auto; display: grid; gap: 7px; padding-top: 6px; }
.appearance { display: grid; gap: 4px; padding: 0 4px; }
.appearance-label { font-size: 9px; color: #75839a; letter-spacing: .08em; }
.appearance-seg {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px;
  padding: 2px; background: #050b15; border: 1px solid var(--b-line-soft); border-radius: 7px;
}
html[data-theme="light"] .appearance-seg { background: #ede3d0; }
.appearance-seg button {
  border: 0; border-radius: 5px; background: transparent; color: var(--b-muted);
  font-size: 9.5px; padding: 3px 5px; cursor: pointer;
}
.appearance-seg button:hover { color: var(--b-text); }
.appearance-seg button[aria-pressed="true"] { background: #1b2536; color: var(--b-gold); }
html[data-theme="light"] .appearance-seg button[aria-pressed="true"] { background: #fffaf0; color: #805a16; }

.system-card {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 8px; border: 1px solid rgba(231,200,121,.10); border-radius: 9px;
  background: #0b1422; text-align: left; cursor: pointer;
}
html[data-theme="light"] .system-card { background: #fffaf0; }
.system-card:hover { border-color: var(--b-line); }
.shield {
  width: 25px; height: 25px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid rgba(231,200,121,.25); color: var(--b-gold); flex: none;
}
.shield svg { width: 13px; height: 13px; }
.system-copy { display: grid; gap: 0; min-width: 0; flex: 1; }
.system-copy strong { font-size: 9.5px; font-weight: 550; color: var(--b-text-soft); }
.system-copy small { font-size: 7.5px; color: #6c7a90; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.off {
  font-size: 7.5px; font-weight: 700; letter-spacing: .08em; color: #07101c;
  background: #c6d0dc; border-radius: 99px; padding: 2px 6px; flex: none;
}

.profile {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 3px 2px; border-top: 1px solid var(--b-line-soft); min-width: 0;
}
.avatar {
  width: 27px; height: 27px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #f2d68e, #c0903b);
  color: #241a05; font-weight: 700; font-size: 11px; flex: none;
}
.profile-copy { display: grid; min-width: 0; flex: 1; line-height: 1.25; }
.profile-copy strong { font-size: 10.5px; font-weight: 550; color: var(--b-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-copy span { font-size: 8px; color: #728097; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-btn {
  border: 0; background: none; color: var(--b-muted); cursor: pointer;
  width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; flex: none;
}
.profile-btn svg { width: 13px; height: 13px; }
.profile-btn:hover { color: var(--b-gold); background: var(--b-hover); }

/* ---------- main ---------- */
.main {
  grid-column: 2; grid-row: 2;
  position: relative; display: flex; flex-direction: column;
  min-width: 0; min-height: 0; overflow: hidden;
  background:
    radial-gradient(900px 520px at 84% 12%, rgba(231, 200, 121, 0.075), transparent 66%),
    radial-gradient(720px 480px at 18% 108%, rgba(38, 62, 101, 0.16), transparent 68%),
    linear-gradient(180deg, #091120 0%, var(--b-canvas) 46%, #080f1c 100%);
}
html[data-theme="light"] .main {
  background:
    radial-gradient(780px 480px at 84% 8%, rgba(231, 200, 121, 0.17), transparent 66%),
    linear-gradient(180deg, #fcf8ef 0%, var(--b-canvas) 55%, #f5eddd 100%);
}

.eclipse {
  position: absolute; z-index: 0; pointer-events: none;
  width: 1000px; height: 1000px; right: -783px; top: -105px;
  opacity: .64;
}
.eclipse::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 208deg, #66400e 0%, #f9e9b7 13%, #d5a142 27%, #8c5b13 42%, #f3d792 58%, #b97c20 72%, #f9e9b7 86%, #66400e 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 15px), #000 calc(100% - 14px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 15px), #000 calc(100% - 14px));
  filter: drop-shadow(0 0 18px rgba(231, 200, 121, .18));
}
.eclipse::after {
  content: ""; position: absolute; inset: 2.3%; border-radius: 50%;
  border: 1px solid rgba(231, 200, 121, .08);
  box-shadow: 0 0 90px rgba(231, 200, 121, .035) inset;
}
.eclipse-inner { display: none; }

.scroller {
  position: relative; z-index: 2; flex: 1; overflow-y: auto;
  padding: 0 34px 26px;
  scrollbar-width: thin; scrollbar-color: rgba(231,200,121,.16) transparent;
}

/* ---------- welcome ---------- */
.hero {
  width: clamp(860px, 62vw, 1080px); max-width: 100%; margin: 0 auto;
  padding: clamp(62px, 13vh, 126px) 0 20px;
  display: flex; flex-direction: column; align-items: center;
  animation: rise .45s ease both;
}
.hero-lockup { display: flex; align-items: center; justify-content: center; gap: 22px; }
.hero-mark {
  width: clamp(62px, 6.4vw, 96px); height: clamp(62px, 6.4vw, 96px);
  filter: drop-shadow(0 16px 38px rgba(231, 200, 121, 0.30));
  flex: none;
}
.hero-word { display: flex; align-items: flex-end; gap: 16px; margin: 0; line-height: 1; }
.hero-word .word-buddy { font-size: clamp(54px, 5.7vw, 104px); }
.hero-edition { margin-bottom: 10px; }
.composer-slot { width: 100%; display: flex; justify-content: center; margin-top: clamp(28px, 4.4vh, 46px); }
.suggested-head {
  display: flex; align-items: center; gap: 6px; width: 100%;
  margin: 24px 0 9px; padding-left: 1px;
  color: #8390a5; font-size: 11px; letter-spacing: .02em;
}
.suggested-head svg { width: 13px; height: 13px; color: var(--b-gold-deep); }
.suggestions {
  width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.suggestion {
  text-align: left; min-height: 73px; padding: 13px 16px 12px;
  border-radius: 10px; cursor: pointer;
  background: linear-gradient(180deg, #101c2f, #0c1728);
  border: 1px solid rgba(231, 200, 121, .10); color: var(--b-text);
  display: flex; flex-direction: column; gap: 3px; justify-content: center;
  transition: border-color .16s, transform .16s, background .16s, box-shadow .16s;
}
html[data-theme="light"] .suggestion { background: #fffdf7; }
.suggestion:hover {
  border-color: rgba(231, 200, 121, .38);
  background: rgba(231, 200, 121, .055);
  transform: translateY(-1px);
  box-shadow: 0 9px 24px rgba(0,0,0,.18);
}
.suggestion strong { font-size: 12.5px; font-weight: 600; line-height: 1.35; }
.suggestion span { font-size: 10.5px; color: #8e9bb0; line-height: 1.4; }

/* ---------- composer ---------- */
.composer {
  width: clamp(700px, 43vw, 820px); max-width: 100%; margin: 0 auto;
  border: 1px solid rgba(231, 200, 121, .19);
  border-radius: 14px;
  background: linear-gradient(180deg, #111c2e 0%, #0d1728 100%);
  box-shadow: 0 17px 44px rgba(0, 0, 0, .32), 0 1px 0 rgba(255,255,255,.025) inset;
  padding: 0;
  display: grid;
  transition: border-color .16s, box-shadow .16s;
}
html[data-theme="light"] .composer { background: #fffdf7; }
.composer:focus-within {
  border-color: rgba(231, 200, 121, .45);
  box-shadow: 0 0 0 3px rgba(231,200,121,.055), 0 17px 44px rgba(0, 0, 0, .32);
}
.composer-input-row { padding: 14px 17px 1px; }
#input {
  width: 100%; resize: none; border: 0; outline: none; background: transparent;
  min-height: 42px; max-height: 200px; padding: 4px 1px 5px;
  font-size: 14px; line-height: 1.55; color: var(--b-text);
}
#input::placeholder { color: #8e9bb0; }
.composer-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 9px 8px 10px;
}
.composer-tools, .composer-actions { display: flex; align-items: center; gap: 1px; }
.composer-actions { margin-left: auto; gap: 5px; }
.tool-btn {
  width: 29px; height: 29px; border: 1px solid transparent; border-radius: 50%;
  background: transparent; color: #8997ad; cursor: pointer;
  display: grid; place-items: center; flex: none; padding: 0;
  transition: background .14s, color .14s, border-color .14s;
}
.tool-btn svg { width: 15px; height: 15px; stroke-width: 1.65; }
.tool-btn:hover { background: rgba(231,200,121,.075); color: var(--b-gold); }
.tool-btn.tool-state { cursor: help; }
.tool-btn.tool-state:hover { background: transparent; color: var(--b-gold); }
.tool-btn:disabled { opacity: .34; cursor: not-allowed; }
.tool-btn:disabled:hover { background: transparent; color: #8997ad; }
.tool-btn.is-planned { color: #6f7d91; }
.model-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 4px 2px 6px; font-size: 11.5px; color: var(--b-text-soft);
  white-space: nowrap;
}
.model-badge svg { width: 11px; height: 11px; color: var(--b-muted); }
.stop {
  border: 1px solid var(--b-line); background: rgba(231,200,121,.07);
  color: var(--b-text-soft); border-radius: 7px; padding: 4px 9px;
  cursor: pointer; font-size: 10px;
}
.stop:hover { border-color: var(--b-danger); color: var(--b-danger); }
.send {
  width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(180deg, #f7e4ae, #e7c879 55%, #c69a4c 100%);
  display: grid; place-items: center; transition: transform .12s, filter .12s, opacity .12s;
  flex: none; margin-left: 1px;
}
.send svg { width: 17px; height: 17px; stroke: #241a05; stroke-width: 2; }
.send:hover { filter: brightness(1.06); }
.send:active { transform: scale(.96); }
.send[disabled] { opacity: .42; cursor: not-allowed; }
.attachment-tray { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px 0; }
.attachment {
  position: relative; display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--b-line-soft); border-radius: 9px;
  background: var(--b-canvas-2); padding: 5px 28px 5px 6px; max-width: 230px;
}
.attachment img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; display: block; }
.attachment .doc {
  width: 36px; height: 36px; border-radius: 6px; display: grid; place-items: center;
  background: rgba(231,200,121,.1); color: var(--b-gold); flex: none;
}
.attachment .doc svg { width: 16px; height: 16px; }
.attachment .name { font-size: 10.5px; color: var(--b-text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment .kind { font-size: 9px; color: var(--b-muted); }
.attachment .remove {
  position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; border-radius: 50%;
  border: 0; background: rgba(10,16,32,.75); color: var(--b-muted);
  cursor: pointer; font-size: 11px; line-height: 1; display: grid; place-items: center;
}
.attachment .remove:hover { color: var(--b-danger); }
.attachment.uploading { opacity: .65; }

.composer-dock {
  position: relative; z-index: 4;
  padding: 8px 28px 10px;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--b-canvas) 95%, transparent) 38%);
}
.disclaimer {
  max-width: 820px; margin: 6px auto 0; text-align: center;
  font-size: 9.5px; color: var(--b-muted);
}

/* ---------- conversation ---------- */
.thread {
  width: min(850px, 100%); margin: 0 auto;
  display: flex; flex-direction: column; gap: 24px;
  padding: 34px 0 18px;
}
.thread:empty { display: none; }

.turn { animation: turnIn .28s ease both; }
@keyframes turnIn { from { opacity: 0; transform: translateY(6px); } }
.turn.user { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; }
.bubble-user {
  max-width: min(640px, 92%); padding: 11px 15px; border-radius: 13px 13px 5px 13px;
  background: linear-gradient(180deg, #17253b, #111c2f);
  border: 1px solid rgba(231, 200, 121, .11);
  font-size: 14px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
  box-shadow: 0 8px 22px rgba(0,0,0,.16);
}
html[data-theme="light"] .bubble-user { background: #f1e8d8; box-shadow: 0 8px 22px rgba(60,45,20,.10); }
.user-attachments { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; max-width: min(640px, 92%); }
.user-image {
  display: block; width: 154px; height: 116px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--b-line); background: var(--b-canvas-2);
}
.user-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-chip {
  display: inline-flex; align-items: center; gap: 7px; max-width: 260px;
  padding: 7px 11px; border-radius: 9px; border: 1px solid var(--b-line-soft);
  background: var(--b-surface); color: var(--b-text-soft); font-size: 11px;
}
.file-chip svg { width: 14px; height: 14px; color: var(--b-gold); flex: none; }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.turn.assistant { display: grid; gap: 11px; }
.answer-head {
  display: flex; align-items: center; gap: 9px;
  font-size: 9px; letter-spacing: .15em; text-transform: uppercase; color: var(--b-muted);
}
.answer-head img { width: 21px; height: 21px; }
.answer-head .who { color: var(--b-gold); letter-spacing: .15em; font-weight: 650; }
.answer-head .tag {
  font-size: 8px; letter-spacing: .11em; color: var(--b-muted);
  border: 1px solid var(--b-line-soft); border-radius: 99px; padding: 1px 7px;
  text-transform: uppercase;
}
.answer-head .meta-model {
  margin-left: auto; font-size: 9.5px; letter-spacing: .03em; color: var(--b-muted);
  text-transform: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 42%;
}
.body { font-size: 14.7px; line-height: 1.73; color: var(--b-text); overflow-wrap: anywhere; }
.body p { margin: 0 0 12px; }
.body p:last-child { margin-bottom: 0; }
.body h3 { font-size: 15px; margin: 18px 0 7px; color: var(--b-text); }
.body ul, .body ol { margin: 0 0 12px; padding-left: 23px; }
.body li { margin-bottom: 5px; }
.body li::marker { color: var(--b-gold-deep); }
.body strong { color: var(--b-text); font-weight: 650; }
.body em { color: var(--b-text-soft); }
.body code {
  background: var(--b-code); border: 1px solid var(--b-line-soft);
  padding: 1.5px 5px; border-radius: 5px; font-family: var(--b-mono); font-size: 12.3px;
}
.body pre {
  background: var(--b-code); border: 1px solid var(--b-line-soft); border-radius: 10px;
  padding: 13px 15px; overflow-x: auto; margin: 0 0 12px; line-height: 1.55;
}
.body pre code { background: none; border: 0; padding: 0; font-size: 12.2px; }
.body a { text-decoration: none; border-bottom: 1px solid rgba(231, 200, 121, .35); }
.body a:hover { border-bottom-color: var(--b-gold); }
.cite {
  display: inline-block; min-width: 17px; padding: 0 4px; margin: 0 1.5px;
  font-size: 10px; line-height: 17px; text-align: center; vertical-align: 2px;
  border-radius: 5px; background: rgba(231, 200, 121, .16); color: var(--b-gold);
  text-decoration: none; border: 0; cursor: pointer; font-family: var(--b-sans);
}
.cite:hover { background: rgba(231, 200, 121, .3); }
.cite.bad { background: rgba(255, 143, 122, .18); color: var(--b-danger); }
.caret {
  display: inline-block; width: 6px; height: 14px; vertical-align: -3px; margin-left: 3px;
  background: var(--b-gold); animation: blink 1s steps(2) infinite; border-radius: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

.status { display: inline-flex; align-items: center; gap: 9px; font-size: 12px; color: var(--b-muted); padding: 2px 0; }
.status .spin {
  width: 12px; height: 12px; border-radius: 50%;
  border: 1.5px solid rgba(231,200,121,.20); border-top-color: var(--b-gold);
  animation: spin .8s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.status.done { display: none; }

.sources {
  border: 1px solid var(--b-line-soft); border-radius: 11px;
  background: rgba(16, 26, 45, .55); overflow: hidden; margin-top: 2px;
}
html[data-theme="light"] .sources { background: rgba(255, 253, 247, .66); }
.sources summary {
  cursor: pointer; padding: 9px 13px; font-size: 9.5px;
  letter-spacing: .12em; text-transform: uppercase; color: var(--b-text-soft);
  display: flex; align-items: center; gap: 8px; list-style: none;
}
.sources summary::-webkit-details-marker { display: none; }
.sources summary::before { content: "▸"; color: var(--b-gold); font-size: 9px; transition: transform .16s; }
.sources[open] summary::before { transform: rotate(90deg); }
.sources .count { margin-left: auto; color: var(--b-muted); letter-spacing: .04em; text-transform: none; }
.source-list { margin: 0; padding: 2px 13px 12px; list-style: none; display: grid; gap: 9px; }
.source { display: grid; grid-template-columns: 23px minmax(0,1fr); gap: 8px; font-size: 12px; line-height: 1.45; }
.source .n { color: var(--b-gold); font-variant-numeric: tabular-nums; padding-top: 1px; }
.source a { color: var(--b-text); text-decoration: none; border-bottom: 1px solid transparent; }
.source a:hover { color: var(--b-gold); border-bottom-color: rgba(231,200,121,.4); }
.source .dom { color: var(--b-muted); font-size: 10.5px; margin-top: 1px; }
.source .snip {
  color: var(--b-muted); font-size: 10.8px; margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.badge {
  font-size: 8.5px; text-transform: uppercase; letter-spacing: .1em;
  padding: 1px 6px; border-radius: 99px; border: 1px solid var(--b-line);
  color: var(--b-muted); vertical-align: 1px;
}
.badge.primary, .badge.conf-high { color: var(--b-ok); border-color: rgba(127,214,166,.35); }
.badge.conf-medium { color: var(--b-gold); border-color: rgba(231,200,121,.35); }
.badge.conf-low, .badge.conf-none { color: var(--b-danger); border-color: rgba(255,143,122,.3); }

.image-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.image-card {
  margin: 0; width: min(390px, 100%); border-radius: 12px; overflow: hidden;
  border: 1px solid var(--b-line); background: var(--b-surface);
  box-shadow: 0 14px 36px rgba(0,0,0,.28);
}
.image-card a { display: block; background: var(--b-canvas-2); overflow: hidden; }
.image-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-foot {
  display: flex; align-items: center; gap: 8px; padding: 8px 11px;
  font-size: 9.5px; color: var(--b-muted); border-top: 1px solid var(--b-line-soft);
}
.image-foot .prompt { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-foot .demo-badge {
  color: var(--b-gold); border: 1px solid var(--b-line); border-radius: 99px;
  padding: 1px 7px; letter-spacing: .09em; text-transform: uppercase; font-size: 8px; flex: none;
}
.image-foot .open { color: var(--b-text-soft); text-decoration: none; flex: none; }
.image-foot .open:hover { color: var(--b-gold); }

.error-card {
  border: 1px solid rgba(255, 143, 122, .35); background: rgba(255, 143, 122, .07);
  border-radius: 10px; padding: 12px 14px; display: grid; gap: 8px; font-size: 13px;
}
.error-card strong { color: var(--b-danger); font-weight: 600; font-size: 11px; letter-spacing: .07em; }
.error-card .retry {
  justify-self: start; border: 1px solid var(--b-line); background: var(--b-surface-2);
  color: var(--b-gold); padding: 5px 12px; border-radius: 7px; cursor: pointer; font-size: 11.5px;
}
.error-card .retry:hover { background: var(--b-hover); }
.meta-line {
  font-size: 9.5px; color: var(--b-muted); letter-spacing: .04em;
  display: flex; gap: 11px; flex-wrap: wrap; align-items: center;
}
.meta-line .ok { color: var(--b-ok); }
.meta-line .warn { color: var(--b-gold); }

/* ---------- status bar ---------- */
.statusbar {
  grid-column: 1 / -1; grid-row: 3;
  display: flex; align-items: center; gap: 9px;
  padding: 0 12px;
  background: var(--b-status-bg);
  border-top: 1px solid rgba(231, 200, 121, .10);
  color: #77859a; font-size: 9px; letter-spacing: .015em;
  z-index: 25;
}
.status-left, .status-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.status-right { margin-left: auto; }
.status-item { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.status-camera {
  width: 7px; height: 7px; border-radius: 50%; border: 1px solid #8390a4; background: transparent;
}
.status-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--b-ok);
  box-shadow: 0 0 6px rgba(127,214,166,.6);
}
.status-link {
  border: 0; background: transparent; color: #94a2b6; font-size: 9px;
  cursor: default; padding: 0; text-decoration: underline; text-underline-offset: 2px;
}
.status-sep { color: #435069; }
.status-muted { color: #657389; white-space: nowrap; }
.status-right b { color: #bcc7d5; font-weight: 600; letter-spacing: .04em; }

/* ---------- memory modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px;
  background: rgba(4, 8, 16, .62); backdrop-filter: blur(5px);
}
.modal-card {
  width: min(520px, 100%); max-height: min(76vh, 640px); overflow: auto;
  background: var(--b-surface); border: 1px solid var(--b-line);
  border-radius: 15px; box-shadow: var(--b-shadow); padding: 21px 21px 17px;
  animation: rise .24s ease both;
}
.modal-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.modal-head h2 {
  font-family: var(--b-sans); font-weight: 650; color: var(--b-gold);
  margin: 0; font-size: 18px; letter-spacing: .04em;
}
.modal-head p { margin: 3px 0 0; font-size: 11px; color: var(--b-muted); }
.modal-head .icon-btn { margin-left: auto; flex: none; }
.icon-btn {
  border: 1px solid transparent; background: transparent; color: var(--b-muted);
  width: 30px; height: 30px; border-radius: 7px; cursor: pointer;
  display: grid; place-items: center; font-size: 17px;
}
.icon-btn:hover { background: var(--b-hover); color: var(--b-gold); }
.memory-list { display: grid; gap: 8px; }
.memory-row {
  display: flex; align-items: flex-start; gap: 10px; padding: 9px 11px;
  border: 1px solid var(--b-line-soft); border-radius: 8px; background: var(--b-canvas-2);
  font-size: 12.5px; line-height: 1.5;
}
.memory-row span { flex: 1; overflow-wrap: anywhere; }
.memory-row button {
  border: 0; background: none; color: var(--b-muted); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 1px 3px;
}
.memory-row button:hover { color: var(--b-danger); }
.memory-empty { color: var(--b-muted); font-size: 12.5px; padding: 13px 4px; line-height: 1.6; }
.modal-foot { color: var(--b-muted); font-size: 10.5px; margin: 15px 0 0; line-height: 1.55; }

.toast {
  position: fixed; left: 50%; bottom: 38px; transform: translateX(-50%);
  background: #16233a; border: 1px solid var(--b-line); color: var(--b-text);
  padding: 8px 15px; border-radius: 8px; font-size: 12px;
  box-shadow: var(--b-shadow); z-index: 70; max-width: 88vw; text-align: center;
}
html[data-theme="light"] .toast { background: #fffdf7; }

.scrim { position: fixed; inset: 0; background: rgba(4,8,16,.58); z-index: 15; }

/* ---------- light refinements ---------- */
html[data-theme="light"] .titlebar { background: linear-gradient(180deg, #f6efdf, #f2ead9); border-bottom-color: rgba(23,32,47,.10); }
html[data-theme="light"] .title-word { color: #9a6f1d; }
html[data-theme="light"] .title-edition { color: #9a6f1d; border-color: rgba(23,32,47,.12); }
html[data-theme="light"] .new-chat { color: #7c5714; background: #fffaf0; }
html[data-theme="light"] .new-chat:hover { background: #fdf3e0; }
html[data-theme="light"] .nav-row svg { color: #7c8798; }
html[data-theme="light"] .chat-row.current { background: rgba(192,144,59,.12); }
html[data-theme="light"] .cite { color: #7c5714; }
html[data-theme="light"] .statusbar { background: #f0e7d4; color: #6b7484; }
html[data-theme="light"] .status-right b { color: #38465a; }
html[data-theme="light"] .suggestion:hover { background: rgba(192,144,59,.09); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .suggestions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { padding-top: clamp(36px, 7vh, 74px); }
}

@media (max-width: 900px) {
  :root { --b-titlebar: 47px; }
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--b-titlebar) minmax(0, 1fr); }
  .titlebar { grid-column: 1; }
  .main { grid-column: 1; grid-row: 2; }
  .sidebar {
    position: fixed; inset: var(--b-titlebar) auto 0 0;
    width: min(300px, 87vw); z-index: 20;
    box-shadow: 0 0 70px rgba(0,0,0,.58);
    transform: translateX(-100%); opacity: 0; pointer-events: none;
  }
  .app.mobile-open .sidebar { transform: translateX(0); opacity: 1; pointer-events: auto; }
  .app.collapsed .sidebar { transform: translateX(-100%); opacity: 0; pointer-events: none; }
  .only-mobile { display: grid; }
  #collapse { display: none; }
  .titlebar { gap: 7px; padding: 0 8px; }
  .title-caption { display: none; }
  .title-crumb { max-width: 42vw; }
  .title-mark { width: 19px; height: 19px; }
  .title-word { font-size: 12px; }
  .title-edition { font-size: 6.5px; }
  .title-status { max-width: 150px; font-size: 9.5px; }
  .statusbar { display: none; }
  .scroller { padding: 0 18px 20px; }
  .hero { padding-top: clamp(26px, 5vh, 46px); }
  .hero-lockup { gap: 16px; }
  .hero-word .word-buddy { font-size: clamp(50px, 9vw, 72px); }
  .hero-mark { width: 68px; height: 68px; }
  .composer-slot { margin-top: 30px; }
  .composer { border-radius: 13px; }
  .suggestions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .suggestion { min-height: 64px; padding: 11px 13px; }
  .suggestion strong { font-size: 11.8px; }
  .suggestion span { font-size: 10px; }
  .composer-dock { padding: 7px 12px 9px; }
  .disclaimer { display: none; }
  .thread { padding-top: 24px; gap: 22px; }
  .bubble-user { max-width: 100%; }
  .user-attachments { max-width: 100%; }
  .image-card { width: 100%; }
  .answer-head .meta-model { display: none; }
  .eclipse { width: 460px; height: 460px; right: -330px; top: 95px; opacity: .38; }
  .eclipse::before { -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 10px), #000 calc(100% - 9px)); mask: radial-gradient(farthest-side, transparent calc(100% - 10px), #000 calc(100% - 9px)); }
}

@media (max-width: 620px) {
  .title-status { display: none; }
  .title-caption { display: none; }
  .title-crumb { max-width: 36vw; }
  .scroller { padding: 0 13px 16px; }
  .hero { padding-top: 24px; }
  .hero-lockup { gap: 13px; }
  .hero-mark { width: 55px; height: 55px; }
  .hero-word { gap: 10px; }
  .hero-word .word-buddy { font-size: clamp(44px, 13vw, 58px); }
  .hero-edition { margin-bottom: 6px; padding: 3px 6px 2px; font-size: 7px; letter-spacing: .2em; }
  .composer-slot { margin-top: 25px; }
  .suggestions { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .suggestion { min-height: 57px; padding: 10px 13px; }
  .suggested-head { margin-top: 19px; }
  .composer-input-row { padding: 11px 13px 0; }
  #input { font-size: 14px; min-height: 38px; }
  .composer-bar { padding: 5px 7px 7px 8px; gap: 4px; }
  .composer-tools { gap: 0; }
  .tool-btn { width: 27px; height: 27px; }
  .tool-btn.tool-state { display: none; }
  .model-badge { font-size: 10.5px; padding-left: 3px; }
  .send { width: 32px; height: 32px; }
  .composer-dock { padding: 6px 9px 8px; }
  .thread { padding-top: 20px; }
  .body { font-size: 14.4px; }
  .source .snip { display: none; }
  .answer-head .tag { display: none; }
  .modal-card { padding: 17px 15px 14px; }
  .eclipse { width: 360px; height: 360px; right: -270px; top: 150px; opacity: .30; }
}

@media (max-width: 390px) {
  .hero-mark { width: 48px; height: 48px; }
  .hero-word .word-buddy { font-size: 46px; }
  .hero-edition { font-size: 6.5px; }
  .title-crumb { display: none; }
  .new-chat .kbd, .nav-key { display: none; }
  .eclipse { width: 300px; height: 300px; right: -240px; opacity: .28; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
