/* 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: 768px; margin: 0 auto; padding: 20px 16px 220px; }

/* 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); }
.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; }
.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; } .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: 80%; background: var(--user); border-radius: 20px; padding: 10px 18px; white-space: pre-wrap; font-size: 16px; line-height: 1.55; }
#chat .assistant { font-size: 16px; line-height: 1.7; }
#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 1em; }
.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 color-mix(in srgb, var(--line) 70%, transparent); margin: 1.4em 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: 6px; margin-top: 4px; min-height: 30px; }
.stats { color: var(--faint); font-size: 12px; line-height: 1.4; transition: opacity .15s; }
.act { border: 0; background: transparent; color: var(--muted); width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; }
.act:hover { background: var(--surface-2); color: var(--ink); }
.act svg { width: 16px; height: 16px; }
.act .done { display: none; }
.act.copied .done { display: block; color: var(--accent); }
.act.copied .idle { display: none; }
@media (hover: hover) { #chat .assistant:not(.live):not(:hover) .stats { opacity: 0; } }
.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) 22px); padding-top: 22px; }
.composer-inner { max-width: 768px; margin: 0 auto; padding: 0 16px 10px; }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 10px 10px 8px 14px; box-shadow: var(--shadow); transition: border-color .15s; }
.box:focus-within { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.box textarea { display: block; width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; resize: none; padding: 6px 4px 4px; max-height: 240px; line-height: 1.5; font-size: 16px; }
.box-row { display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.spacer { flex: 1; }
.icon { border: 0; background: transparent; color: var(--muted); width: 36px; height: 36px; 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(--ink); color: var(--bg); }
.icon.send:hover:not(:disabled) { background: var(--ink); color: var(--bg); opacity: .85; }
.icon.send:disabled { background: var(--line); color: var(--faint); opacity: 1; }
.icon.stop { background: var(--ink); color: var(--bg); }
.icon.stop:hover:not(:disabled) { background: var(--ink); color: var(--bg); opacity: .85; }
.chip-toggle { display: inline-flex; align-items: center; gap: 5px; height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 13.5px; color: var(--muted); cursor: pointer; user-select: none; transition: background .15s, color .15s, border-color .15s; }
.chip-toggle svg { width: 16px; height: 16px; }
.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; }
.settings-wrap { position: relative; }
.popover { position: absolute; bottom: 44px; left: 0; z-index: 6; min-width: 240px; display: grid; gap: 12px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.12); font-size: 13.5px; }
.popover label { display: grid; gap: 6px; color: var(--muted); }
.popover label > span { display: flex; align-items: center; gap: 8px; }
.popover select, .popover input { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 5px 8px; color: var(--ink); }
.popover input { width: 90px; }
.disclaimer { display: flex; align-items: center; justify-content: center; gap: 5px; margin-top: 8px; font-size: 12px; color: var(--faint); text-align: center; }
.disclaimer svg { width: 12px; height: 12px; color: var(--accent); }
.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); }
.dropping .box { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
