:root {
  --bg: #f6f6f3; --panel: #fff; --text: #1f2421; --muted: #6b716d; --line: #dcdeda;
  --accent: #2f6f4f; --accent-text: #fff; --warn-bg: #fff4d6; --warn-line: #e6c56a;
  --ok-bg: #e5f3ea; --ok-line: #9fcfb1; --err-bg: #fbe5e3; --err-line: #e3a29b;
  --red: #b3261e; --blue: #1d5fb8; --stage: #2a2d2b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161917; --panel: #1f2321; --text: #e6e8e5; --muted: #9aa19c; --line: #353a37;
    --accent: #5fb38a; --accent-text: #0d1a13; --warn-bg: #3a3218; --warn-line: #7a6626;
    --ok-bg: #1c3326; --ok-line: #2f6f4f; --err-bg: #3d1f1d; --err-line: #8a3a33;
    --red: #ff8a80; --blue: #8ab4f8; --stage: #0e100f;
    color-scheme: dark;
  }
}
* { 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; }
a { color: var(--blue); }
main { max-width: 1500px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.5rem; margin: .2em 0 .6em; }
h2 { font-size: 1.1rem; }
input, textarea, select, button { font: inherit; color: inherit; }
input:not([type=radio]):not([type=checkbox]):not([type=range]):not([type=file]), textarea, select {
  width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel);
}
textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 13.5px; }
button, .button {
  display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel);
  cursor: pointer; text-decoration: none; color: var(--text); white-space: nowrap;
}
button:hover, .button:hover { border-color: var(--muted); }
button.primary, .button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--red); }
button.link { border: 0; background: none; padding: 0; color: var(--blue); text-decoration: underline; }
button:disabled { opacity: .5; cursor: default; }
label { display: block; margin: 0 0 10px; font-weight: 500; }
label input, label textarea, label select { margin-top: 3px; font-weight: 400; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 12px; padding: 8px 12px 4px; }
legend { font-weight: 600; padding: 0 4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; font-weight: 400; }
.note { color: var(--muted); max-width: 70ch; }
.empty { padding: 30px 0; color: var(--muted); }
.msg { padding: 8px 12px; border-radius: 6px; margin: 0 0 12px; border: 1px solid; }
.msg.ok { background: var(--ok-bg); border-color: var(--ok-line); }
.msg.err { background: var(--err-bg); border-color: var(--err-line); }
.msg.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.inline { display: inline; }
.stack > * { display: block; }
.narrow { max-width: 640px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > label { flex: 0 0 auto; }
.row > .grow { flex: 1 1 220px; }
.spacer { flex: 1; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px 16px 12px; margin: 0 0 16px; max-width: 900px; }
.copy { font-family: ui-monospace, monospace; font-size: 13px; }
table.list { border-collapse: collapse; width: 100%; }
table.list th, table.list td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.error { color: var(--red); }

/* Header */
.top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.top .brand { font-weight: 700; text-decoration: none; color: var(--text); }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; align-items: center; }
.top nav a { padding: 4px 9px; border-radius: 6px; text-decoration: none; color: var(--text); }
.top nav a[aria-current] { background: var(--accent); color: var(--accent-text); }
.top nav .sep { flex: 1; }
.count { display: inline-block; min-width: 1.5em; padding: 0 5px; border-radius: 9px; background: var(--line); color: var(--text); font-size: 12px; text-align: center; }
.top nav a[aria-current] .count { background: rgba(0,0,0,.2); color: inherit; }
.menu-toggle, .review-badge { display: none; }

