:root { --bg: #f5f7f6; --surface: #fff; --fg: #0e1413; --muted: #586261; --line: #dce1e0; --accent: #0d7d75; --accent-soft: #dcf4f0; --warn: #9a5b00; --warn-soft: #fbf0d9; --user: #33558a; color-scheme: light; }
@media (prefers-color-scheme: dark) { :root { --bg: #0d1110; --surface: #141918; --fg: #e8eded; --muted: #9aa6a4; --line: #263030; --accent: #2bb3a8; --accent-soft: #10302d; --warn: #e0a84a; --warn-soft: #33270f; --user: #8fb0e6; color-scheme: dark; } }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

#signin { max-width: 340px; margin: 12vh auto 0; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; gap: 12px; }
#signin h1 { margin: 0; font-size: 24px; }
#signin p { margin: 0; color: var(--muted); }
#signin label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
#signin input { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
#signin button { padding: 10px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; }
#signin .other { display: block; text-align: center; padding: 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--fg); text-decoration: none; font-weight: 600; }
#signin .other:hover { border-color: var(--accent); }
.error { color: #b3261e; min-height: 1.2em; }

#app { height: 100%; display: flex; flex-direction: column; }
header { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.brand { font-size: 16px; }
#crumb { color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#search { margin-left: auto; display: flex; gap: 6px; flex: 1 1 260px; max-width: 460px; }
#q { flex: 1; min-width: 0; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); }
#scope { border: 1px solid var(--line); border-radius: 999px; background: var(--bg); padding: 0 8px; }
#me { color: var(--muted); font-size: 12px; }
#signout, #back { border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 5px 10px; }
#back { display: none; font-size: 18px; line-height: 1; }

main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(220px, 280px) minmax(240px, 330px) minmax(0, 1fr); }
main > * { overflow-y: auto; min-width: 0; padding: 12px; }
#people, #book { border-right: 1px solid var(--line); background: var(--surface); }
h2.group { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 14px 6px 4px; font-weight: 600; }
h2.group:first-child { margin-top: 2px; }
.row { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 6px 8px; border-radius: 8px; overflow-wrap: anywhere; }
.row:hover { background: var(--bg); }
.row[aria-current="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.row small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.row.asleep { color: var(--muted); }
.empty { color: var(--muted); padding: 8px; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 10px; font-size: 13px; }
.card b { font-size: 15px; display: block; overflow-wrap: anywhere; }
.card dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 8px 0 0; }
.card dt { color: var(--muted); } .card dd { margin: 0; }

#read { padding: 20px max(16px, 3vw) 60px; outline: none; }
#read .doc { max-width: 78ch; }
#read h1 { font-size: 22px; line-height: 1.25; margin: 0 0 10px; overflow-wrap: anywhere; }
#read h2 { font-size: 16px; margin: 22px 0 6px; } #read h3 { font-size: 14px; margin: 18px 0 4px; }
#read h3.turn { color: var(--accent); border-top: 1px solid var(--line); padding-top: 12px; }
#read p, #read li { overflow-wrap: anywhere; } #read p { margin: 0 0 10px; }
#read ul { padding-left: 20px; margin: 0 0 10px; }
#read a { color: var(--accent); }
#read code { background: var(--line); border-radius: 4px; padding: 0 4px; font-size: 13px; }
#read pre { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.where { color: var(--muted); font-size: 12px; margin-bottom: 14px; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip { font-size: 12px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 1px 9px; }
.chip i { font-style: normal; opacity: .7; }
.who { font-size: 11px; letter-spacing: .04em; } .who-user { color: var(--user); } .who-assistant { color: var(--muted); } .who-fermi { color: var(--accent); } .who-file { color: var(--warn); }
.aside { color: var(--muted); font-size: 13px; }
.hit { display: block; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 11px; margin-bottom: 8px; }
.hit:hover { border-color: var(--accent); }
.hit small { color: var(--muted); display: block; overflow-wrap: anywhere; } .hit span { overflow-wrap: anywhere; }
mark { background: var(--warn-soft); color: inherit; border-radius: 3px; }
.found { outline: 2px solid var(--warn); outline-offset: 3px; border-radius: 4px; }
.figure { display: block; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin: 4px 0 2px; }
iframe.plot { display: block; width: 100%; height: min(70vh, 520px); border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.open { display: inline-block; margin-top: 8px; padding: 8px 14px; border-radius: 8px; background: var(--accent); color: #fff !important; text-decoration: none; font-weight: 600; }

@media (max-width: 860px) {
  main { grid-template-columns: 1fr; }
  main > * { display: none; border-right: 0 !important; }
  body.at-people #people, body.at-book #book, body.at-read #read { display: block; }
  body.at-book #back, body.at-read #back { display: inline-block; }
  #me { display: none; }
}
