/* Saga, in the family look: night background, warm gold, Cinzel titles, Inter text. */
:root {
  color-scheme: dark;
  --bg: #0e1014;
  --surface: #161920;
  --surface-2: #1d212a;
  --line: #2a2f3a;
  --text: #ece6da;
  --muted: #9b968c;
  --gold: #e5a93c;
  --gold-2: #f3c362;
  --gold-ink: #1a1408;
  --good: #6cc59a;
  --warn: #e0875a;
  --radius: 14px;
  --display: "Cinzel", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 var(--sans); }
body { min-height: 100dvh; padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--gold-2); }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: .02em; margin: 0; }
h2 { font-size: 1.15rem; color: var(--gold-2); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
[hidden] { display: none !important; }

/* header */
header.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
header.top img { width: 30px; height: 30px; }
header.top h1 { font-size: 1.35rem; color: var(--gold-2); flex: 1; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; cursor: pointer; color: var(--muted); }
.icon-btn:hover { color: var(--text); border-color: var(--gold); }

/* tabs: bottom bar on phones, top row on wide screens */
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
nav.tabs button { background: none; border: 0; padding: 10px 4px 12px; cursor: pointer; color: var(--muted); display: grid; justify-items: center; gap: 2px; font-size: .78rem; }
nav.tabs button b { font-family: "Noto Sans Runic", "Segoe UI Historic", var(--display); font-size: 1.15rem; font-weight: 600; line-height: 1; }
nav.tabs button.on { color: var(--gold-2); }
main { max-width: 760px; margin: 0 auto; padding: 16px; }
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  nav.tabs { position: sticky; top: 63px; bottom: auto; max-width: 760px; margin: 0 auto; border: 0; background: none; grid-template-columns: repeat(4, auto); justify-content: start; gap: 6px; padding: 10px 16px 0; }
  nav.tabs button { grid-auto-flow: column; gap: 8px; padding: 8px 14px; border-radius: 10px; font-size: .95rem; }
  nav.tabs button.on { background: var(--surface-2); }
}

/* cards and lists */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card h2 + * { margin-top: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; padding-top: 4px; }
.tag { display: inline-block; font-size: .72rem; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); margin-right: 4px; }
.tag.gold { color: var(--gold-2); border-color: color-mix(in srgb, var(--gold) 45%, transparent); }
.tag.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.empty { color: var(--muted); padding: 8px 0; }

/* buttons and fields */
.btn { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 7px 14px; cursor: pointer; }
.btn:hover { border-color: var(--gold); }
.btn.gold { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); font-weight: 600; }
.btn.gold:hover { background: var(--gold-2); }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: default; }
input[type=text], input[type=email], input[type=date], input[type=search], input:not([type]), textarea, select {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold); }
textarea { resize: vertical; }
label.f { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

/* brief */
.brief .headline { font-family: var(--display); font-size: 1.25rem; color: var(--gold-2); line-height: 1.3; }
.md p { margin: .55em 0; } .md ul, .md ol { margin: .4em 0; padding-left: 1.3em; } .md strong { color: var(--gold-2); font-weight: 600; }
.md code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.item .why { color: var(--muted); font-size: .88rem; }
.item .acts { margin-top: 8px; }

/* talk */
.talk { display: flex; flex-direction: column; min-height: calc(100dvh - 230px); }
.msgs { flex: 1; display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 16px; }
.msg.me { align-self: flex-end; background: var(--surface-2); border: 1px solid var(--line); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.saga { align-self: flex-start; background: var(--surface); border: 1px solid color-mix(in srgb, var(--gold) 30%, var(--line)); border-bottom-left-radius: 4px; }
.msg.saga .md > :first-child { margin-top: 0; } .msg.saga .md > :last-child { margin-bottom: 0; }
.chips { align-self: flex-start; display: flex; flex-wrap: wrap; gap: 4px; margin-top: -4px; }
.compose { position: sticky; bottom: calc(72px + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: flex-end; padding: 10px 0; background: var(--bg); }
.compose textarea { min-height: 46px; max-height: 40vh; }
@media (min-width: 900px) { .compose { bottom: 0; } }
.thinking { align-self: flex-start; color: var(--muted); font-style: italic; }
.thinking::after { content: ""; animation: dots 1.4s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* goals */
.goal .meta { color: var(--muted); font-size: .85rem; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2)); }
details.add > summary { cursor: pointer; color: var(--gold-2); list-style: none; }
details.add > summary::-webkit-details-marker { display: none; }

/* sign in, dialogs, toast */
.signin { max-width: 380px; margin: 12vh auto 0; text-align: center; }
.signin img { width: 96px; height: 96px; }
.signin h1 { font-size: 2rem; color: var(--gold-2); margin: 8px 0 4px; }
dialog { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; width: min(420px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
#toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--gold);
  padding: 8px 16px; border-radius: 99px; z-index: 20; display: none; max-width: calc(100vw - 32px); }