/* Phones: the menu folds away behind a button */
@media (max-width: 760px) {
  .top { gap: 8px; padding: 8px 12px; }
  .top .brand { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .menu-toggle { display: inline-block; }
  .review-badge { display: inline-block; min-width: 1.8em; padding: 2px 7px; border-radius: 12px; background: var(--accent);
    color: var(--accent-text); font-size: 13px; font-weight: 700; text-align: center; text-decoration: none; }
  .top nav, .top .signout { display: none; }
  .top.menu-open nav { display: flex; flex-direction: column; align-items: stretch; flex-basis: 100%; gap: 2px; padding-top: 6px; }
  .top.menu-open nav a { padding: 9px 10px; }
  .top.menu-open nav .sep { display: block; height: 1px; background: var(--line); margin: 4px 0; flex: none; }
  .top.menu-open .signout { display: block; flex-basis: 100%; padding: 4px 10px 6px; }
}

/* Sign-in */
body.login main { max-width: 380px; margin-top: 12vh; }

/* Inbox list */
.post { margin: 0 0 22px; }
.post h2 { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin: 0 0 4px; }
.post-text { margin: 0 0 8px; color: var(--muted); max-width: 90ch; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.card { position: relative; display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; text-decoration: none; color: var(--text); }
.card:hover { border-color: var(--accent); }
.card img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; background: var(--line); }
.card-title { display: block; padding: 6px 8px 0; font-size: 13.5px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-sub { display: block; padding: 0 8px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.card::after { content: ""; display: block; height: 8px; }
.card .flag, .card .badge { position: absolute; top: 6px; font-size: 12px; padding: 1px 6px; border-radius: 4px; }
.card .flag { left: 6px; background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--text); }
.card .badge { right: 6px; background: rgba(0,0,0,.6); color: #fff; }
.site { font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 4px; background: var(--line); color: var(--text); }
.site-facebook { background: #1877f2; color: #fff; }
.site-reddit { background: #ff4500; color: #fff; }
.site-instagram { background: #c13584; color: #fff; }
.site-gphotos { background: #188038; color: #fff; }

/* Photo page */
.photo-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0 0 12px; }
.photo-layout { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .photo-layout { grid-template-columns: minmax(0, 1fr); } }
.fields { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; position: sticky; top: 8px; max-height: calc(100vh - 16px); overflow: auto; }
@media (max-width: 1000px) { .fields { position: static; max-height: none; } }
.with-ext { display: flex; align-items: center; gap: 4px; }
.with-prefix { display: flex; align-items: center; gap: 2px; margin-top: 3px; }
.with-prefix > span { color: var(--muted); font-weight: 400; white-space: nowrap; }
.with-prefix input { margin-top: 0 !important; }
.with-prefix input[readonly] { background: var(--bg); }
.earlier-sets { display: flex; flex-direction: column; gap: 4px; margin: -4px 0 10px; }
.set-pick { display: flex; gap: 8px; align-items: center; text-align: left; white-space: normal; font-size: 13px; padding: 4px 8px; }
.set-pick img { width: 44px; height: 33px; object-fit: cover; border-radius: 3px; flex: none; }
.set-pick.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.check .choice { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.with-ext span { color: var(--muted); }
.add-cat { display: flex; gap: 6px; margin: -4px 0 10px; }
.radios { display: flex; gap: 12px; flex-wrap: wrap; margin: 0 0 8px; align-items: center; }
.radios label { margin: 0; font-weight: 400; display: inline-flex; gap: 4px; align-items: center; }
.custom-url[hidden] { display: none; }
.check { font-size: 13px; margin: -6px 0 10px; }
.check:empty { display: none; }
.check a.missing { color: var(--red); }
.check .redir { color: var(--muted); }
.check .warnline { color: var(--red); }
.preview pre { white-space: pre-wrap; font-size: 12.5px; background: var(--bg); padding: 8px; border-radius: 6px; overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.upload-result:empty { display: none; }
.danger-zone { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.source-info { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin-top: 12px; }
.source-info summary { cursor: pointer; font-weight: 600; }
.location { margin: 0 0 10px; padding: 6px 10px; border-left: 3px solid var(--accent); background: var(--bg); border-radius: 4px; }
.location .private { font-size: 12px; color: var(--muted); }
.card .pin { position: absolute; bottom: 6px; right: 6px; font-size: 14px; }
.comments { margin: 0 0 10px; }
.comments summary { cursor: pointer; }
.comments p { font-size: 14px; white-space: normal; }
.done-thumb { max-width: 100%; border-radius: 8px; }

/* Editor */
.editor { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; justify-content: space-between; }
.tool-group { display: flex; gap: 4px; flex-wrap: wrap; }
.toolbar .zoom-level { min-width: 4.2em; font-variant-numeric: tabular-nums; }
.toolbar button.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.subbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 6px 0 0; }
.subbar select { width: auto; }
.subbar[hidden] { display: none; }
.stage { margin-top: 8px; background: var(--stage); border-radius: 6px; display: flex; justify-content: center; align-items: center; min-height: 300px; overflow: hidden; touch-action: none; }
.stage canvas { display: block; max-width: 100%; }
.adjust { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px 16px; margin-top: 8px; align-items: center; }
.adjust label { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; font-size: 13.5px; }
.adjust input[type=range] { flex: 1; min-width: 60px; }
.adjust output { width: 2.2em; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.edit-status { min-height: 1.4em; margin: 6px 0 0; }

/* Authors */
form.author { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 0 0 12px; max-width: 760px; }
.drop input[type=file] { display: block; margin: 6px 0; padding: 24px; border: 2px dashed var(--line); border-radius: 8px; width: 100%; background: var(--panel); }
