:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0eee9;
  --text: #1c1b19;
  --muted: #6b6860;
  --border: #e3e0d8;
  --accent: #4338ca;
  --accent-ink: #ffffff;
  --accent-soft: #e8e7fb;
  --ok-bg: #e5f4ea;
  --ok-ink: #1d5c33;
  --err-bg: #fbe7e5;
  --err-ink: #8a2419;
  --danger: #b42318;
  --me: #eef0ff;
  --ai: #f4f3ef;
  --note: #fff6db;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 18, 10, 0.06), 0 2px 8px rgba(20, 18, 10, 0.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131312;
    --surface: #1c1c1a;
    --surface-2: #252522;
    --text: #ecebe6;
    --muted: #a19e95;
    --border: #33322e;
    --accent: #8b87f5;
    --accent-ink: #111018;
    --accent-soft: #2a2950;
    --ok-bg: #173523;
    --ok-ink: #a8e2bb;
    --err-bg: #3d1a16;
    --err-ink: #f4b8af;
    --danger: #f97066;
    --me: #23244a;
    --ai: #222220;
    --note: #3a3214;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
code, pre, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .9em; }
pre { white-space: pre-wrap; word-break: break-word; margin: 0; }

.topbar {
  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(--border);
}
.topbar-inner {
  max-width: 960px; margin: 0 auto; padding: .6rem 16px;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.brand { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: .5rem; }
.brand img { width: 26px; height: 26px; border-radius: 7px; }
.nav { display: flex; gap: .9rem; flex-wrap: wrap; margin-left: auto; align-items: center; }
.nav a { color: var(--muted); font-weight: 500; }
.nav a:hover { color: var(--text); text-decoration: none; }
.nav form { margin: 0; }

main { max-width: 960px; margin: 0 auto; padding: 1.25rem 16px 4rem; }
.narrow { max-width: 440px; margin: 3rem auto; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; margin-bottom: 1rem; box-shadow: var(--shadow);
}
.card > h2:first-child { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: .6rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.flash { padding: .7rem .9rem; border-radius: 10px; margin-bottom: 1rem; }
.flash.ok { background: var(--ok-bg); color: var(--ok-ink); }
.flash.err { background: var(--err-bg); color: var(--err-ink); }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
input[type=text], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: .6rem .7rem; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 7rem; resize: vertical; line-height: 1.45; }
textarea.tall { min-height: 18rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=file] { font: inherit; max-width: 100%; }
.check { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; }
.check input { margin-top: .3rem; }

.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem .95rem; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; min-height: 40px;
}
.btn:hover, button:hover { text-decoration: none; filter: brightness(0.97); }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger, button.danger { color: var(--danger); }
.btn.small, button.small { padding: .3rem .65rem; min-height: 32px; font-size: .875rem; }
.linkish { background: none; border: none; padding: 0; min-height: 0; color: var(--muted); font-weight: 500; }

.badge {
  display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .75rem;
  font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.badge.chatgpt { background: #e6f4ef; color: #0f6b4f; border-color: #c4e6d9; }
.badge.claude { background: #fbeee6; color: #9a4a1c; border-color: #f1d4c2; }
.badge.gemini { background: #e8effc; color: #2a4fa8; border-color: #cbd9f6; }
@media (prefers-color-scheme: dark) {
  .badge.chatgpt { background: #12332a; color: #8fe0c2; border-color: #1f4d3f; }
  .badge.claude { background: #3a2417; color: #f3b48f; border-color: #57361f; }
  .badge.gemini { background: #17264a; color: #a9c2f7; border-color: #263c6c; }
}

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .65rem 0; border-top: 1px solid var(--border); }
.list li:first-child { border-top: none; }
.group-card { display: block; color: var(--text); }
.group-card:hover { text-decoration: none; border-color: var(--accent); }
.group-card h2 { color: var(--accent); }

.brief { white-space: pre-wrap; word-break: break-word; }
.msg { border-radius: 10px; padding: .7rem .85rem; margin-bottom: .6rem; border: 1px solid var(--border); }
.msg.user { background: var(--me); }
.msg.assistant, .msg.assistant_summary, .msg.transcript { background: var(--ai); }
.msg.note { background: var(--note); }
.msg .meta { font-size: .8rem; color: var(--muted); margin-bottom: .25rem; }
.msg .body { white-space: pre-wrap; word-break: break-word; }
.msg:target { outline: 2px solid var(--accent); }

.snippet { white-space: pre-wrap; word-break: break-word; }
.copybox { position: relative; }
.copybox pre {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: .75rem; max-height: 16rem; overflow: auto;
}
details summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: .6rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .4rem; border-top: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; border-top: none; }
.steps { padding-left: 1.2rem; margin: 0; }
.steps li { margin-bottom: .35rem; }
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .6rem; }
.tabs a { padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); font-weight: 600; font-size: .875rem; }
.tabs a.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.preview-img { max-width: 100%; border-radius: 10px; border: 1px solid var(--border); }
.hidden { display: none !important; }

@media (max-width: 600px) {
  h1 { font-size: 1.35rem; }
  .card { padding: .9rem; }
  .nav { gap: .7rem; font-size: .95rem; }
}
