/* style.css - BrowsePrivateLLM. Light and dark follow the system setting. */
:root {
  --bg: #f6f6f3; --surface: #ffffff; --surface-2: #efefea; --ink: #1c1d1b; --muted: #6a6c66; --faint: #9a9c95;
  --line: #e2e2dc; --accent: #2f6f5e; --accent-ink: #ffffff; --accent-soft: #e3efe9; --danger: #b3261e;
  --user: #e9efe9; --code-bg: #f1f1ec; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --radius: 14px; --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141514; --surface: #1c1e1c; --surface-2: #242624; --ink: #ebece8; --muted: #a0a29b; --faint: #74766f;
    --line: #2f312e; --accent: #6fb8a0; --accent-ink: #0f1a16; --accent-soft: #1f322b; --danger: #f2b8b5;
    --user: #233029; --code-bg: #111211; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  }
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; font: 15px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
svg { width: 18px; height: 18px; flex: none; }
[hidden] { display: none !important; }

/* buttons */
.btn, .cards button, .ghost { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 7px 14px; display: inline-flex; align-items: center; gap: 6px; transition: background .15s, border-color .15s; }
.ghost { background: transparent; border-color: transparent; }
.ghost:hover:not(:disabled), .cards button:hover:not(:disabled) { background: var(--surface-2); }
.cards button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.cards button.primary:hover:not(:disabled) { filter: brightness(1.06); background: var(--accent); }
.cards button.danger { color: var(--danger); }
.small { padding: 3px 10px; font-size: 13px; }

/* top bar */
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 880px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: -.01em; }
.logo { width: 24px; height: 24px; color: var(--accent-ink); }
.logo rect:first-child { fill: var(--accent); }
.status { margin: 0 auto; min-width: 0; flex: 0 1 auto; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 10px 5px 12px; font-size: 13.5px; max-width: 100%; }
.status span:not(.dot) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status svg { width: 14px; height: 14px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.status.ready .dot { background: #34a37a; box-shadow: 0 0 0 3px color-mix(in srgb, #34a37a 22%, transparent); }
.status.busy .dot { background: #d79b2b; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.top-actions { display: flex; gap: 6px; align-items: center; }
.profile-link { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px 6px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font-size: 13.5px; font-weight: 600; white-space: nowrap; transition: border-color .15s, color .15s; }
.profile-link svg { width: 17px; height: 17px; color: #0a66c2; }
.profile-link:hover { border-color: #0a66c2; color: #0a66c2; }
@media (prefers-color-scheme: dark) { .profile-link svg { color: #70b5f9; } .profile-link:hover { border-color: #70b5f9; color: #70b5f9; } }
#newChat { white-space: nowrap; }
@media (max-width: 640px) { .profile-link span, #newChat span { display: none; } .profile-link { padding: 7px; } #newChat { padding: 7px; }
  .top-inner { gap: 8px; padding: 8px 12px; } .top-actions { gap: 2px; flex: none; } .status { padding: 5px 8px 5px 10px; font-size: 13px; } }

main { max-width: 880px; margin: 0 auto; padding: 20px 16px 200px; }

/* setup */
.setup { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); margin-bottom: 18px; }
.setup-head { display: flex; justify-content: space-between; gap: 12px; }
.setup h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.02em; }
.lead { margin: 0 0 16px; color: var(--muted); max-width: 640px; }
.close { font-size: 22px; line-height: 1; padding: 2px 10px; height: fit-content; }
.cards { display: grid; gap: 10px; }
.card { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: var(--bg); }
.card.loaded { border-color: var(--accent); background: var(--accent-soft); }
.card .name { font-weight: 620; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge { font-size: 11.5px; font-weight: 600; letter-spacing: .02em; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge.ok { background: var(--accent-soft); color: var(--accent); }
.card .meta { color: var(--muted); font-size: 13.5px; }
.card .size { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.card .size .need::before { content: '·'; margin-right: 10px; }
.size .track { flex: 1; max-width: 260px; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.size .fill { height: 100%; background: var(--accent); border-radius: 3px; opacity: .55; }
.size .fill.stored { opacity: 1; }
.card .actions { display: flex; gap: 6px; grid-row: 1 / span 2; grid-column: 2; }
.progress { margin-top: 14px; }
.card .progress { grid-column: 1 / -1; margin-top: 6px; }
/* while it downloads or loads, a card shows only its progress (its own buttons and bar are replaced by it) */
.card:has(> .progress.running:not([hidden])) > .actions, .card:has(> .progress.running:not([hidden])) > .size { display: none; }
.progress-row { display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; color: var(--muted); margin-bottom: 6px; gap: 8px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
#progressFill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.options { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.options.single { grid-template-columns: minmax(0, 420px); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.field span { font-weight: 600; }
.field small { color: var(--muted); font-size: 12.5px; }
.field select, .field input[type=file] { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 7px 10px; width: 100%; min-width: 0; }
.model-info { margin-top: 14px; font-size: 13px; color: var(--muted); }
.model-info:empty { display: none; }
.err { color: var(--danger); font-size: 13.5px; margin: 0 0 8px; padding: 8px 12px; border-radius: 12px; background: color-mix(in srgb, var(--danger) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--danger) 25%, var(--line)); }
.err:empty { display: none; }
.engine { margin-top: 12px; font-size: 12px; color: var(--faint); }
@media (max-width: 640px) { .options, .options.single { grid-template-columns: minmax(0, 1fr); } .setup { padding: 18px 16px; } .private { margin-left: 0; } .card { grid-template-columns: 1fr; } .card .actions { grid-row: auto; grid-column: 1; order: 1; } .brand span { display: none; } .suggestions { grid-template-columns: 1fr; } }

/* empty state */
.empty { text-align: center; padding: 8vh 8px 20px; }
.empty h2 { font-size: 26px; margin: 0 0 6px; letter-spacing: -.02em; }
.empty p { color: var(--muted); margin: 0 0 20px; }
.suggestions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; max-width: 660px; margin: 0 auto; }
.suggestions button { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 12px 14px; color: var(--ink); line-height: 1.4; }
.suggestions button:hover { border-color: var(--accent); }
.suggestions b { display: block; font-weight: 600; margin-bottom: 2px; }
.suggestions span { color: var(--muted); font-size: 13.5px; }
@media (max-width: 640px) { .suggestions { grid-template-columns: 1fr; } .empty { padding-top: 4vh; } .empty h2 { font-size: 22px; } }

/* chat */
#chat .msg { margin: 18px 0; scroll-margin-bottom: 220px; word-wrap: break-word; }
#chat .user { margin-left: auto; width: fit-content; max-width: 85%; background: var(--user); border-radius: 18px 18px 4px 18px; padding: 10px 16px; white-space: pre-wrap; }
#chat .files { color: var(--muted); font-size: 12.5px; margin-bottom: 4px; display: flex; gap: 6px; align-items: center; }
#chat .assistant { position: relative; }
.answer > :first-child { margin-top: 0; }
.answer > :last-child { margin-bottom: 0; }
.answer p { margin: 0 0 .8em; }
.answer h3, .answer h4, .answer h5, .answer h6 { margin: 1.1em 0 .4em; line-height: 1.3; }
.answer h3 { font-size: 1.25em; } .answer h4 { font-size: 1.1em; } .answer h5, .answer h6 { font-size: 1em; }
.answer ul, .answer ol { margin: 0 0 .8em; padding-left: 1.5em; }
.answer li { margin: .2em 0; }
.answer li > ul, .answer li > ol { margin: .2em 0; }
.answer blockquote { margin: 0 0 .8em; padding: 2px 14px; border-left: 3px solid var(--line); color: var(--muted); }
.answer hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }
.answer a { color: var(--accent); }
.answer code { font-family: var(--mono); font-size: .88em; background: var(--code-bg); padding: .1em .35em; border-radius: 5px; }
.codeblock { margin: 0 0 .9em; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--code-bg); }
.codebar { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 4px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); font-family: var(--mono); }
.codeblock pre { margin: 0; padding: 12px 14px; overflow-x: auto; }
.codeblock pre code { background: none; padding: 0; font-size: 13px; line-height: 1.55; }
.copy { border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 3px 8px; border-radius: 6px; }
.copy:hover { background: var(--surface-2); color: var(--ink); }
.table { overflow-x: auto; margin: 0 0 .9em; }
.answer table { border-collapse: collapse; font-size: 14px; }
.answer th, .answer td { border: 1px solid var(--line); padding: 6px 10px; }
.answer th { background: var(--surface-2); }
details.think { margin: 0 0 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
details.think summary { cursor: pointer; padding: 7px 12px; color: var(--muted); font-size: 13.5px; list-style: none; display: flex; align-items: center; gap: 6px; }
details.think summary::-webkit-details-marker { display: none; }
details.think summary::before { content: "›"; display: inline-block; transition: transform .15s; font-size: 16px; line-height: 1; }
details.think[open] summary::before { transform: rotate(90deg); }
details.think .thought { padding: 0 14px 10px; color: var(--muted); font-size: 13.5px; white-space: pre-wrap; }
.foot { display: flex; align-items: center; gap: 10px; margin-top: 6px; min-height: 26px; }
.stats { color: var(--faint); font-size: 12px; }
.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* composer */
.composer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; background: linear-gradient(to bottom, transparent, var(--bg) 24px); padding-top: 24px; }
.composer-inner { max-width: 880px; margin: 0 auto; padding: 0 16px 12px; }
/* laptops: [paperclip | message | Send] in the rounded frame, then [Think, sampling, length ... private] */
.box { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 6px; align-items: end; }
.frame { grid-column: 1 / -1; grid-row: 1; align-self: stretch; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); transition: border-color .15s; }
.box:focus-within .frame { border-color: var(--accent); }
.dropping .frame { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
#attachBtn { grid-column: 1; grid-row: 1; margin: 6px 0 6px 6px; }
.box textarea { grid-column: 2; grid-row: 1; margin: 6px 0; min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; resize: none; padding: 8px 4px; max-height: 240px; line-height: 1.5; }
#stop, #send { grid-column: 3; grid-row: 1; justify-self: end; margin: 6px 6px 6px 0; }
.tools { grid-column: 1 / 3; grid-row: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-top: 8px; padding: 0 6px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.opts { display: contents; }
.tools select, .tools input[type=number] { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 2px 6px; font-size: 12.5px; }
.tools input[type=number] { width: 64px; }
.private { grid-column: 3; grid-row: 2; justify-self: end; margin-top: 8px; padding-right: 6px; display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.private svg { width: 13px; height: 13px; color: var(--accent); }
.p-more { display: none; }
.icon { border: 0; background: transparent; color: var(--muted); width: 38px; height: 38px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.icon:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.icon.round { border-radius: 50%; }
.icon.send { background: var(--accent); color: var(--accent-ink); }
.icon.send:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); filter: brightness(1.08); }
.icon.stop { background: var(--ink); color: var(--bg); }
.icon.stop:hover:not(:disabled) { background: var(--ink); color: var(--bg); }
/* Think: a chip with a bulb, filled when on */
.chip-toggle { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 11px 0 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 12.5px; color: var(--muted); cursor: pointer; user-select: none; transition: background .15s, color .15s, border-color .15s; }
.chip-toggle svg { width: 15px; height: 15px; }
.chip-toggle[hidden] { display: none; }
.chip-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-toggle:hover { background: var(--surface-2); }
.chip-toggle:has(input:checked) { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); color: var(--accent); }
.chip-toggle:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 10px; padding: 4px 4px 4px 10px; font-size: 13px; background: var(--surface); }
.chip button { border: 0; background: none; color: var(--muted); padding: 0 6px; font-size: 15px; border-radius: 6px; }
.chip button:hover { background: var(--surface-2); color: var(--ink); }
/* the answer's Copy button: plain text on laptops; its icons show on phones */
.foot .copy svg { display: none; width: 14px; height: 14px; }

/* ---- Phones only. Everything below sits in phone-sized media rules, so laptops and desktops keep the
   layout above. Three shapes: portrait phones (up to 640 px wide), small portrait phones (up to 380 px)
   and phones held sideways (a touch screen at most 500 px tall). ---- */
.phone-only { display: none; }
@media (max-width: 640px), (pointer: coarse) and (max-height: 500px) {
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  .phone-only { display: inline-flex; }
  .box textarea { font-size: 16px; max-height: 30vh; }
  .box textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tools { flex-wrap: nowrap; gap: 4px; margin: 0; padding: 0; }
  .tools .chip-toggle { height: 34px; padding: 0 12px 0 10px; font-size: 13.5px; }
  .tools .chip-toggle svg { width: 16px; height: 16px; }
  /* sampling and length: a panel above the box, opened by the settings button */
  .opts { display: none; }
  .box.show-settings .opts { display: grid; gap: 12px; position: absolute; left: 8px; right: 8px; bottom: calc(100% + 8px); z-index: 6; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 8px 30px rgba(0,0,0,.16); font-size: 14px; }
  .opts label { display: flex; align-items: center; gap: 10px; color: var(--muted); }
  .opts select, .opts input[type=number] { font-size: 16px; padding: 5px 8px; color: var(--ink); }
  .opts select { flex: 1; min-width: 0; }
  .opts input[type=number] { width: 90px; }
  #settingsBtn[aria-expanded="true"] { background: var(--surface-2); color: var(--ink); }
  /* each answer starts its footer with a clear Copy pill; tap the statistics for the details */
  .foot { flex-wrap: wrap; gap: 6px 10px; }
  .foot .copy { order: -1; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 5px 13px 5px 10px; font-size: 13px; color: var(--ink); background: var(--surface); }
  .foot .copy[hidden] { display: none; }
  .foot .copy .ic-copy { display: block; }
  .foot .copy.copied { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--accent-soft); }
  .foot .copy.copied .ic-copy { display: none; }
  .foot .copy.copied .ic-done { display: block; }
  .stats .s-more { display: none; }
  .stats.full .s-more { display: inline; }
  .stats:has(.s-more) { cursor: pointer; }
}
@media (max-width: 640px) {
  main { padding: 14px 14px 170px; }
  #chat .msg { scroll-margin-bottom: 170px; }
  #chat .user { max-width: 88%; }
  .composer { padding-top: 14px; background: linear-gradient(to bottom, transparent, var(--bg) 14px); }
  .composer-inner { padding: 0 10px max(8px, env(safe-area-inset-bottom)); }
  /* portrait: the message on top; paperclip, Think, settings and Send under it; the note below the box */
  .frame { grid-row: 1 / span 2; border-radius: 24px; }
  .box textarea { grid-column: 1 / -1; grid-row: 1; margin: 8px 0 0; padding: 6px 14px 4px; }
  #attachBtn { grid-column: 1; grid-row: 2; margin: 2px 0 8px 6px; }
  .tools { grid-column: 2; grid-row: 2; margin: 2px 0 8px; }
  #stop, #send { grid-column: 3; grid-row: 2; margin: 2px 8px 8px 0; }
  .private { grid-column: 1 / -1; grid-row: 3; justify-self: center; margin-top: 7px; padding: 0; font-size: 11.5px; color: var(--faint); }
  .private svg { width: 12px; height: 12px; }
  .p-more { display: inline; }
}
@media (max-width: 380px) {
  .top-inner { gap: 6px; padding: 8px 10px; }
  .status { font-size: 12.5px; }
  main { padding-left: 12px; padding-right: 12px; }
  .composer-inner { padding-left: 8px; padding-right: 8px; }
  .setup h1 { font-size: 20px; }
  .private { font-size: 10.5px; }
}
@media (pointer: coarse) and (max-height: 500px) {
  /* sideways: one line [paperclip | message | Think, settings | Send], the top bar scrolls away and the
     note hides, so the chat keeps most of the screen */
  .top { position: static; }
  .top-inner { padding-top: 4px; padding-bottom: 4px; }
  main { padding-top: 10px; padding-bottom: 90px; }
  #chat .msg { scroll-margin-bottom: 90px; }
  .empty { padding-top: 2vh; }
  .composer { padding-top: 8px; background: linear-gradient(to bottom, transparent, var(--bg) 8px); }
  .composer-inner { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .box { grid-template-columns: auto minmax(0, 1fr) auto auto; }
  .frame { grid-row: 1; }
  .box textarea { grid-column: 2; grid-row: 1; max-height: 28vh; margin: 4px 0; padding: 8px 4px; }
  #attachBtn { grid-column: 1; grid-row: 1; margin: 4px 0 4px 6px; }
  .tools { grid-column: 3; grid-row: 1; margin: 4px 0; align-self: end; }
  #stop, #send { grid-column: 4; grid-row: 1; margin: 4px 6px 4px 0; }
  .box.show-settings .opts { left: auto; width: 320px; }
  .private { display: none; }
}
