/* Layout: true-black canvas, one reading column, hairlines instead of cards. White is the only accent.
   The single flourish is a line of light along the composer while a reply is being made. */
@font-face { font-family: Geist; src: url("/vendor/geist.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("/vendor/geist-mono.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  color-scheme: dark;
  --black: #000;
  --raised: #0b0b0d;
  --fill: #17171a;
  --line: #222226;
  --line-strong: #38383e;
  --text: #ededef;
  --muted: #92929b;
  --white: #fff;
  --danger: #ff6b70;
  --danger-fill: #cf2f36;
  --body: Geist, "Segoe UI", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; background: var(--black); }
body { color: var(--text); font: 400 16px/1.65 var(--body); letter-spacing: -.006em; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; letter-spacing: inherit; color: inherit; }
button, select, summary { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .4; }
button, a, select, .composer-box { transition: background-color .15s, border-color .15s, color .15s, opacity .15s; }
:focus-visible { outline: 2px solid var(--white); outline-offset: 2px; }
::selection { background: #3a3a42; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; letter-spacing: -.022em; text-wrap: balance; }
svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.mark { stroke-width: 46; stroke-linecap: butt; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border: 1px solid var(--line-strong); border-radius: 10px; background: transparent; color: var(--text); font-size: 14px; font-weight: 500; text-decoration: none; }
.button.primary { border-color: var(--white); background: var(--white); color: var(--black); }
.button.primary.destructive { border-color: var(--danger-fill); background: var(--danger-fill); color: var(--white); }
.icon-button { display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 9px; background: none; color: var(--muted); }
.text-button { min-height: 40px; padding: 4px 10px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 13px; text-align: left; }
@media (hover: hover) {
  .button:not(.primary):hover, .icon-button:hover, .text-button:not(:disabled):hover, .chip:hover, #model:hover { background-color: var(--fill); color: var(--text); }
  .button.primary:hover, .send:hover { opacity: .88; }
  .text-button.danger:not(:disabled):hover { color: var(--danger); }
}

/* Sign-in */
.login { display: grid; grid-template-rows: 1fr auto; justify-items: center; padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); }
.login-panel { align-self: center; display: grid; gap: 12px; width: min(100%, 340px); text-align: center; }
.login-panel .mark { justify-self: center; width: 44px; height: 44px; margin-bottom: 16px; color: var(--white); }
.login-panel h1 { margin: 0; font-size: 28px; letter-spacing: -.035em; }
.login-panel p { margin: 0 0 16px; color: var(--muted); }
.login-panel .button { min-height: 48px; font-size: 15px; }
.login-panel .notice { padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); border-radius: 10px; color: var(--danger); font-size: 14px; line-height: 1.5; text-align: left; }
.login small { color: var(--muted); font-size: 13px; }

/* App layout */
.app { display: grid; grid-template-columns: 272px minmax(0, 1fr); height: 100dvh; overflow: hidden; }
.sidebar { display: flex; flex-direction: column; gap: 4px; min-height: 0; padding: max(14px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); background: var(--black); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; color: var(--white); font-size: 16px; font-weight: 600; letter-spacing: -.025em; }
.brand .mark { width: 22px; height: 22px; }
#new-chat { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 8px 10px; border: 0; border-radius: 9px; background: var(--fill); font-size: 14px; font-weight: 500; }
#search { width: 100%; min-height: 42px; padding: 8px 10px; border: 0; border-radius: 9px; background: none; font-size: 14px; }
#search::-webkit-search-cancel-button { filter: grayscale(1); }
#chat-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
#chat-list h2 { margin: 18px 10px 6px; color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: 0; }
#chat-list > p { margin: 18px 10px; color: var(--muted); font-size: 13px; }
.chat-item { display: flex; align-items: center; border-radius: 9px; }
.chat-item[data-active="true"] { background: var(--fill); }
.chat-item .open { flex: 1; min-width: 0; min-height: 38px; padding: 6px 10px; border: 0; border-radius: 9px; background: none; color: #c3c3ca; font-size: 14px; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item[data-active="true"] .open { color: var(--white); }
.chat-item .icon-button { width: 32px; height: 36px; }
.chat-item .icon-button svg { width: 15px; height: 15px; }
@media (hover: hover) {
  .chat-item:not(:hover, :focus-within) .icon-button { width: 0; opacity: 0; overflow: hidden; }
  .chat-item:hover:not([data-active="true"]) { background: var(--raised); }
}
.sidebar footer { display: flex; flex-wrap: wrap; justify-content: space-between; padding-top: 12px; border-top: 1px solid var(--line); }
.allowance { display: grid; grid-template-columns: 1fr auto; gap: 8px; width: 100%; padding: 2px 10px 6px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.allowance output { color: var(--text); }
progress { grid-column: 1 / -1; appearance: none; width: 100%; height: 2px; border: 0; background: var(--line); }
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--white); }
progress::-moz-progress-bar { background: var(--white); }

