:root {
  --bg: #f6f7f9; --card: #fff; --text: #1b1f24; --muted: #5f6b7a; --line: #dde2e8;
  --brand: #1f3a5f; --accent: #2f6fdb; --danger: #c0392b; --ok: #1e8e5a; --warn-bg: #fff6e0;
  --radius: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111418; --card: #1a1f25; --text: #e8ecf1; --muted: #9aa6b4; --line: #2c333c;
          --brand: #8db4ff; --accent: #6ea2ff; --danger: #ff7b6b; --warn-bg: #3a3220; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
main { max-width: 860px; margin: 0 auto; padding: 16px 16px 64px; }
main.narrow { max-width: 480px; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 8px 0 12px; }
h2 { font-size: 1.1rem; margin: 28px 0 8px; }
.muted { color: var(--muted); } .small, small { font-size: .875rem; } .center { text-align: center; } .right { text-align: right; }
.error { color: var(--danger); } .notice { background: var(--warn-bg); padding: 10px 12px; border-radius: 8px; }

header.top { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; color: var(--brand); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand span { font-weight: 400; color: var(--muted); margin-left: 4px; }
header nav { display: flex; align-items: center; gap: 14px; }
header nav a { text-decoration: none; }
header form { margin: 0; }

input, textarea, select { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card); color: var(--text); }
textarea { resize: vertical; }
label { display: block; font-weight: 600; font-size: .95rem; }
label > input, label > textarea, label > select { margin-top: 4px; font-weight: 400; }
.stack { display: flex; flex-direction: column; gap: 14px; margin: 12px 0; }
.narrow-form { max-width: 480px; }
button, .btn { font: inherit; border-radius: 10px; padding: 10px 16px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); cursor: pointer; text-decoration: none; display: inline-block; text-align: center; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; padding: 12px 16px; }
button.danger, .danger { color: var(--danger); }
button.link { background: none; border: none; padding: 0; color: var(--accent); }
button:disabled { opacity: .5; }
progress { width: 100%; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 4px 0 14px; }
.bigbtn { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 18px 8px; border-radius: var(--radius);
  background: var(--brand); color: #fff; text-decoration: none; font-weight: 600; }
@media (prefers-color-scheme: dark) { .bigbtn { color: #0d1117; } }
.bigbtn span { font-size: 1.8rem; }
.search input { border-radius: 999px; }

.notes { list-style: none; padding: 0; margin: 12px 0; }
.notes .day { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 4px 6px; }
.note-card { display: flex; gap: 12px; padding: 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 8px; color: inherit; text-decoration: none; }
.note-card img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex: none; }
.note-card p { margin: 2px 0; color: var(--muted); font-size: .92rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-card small { color: var(--muted); }

.banner { background: var(--warn-bg); padding: 12px; border-radius: var(--radius); margin-bottom: 12px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.banner form { margin: 0; }
.meta { color: var(--muted); margin-top: -6px; }
.summary { font-size: 1.05rem; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: .8rem; padding: 2px 10px; border-radius: 999px; background: var(--line); color: var(--text); text-decoration: none; }
.tag.site { background: var(--brand); color: #fff; }
.todo { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 16px; margin: 12px 0; }
.todo ul { padding-left: 20px; } .due { color: var(--danger); font-size: .85rem; white-space: nowrap; }
.body { overflow-wrap: anywhere; }
.body img { max-width: 100%; }
.gallery, .thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.gallery a { text-decoration: none; color: var(--muted); }
.gallery img, .thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
audio { width: 100%; }
.transcript { white-space: pre-wrap; color: var(--muted); }
details summary { cursor: pointer; }
.plain { list-style: none; padding: 0; } .plain li { padding: 4px 0; }
.tools { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); align-items: flex-start; }
.tools form { margin: 0; }
.tools details.edit { flex-basis: 100%; order: 5; }
.tools details.edit summary { list-style: none; display: inline-block; }
.filepick { display: flex; align-items: center; justify-content: center; padding: 28px; border: 2px dashed var(--line); border-radius: var(--radius); cursor: pointer; font-size: 1.1rem; }
.filepick input { display: none; }

.timer { font-size: 3rem; text-align: center; font-variant-numeric: tabular-nums; margin: 16px 0; }
.recbtn { display: block; margin: 0 auto; width: 96px; height: 96px; border-radius: 50%; border: 4px solid var(--line); background: var(--card); padding: 0; }
.recbtn span { display: block; margin: auto; width: 56px; height: 56px; border-radius: 50%; background: var(--danger); transition: all .2s; }
.recbtn.on span { width: 36px; height: 36px; border-radius: 6px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.row { display: flex; gap: 12px; margin: 16px 0; } .row button { flex: 1; }

.qr { display: block; margin: 12px auto; width: 220px; height: 220px; background: #fff; border-radius: 8px; }
.secret { word-break: break-all; font-size: 1.05rem; }
.copy { font-family: monospace; }
table.users { width: 100%; border-collapse: collapse; }
table.users td, table.users th { padding: 10px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.users form { display: inline; margin-left: 8px; }
tr.inactive td { opacity: .55; }

/* hub: heading, tabs, list sections */
.hero { margin: 8px 0 14px; }
.hero h1 { font-size: 2rem; margin: 0; color: var(--brand); letter-spacing: -.02em; }
.hero p { margin: 0; color: var(--muted); }
.tabs { display: flex; gap: 4px; margin: 14px 0 4px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
h2.section { display: flex; align-items: baseline; justify-content: space-between; font-size: 1.05rem; margin: 18px 0 4px; }
h2.section .clear { font-size: .875rem; font-weight: 400; }
.row-card { display: flex; align-items: stretch; gap: 8px; margin-bottom: 8px; }
.row-card .note-card { flex: 1; margin-bottom: 0; min-width: 0; }
.row-card form { margin: 0; display: flex; }
button.done { width: 48px; border-radius: var(--radius); font-size: 1.25rem; color: var(--ok); padding: 0; }
button.done:hover { background: var(--ok); color: #fff; border-color: var(--ok); }
.badge { background: var(--line); border-radius: 999px; padding: 0 8px; font-size: .75rem; }
.topics { list-style: none; padding: 0; margin: 8px 0; }
.topics li { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.topic { flex: 1; display: block; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: inherit; }
.topic small { display: block; color: var(--muted); }
.tag.cat { background: var(--brand); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { .tag.cat { color: #0d1117; } }
.done-banner { background: var(--line); }

/* note page: folded details */
details.more { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 12px; }
details.more > summary { font-weight: 600; color: var(--muted); padding: 6px 0; }
details.more h3 { font-size: .95rem; margin: 20px 0 6px; }
.row-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; }
.row-tools form { margin: 0; }
.note .gallery { margin: 16px 0; }
.note audio { margin: 8px 0; }

/* note page: add-to and editor */
.addto { margin-top: 20px; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.addto h2 { margin: 0 0 4px; font-size: 1rem; }
.addto .stack { margin: 8px 0; gap: 8px; }
.addto .row-tools { justify-content: flex-start; margin-top: 4px; }
.addto p { margin: 10px 0 0; }
.editor { margin-top: 20px; padding: 14px 16px; background: var(--card); border: 2px solid var(--accent); border-radius: var(--radius); }
.editor h2 { margin-top: 0; }
.editor .row a { flex: 1; }

/* chat */
.askbtn { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; margin: 0 0 14px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--text); text-decoration: none; font-weight: 600; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; margin: 12px 0; }
.chat-form textarea { flex: 1; }
.crumbs { margin: 0 0 8px; }
.crumbs a { text-decoration: none; }
.chat { display: flex; flex-direction: column; gap: 8px; }
.msg { display: flex; flex-direction: column; max-width: 88%; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.pa { align-self: flex-start; }
.msg small { color: var(--muted); font-size: .75rem; margin: 2px 6px 0; }
.bubble { padding: 10px 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); overflow-wrap: anywhere; }
.msg.me .bubble { background: var(--accent); border-color: var(--accent); color: #fff; white-space: pre-wrap; border-bottom-right-radius: 4px; }
.msg.pa .bubble { border-bottom-left-radius: 4px; }
.bubble.body > :first-child { margin-top: 0; } .bubble.body > :last-child { margin-bottom: 0; }
.bubble.body ul, .bubble.body ol { padding-left: 20px; }
.typing { color: var(--muted); animation: pulse 1.2s infinite; }
.toolnote { align-self: flex-start; font-size: .8rem; color: var(--muted); padding: 0 6px; }
.toolnote::before { content: "🔎 "; }
.action { align-self: stretch; padding: 12px 14px; border-radius: var(--radius); background: var(--card); border: 2px solid var(--accent); }
.action ul { margin: 6px 0; padding-left: 18px; }
.action .row { margin: 10px 0 0; }
.action .row form { flex: 1; margin: 0; display: flex; } .action .row form button { flex: 1; }
.action.done, .action.cancelled, .action.failed { border-width: 1px; border-color: var(--line); }
.action.cancelled { opacity: .7; }
.ok { color: var(--ok); }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
label.check input { width: auto; margin: 0; }
