:root {
  --bg: #faf7f2; --surface: #ffffff; --surface-2: #f2ede4; --text: #2b2620; --muted: #776d60;
  --line: #e4dccf; --accent: #b4532a; --accent-text: #ffffff; --accent-soft: #f6e3d8;
  --fav: #c2334d; --share: #2f6f5e; --share-soft: #dcefe8; --shadow: 0 1px 3px rgba(60,40,20,.08), 0 4px 14px rgba(60,40,20,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1916; --surface: #24211d; --surface-2: #2e2a25; --text: #eee7dc; --muted: #a89d8e;
    --line: #3a352e; --accent: #e07a4c; --accent-text: #1b1916; --accent-soft: #3d2a20;
    --fav: #ef6b84; --share: #6cc4a8; --share-soft: #1f3530; --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

header { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px 14px; padding: 10px 16px; flex-wrap: wrap; }
header h1 { font-size: 19px; margin: 0; font-weight: 650; flex: 1; }
.who { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); flex-wrap: wrap; }
.who b { color: var(--text); }
.linkbtn { border: 0; background: none; color: var(--accent); padding: 2px 4px; font-size: 14px; text-decoration: underline; }
.iconbtn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 4px 10px; }
.iconbtn:hover { border-color: var(--accent); }

.page { max-width: 1300px; margin: 0 auto; padding: 16px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input[type=search] { flex: 1 1 220px; min-width: 0; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.filters select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); max-width: 100%; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; }
.chip[aria-pressed=true] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.count { color: var(--muted); font-size: 13px; margin: 0 0 10px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; text-align: left; padding: 11px 13px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; transition: transform .1s; }
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card .title { font-weight: 600; line-height: 1.25; }
.card .meta { color: var(--muted); font-size: 12.5px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.heart { color: var(--fav); }
.empty { color: var(--muted); font-size: 13.5px; font-style: italic; }
.more { display: block; margin: 16px auto 0; }
[hidden] { display: none !important; }

dialog { border: 0; border-radius: 16px; padding: 0; width: min(780px, calc(100vw - 24px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(20,15,10,.5); }
.dlg-head { position: sticky; top: 0; z-index: 1; background: var(--surface); padding: 16px 18px 10px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: flex-start; }
.dlg-head h2 { margin: 0; font-size: 21px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.dlg-body { padding: 14px 18px 20px; }
.metarow { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 13.5px; margin-bottom: 10px; }
.scalebar { display: flex; align-items: center; gap: 8px; margin: 4px 0 14px; font-size: 14px; color: var(--muted); }
.scalebar select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.origbtn { margin-left: auto; }
.orig { background: var(--surface-2); border-radius: 12px; padding: 10px; margin-bottom: 16px; }
.orig img { display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: 6px; cursor: zoom-in; }
.orig .pages { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.orig .on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.orig p { margin: 4px 0; }
.cols { display: grid; grid-template-columns: minmax(220px, 2fr) 3fr; gap: 20px; }
.cols h3, .notesbox h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 8px; }
.ing { list-style: none; padding: 0; margin: 0; }
.ing li { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.ing .grp { font-weight: 650; margin-top: 10px; border: 0; color: var(--accent); }
.ing .q { font-weight: 600; }
.ing .p { color: var(--muted); }
ol.steps { padding-left: 20px; margin: 0; }
ol.steps li { margin-bottom: 8px; }
.recnotes { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin-top: 14px; font-size: 14px; white-space: pre-line; }
.tagchip { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); margin: 0 4px 4px 0; cursor: pointer; border: 0; }
.tagchip:hover { color: var(--accent); }

.notesbox { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 14px; }
.note { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; margin-bottom: 6px; background: var(--accent-soft); }
.note.shared { background: var(--share-soft); }
.note .txt { flex: 1; min-width: 0; white-space: pre-line; overflow-wrap: anywhere; }
.note small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.note .acts { display: flex; gap: 4px; flex-shrink: 0; }
.smallbtn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 4px 9px; font-size: 13px; }
.smallbtn:hover { border-color: var(--accent); }
.noteform { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.noteform textarea { width: 100%; min-height: 60px; resize: vertical; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font: inherit; color: inherit; }
.noteform .row { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.noteform label { display: flex; gap: 6px; align-items: center; font-size: 14px; }
.primary { background: var(--accent); color: var(--accent-text); border: 0; border-radius: 9px; padding: 8px 16px; font-weight: 600; }
.signin-hint { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: 14px; }

.form { display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); font-weight: 600; }
.form input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.err { color: var(--fav); font-size: 14px; min-height: 1.2em; margin: 0; }
.lede { color: var(--muted); margin: 0 0 6px; font-size: 14px; }

.login { max-width: 380px; margin: 12vh auto 0; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.login h1 { margin: 0 0 6px; font-size: 22px; }
.wrap { padding: 0 16px; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; }

@media (max-width: 700px) {
  .page { padding: 12px 16px; }
  .grid { grid-template-columns: 1fr; }
  .cols { grid-template-columns: 1fr; }
  .dlg-body { padding: 12px 14px 18px; }
}