.app main { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; min-width: 0; min-height: 0; }
.app header { display: flex; align-items: center; gap: 4px; min-height: 56px; padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px 24px; }
#title { flex: 1; min-width: 0; margin: 0; overflow: hidden; color: var(--muted); font-size: 14px; font-weight: 500; letter-spacing: -.006em; text-overflow: ellipsis; white-space: nowrap; }
#menu, #new-chat-top, #scrim { display: none; }
#scroll { overflow-y: auto; overscroll-behavior: contain; }
#messages { display: flex; flex-direction: column; gap: 32px; width: 100%; max-width: 768px; min-height: 100%; margin: 0 auto; padding: 20px max(16px, env(safe-area-inset-right)) 40px max(16px, env(safe-area-inset-left)); }

/* Start screen */
.empty { margin: auto 0; text-align: center; }
.empty h2 { margin: 0; color: var(--white); font-size: clamp(28px, 4vw, 38px); font-weight: 500; letter-spacing: -.042em; }
#ideas { display: none; flex-wrap: wrap; justify-content: center; gap: 8px; width: 100%; max-width: 768px; margin: 0 auto; padding: 0 16px 12px; }
#ideas button { min-height: 40px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 20px; background: none; color: var(--muted); font-size: 14px; }
main:has(.empty) #ideas { display: flex; }
main:has(.empty) #title { visibility: hidden; }
@media (hover: hover) { #ideas button:hover { border-color: var(--line-strong); color: var(--text); } }
@media (min-width: 761px) {
  .app main:has(.empty) { grid-template-rows: auto minmax(0, 1fr) auto minmax(0, 1.15fr); }
  main:has(.empty) .empty { margin: auto 0 0; }
  main:has(.empty) #messages { padding-bottom: 28px; }
  main:has(.empty) #composer { order: 1; }
  main:has(.empty) #ideas { order: 2; align-content: flex-start; padding-top: 12px; }
  main:has(.empty) .hint { display: none; }
}

/* Messages */
.message { min-width: 0; overflow-wrap: anywhere; }
.message.user { align-self: flex-end; max-width: min(82%, 600px); padding: 10px 16px; border-radius: 20px; background: var(--fill); white-space: pre-wrap; }
.message.assistant { width: 100%; }
.thoughts { margin-bottom: 14px; color: var(--muted); font-size: 14px; }
.thoughts summary { width: fit-content; padding-block: 4px; }
.thoughts summary::marker { font-size: .8em; }
.thoughts div { max-height: 300px; margin-top: 6px; padding-left: 16px; overflow-y: auto; border-left: 1px solid var(--line-strong); white-space: pre-wrap; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown h1, .markdown h2, .markdown h3 { margin: 1.6em 0 .5em; color: var(--white); font-size: 1.125em; }
.markdown h1 { font-size: 1.375em; }
.markdown h2 { font-size: 1.25em; }
.markdown strong { color: var(--white); font-weight: 600; }
.markdown li + li { margin-top: 4px; }
.markdown li::marker { color: var(--muted); }
.markdown a { color: var(--white); text-decoration-color: var(--muted); text-underline-offset: 3px; }
.markdown blockquote { margin-inline: 0; padding-left: 16px; border-left: 1px solid var(--line-strong); color: var(--muted); }
.markdown :not(pre) > code { padding: 2px 6px; border-radius: 6px; background: var(--fill); font: .86em var(--mono); }
.markdown table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: 15px; }
.markdown th, .markdown td { padding: 9px 24px 9px 0; border-bottom: 1px solid var(--line); text-align: left; overflow-wrap: normal; }
.markdown th { border-color: var(--line-strong); color: var(--muted); font-weight: 500; }
.markdown hr { margin-block: 28px; border: 0; border-top: 1px solid var(--line); }
.code { margin-block: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--raised); }
.code-bar { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 0 16px; color: var(--muted); font: 12px var(--mono); }
.code pre { margin: 0; padding: 4px 16px 16px; overflow-x: auto; font: 13.5px/1.65 var(--mono); letter-spacing: 0; overflow-wrap: normal; }
.code code { font: inherit; }
.pictures { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 8px; max-width: 440px; margin-top: 14px; }
.pictures figure { position: relative; margin: 0; overflow: hidden; border-radius: 14px; background: var(--raised); box-shadow: 0 0 0 1px var(--line); }
.pictures img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; }
.pictures .save { position: absolute; right: 8px; bottom: 8px; background: rgb(0 0 0 / .72); color: var(--white); }
.message-error { margin: 12px 0 0; color: var(--danger); font-size: 15px; }
.message-tools { display: flex; align-items: center; margin: 8px 0 0 -11px; color: var(--muted); font-size: 12px; }
.message-tools svg { width: 16px; height: 16px; }
.message-tools span { padding-left: 8px; }
.message-tools span:first-child { padding-left: 11px; }

.working { width: fit-content; margin-top: 12px; font-size: 14px; color: transparent; background: linear-gradient(90deg, var(--muted) 35%, var(--white) 50%, var(--muted) 65%) 100% 0 / 300% 100%; background-clip: text; animation: shimmer 2s linear infinite; }
@keyframes shimmer { to { background-position: 0 0; } }

/* Composer */
#composer { width: 100%; max-width: 768px; margin: 0 auto; padding: 0 max(16px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.composer-box { position: relative; padding: 16px 10px 10px 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 22px; background: var(--raised); }
.composer-box:focus-within { border-color: var(--line-strong); }
.app:has(.working) .composer-box::before { content: ""; position: absolute; inset: 0 0 auto; height: 1px; background: linear-gradient(90deg, transparent, var(--white), transparent); animation: light 2.2s ease-in-out infinite; }
@keyframes light { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
#input { display: block; width: 100%; max-height: 34dvh; padding: 0; resize: none; border: 0; outline: 0; background: none; line-height: 1.5; }
::placeholder { color: var(--muted); opacity: 1; }
.composer-row { display: flex; align-items: center; gap: 4px; margin: 12px 0 0 -8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 6px 12px; border: 1px solid transparent; border-radius: 20px; background: none; color: var(--muted); font-size: 14px; }
.chip[aria-pressed="true"] { border-color: var(--white); color: var(--white); }
#model { appearance: none; min-width: 0; min-height: 40px; margin-left: auto; padding: 6px 28px 6px 10px; border: 0; border-radius: 9px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%2392929b' stroke-width='1.5'%3E%3Cpath d='M3 4.500l3 3 3-3'/%3E%3C/svg%3E") no-repeat right 9px center / 12px; color: var(--muted); font-size: 14px; text-overflow: ellipsis; }
#model option { background: var(--fill); color: var(--text); }
.send { display: grid; place-items: center; flex: none; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: var(--white); color: var(--black); }
.send svg { stroke-width: 2; }
.hint { margin: 8px 0 0; color: var(--muted); font-size: 12px; text-align: center; }

dialog { width: min(400px, calc(100% - 32px)); padding: 24px; border: 1px solid var(--line-strong); border-radius: 18px; background: var(--raised); color: var(--text); }
dialog::backdrop, #scrim { background: rgb(0 0 0 / .72); }
dialog h2 { margin: 0 0 8px; color: var(--white); font-size: 18px; }
dialog p { margin: 0; color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }
#dialog-input { width: 100%; min-height: 44px; margin-top: 8px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--black); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
#toast { position: fixed; z-index: 30; left: 50%; bottom: calc(160px + env(safe-area-inset-bottom)); width: max-content; max-width: calc(100% - 32px); padding: 10px 16px; transform: translateX(-50%); border: 1px solid var(--line-strong); border-radius: 12px; background: var(--fill); font-size: 14px; }

@media (max-width: 760px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; width: min(310px, 86vw); visibility: hidden; transform: translateX(-100%); transition: transform .22s ease, visibility .22s; }
  .sidebar.open { visibility: visible; transform: none; }
  .chat-item .open { min-height: 44px; font-size: 15px; }
  #search { font-size: 16px; } /* Anything smaller makes iPhones zoom in. */
  #scrim { display: block; position: fixed; z-index: 15; inset: 0; border: 0; }
  #menu, #new-chat-top { display: inline-grid; }
  .app header { padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right)); }
  #title { text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, ::before { animation: none !important; transition: none !important; }
  .working { color: var(--muted); background: none; }
}
