:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --ink: #1d1f23;
  --muted: #646a73;
  --line: #dfdcd5;
  --accent: #1f6f78;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1f2;
  --ok: #1d7a46;
  --ok-soft: #e4f4ea;
  --warn: #8a5a00;
  --warn-soft: #fbf0d9;
  --danger: #b3261e;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 2px 8px rgb(0 0 0 / .04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1e2125;
    --ink: #eceae6;
    --muted: #a0a6ae;
    --line: #33373d;
    --accent: #5fb7bf;
    --accent-ink: #0d1f21;
    --accent-soft: #1d3436;
    --ok: #6fcf97;
    --ok-soft: #1b3326;
    --warn: #f0c060;
    --warn-soft: #3a2f17;
    --danger: #ff8a80;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; margin-top: 1rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.pad { padding: 2rem 1rem; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--ink); text-decoration: none; }
.who { display: flex; gap: .75rem; align-items: center; font-size: .875rem; color: var(--muted); min-width: 0; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 860px; margin: 0 auto; padding: 1.25rem 1rem 7rem; }
.stack > * + * { margin-top: 1rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.narrow { max-width: 420px; margin: 2rem auto; }
.notice { background: var(--warn-soft); color: var(--warn); padding: .6rem .8rem; border-radius: 8px; }

label, .label, legend { display: block; font-weight: 600; font-size: .9rem; margin: .9rem 0 .3rem; }
input[type=text], input[type=email], input[type=password], input[type=url], input:not([type]), textarea {
  width: 100%; padding: .6rem .7rem; font: inherit; color: inherit;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
textarea { resize: vertical; min-height: 4.5rem; }
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.form-msg { color: var(--danger); min-height: 1.5em; margin: .75rem 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1rem; min-height: 44px; font: inherit; font-weight: 600; text-decoration: none;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--ghost { background: transparent; }
.link { background: none; border: 0; padding: .25rem 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }
.danger { color: var(--danger); }
form .btn--primary { margin-top: .5rem; }
.narrow .btn--primary { width: 100%; }
.narrow .link { margin-top: .75rem; }

.site-card .site-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.site-card h2 { margin: 0; }
.people { list-style: none; padding: 0; margin: 0; }
.people li { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; padding: .5rem 0; border-top: 1px solid var(--line); }
.people li > :first-child { font-weight: 600; overflow-wrap: anywhere; }
.pill { font-size: .8rem; padding: .1rem .55rem; border-radius: 99px; background: var(--warn-soft); color: var(--warn); }
.pill--ok { background: var(--ok-soft); color: var(--ok); }
.inline-form { display: flex; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.inline-form input { flex: 1 1 220px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 1rem; }
.site-list { padding-left: 1.2rem; }

/* editor */
.banners > * { margin-bottom: .75rem; }
.banner { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; padding: .75rem 1rem; border-radius: var(--radius); background: var(--accent-soft); }
.banner--ok { background: var(--ok-soft); }
.banner--warn { background: var(--warn-soft); color: var(--warn); }
.tabs { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .5rem; margin-bottom: .5rem; scrollbar-width: thin; }
.tabs button {
  flex: none; padding: .5rem .85rem; min-height: 40px; font: inherit; font-size: .9rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 99px; cursor: pointer;
}
.tabs button[aria-current=page] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tabs button.is-dirty::after { content: ""; display: inline-block; width: .5rem; height: .5rem; margin-left: .4rem; border-radius: 50%; background: var(--warn); vertical-align: middle; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); scroll-margin-top: 1rem; }
.field { position: relative; margin-bottom: .5rem; }
fieldset.field { border: 0; padding: 0; margin: 0 0 .5rem; min-width: 0; }
.count { position: absolute; right: 0; top: .95rem; font-size: .75rem; color: var(--muted); }
.count.over { color: var(--danger); font-weight: 700; }
.field > input + .count, .field > textarea + .count { top: auto; bottom: -1.2rem; }
.field:has(> .count) { margin-bottom: 1.4rem; }
.has-error input, .has-error textarea, input.has-error, textarea.has-error { border-color: var(--danger); }
.items { display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem; }
.row { display: flex; gap: .5rem; align-items: flex-start; }
.row > .field { flex: 1; margin: 0; }
.row > .field:has(> .count) { margin-bottom: 1.2rem; }
.item { border: 1px solid var(--line); border-radius: 8px; padding: 0 .75rem; background: var(--bg); }
.item[open] { padding-bottom: .75rem; }
.item summary { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .6rem 0; cursor: pointer; font-weight: 600; min-height: 44px; }
.item summary .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item summary .thumb { width: 48px; height: 36px; object-fit: cover; border-radius: 4px; flex: none; }
.item-tools { display: flex; gap: .25rem; flex: none; }
.item > .item-tools { justify-content: flex-end; margin-top: .5rem; }
.item summary::after { content: "▸"; color: var(--muted); flex: none; }
.item[open] summary::after { content: "▾"; }
.item summary::-webkit-details-marker { display: none; }
.item summary { list-style: none; }
.icon { width: 36px; height: 36px; font: inherit; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); cursor: pointer; }
.icon:disabled { opacity: .35; cursor: default; }
.row .icon { margin-top: .25rem; }
.tags label.check { display: inline-flex; align-items: center; gap: .4rem; font-weight: 400; margin: .25rem 1rem .25rem 0; }
.tags input { width: 1.1rem; height: 1.1rem; }
.photo-row { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.photo-row img, .photo-empty { width: 160px; max-width: 100%; height: 120px; object-fit: cover; border-radius: 8px; background: var(--line); border: 1px solid var(--line); }
.photo-empty { display: grid; place-items: center; color: var(--muted); font-size: .85rem; }
.photo-actions { flex: 1 1 220px; }
.photo-actions label { margin-top: .6rem; font-weight: 400; }
.history { margin-top: 1.5rem; }
.history ul { list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.history li { padding: .4rem 0; border-top: 1px solid var(--line); }
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .75rem max(1rem, calc((100vw - 860px) / 2)); background: var(--surface); border-top: 1px solid var(--line);
}
.status { font-weight: 600; }
.bar-actions { display: flex; gap: .5rem; }
.dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); max-width: min(480px, calc(100vw - 2rem)); padding: 1.25rem; }
.dialog::backdrop { background: rgb(0 0 0 / .4); }
.dialog ul { padding-left: 1.2rem; max-height: 40vh; overflow: auto; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.toast {
  position: fixed; left: 50%; bottom: 5.5rem; transform: translateX(-50%); z-index: 10;
  max-width: calc(100vw - 2rem); padding: .7rem 1rem; border-radius: 8px; color: #fff; background: #1d1f23; box-shadow: 0 4px 16px rgb(0 0 0 / .2);
}
.toast--error { background: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) { .toast--error { color: #1d1f23; } }

@media (max-width: 560px) {
  h1 { font-size: 1.35rem; }
  .bar { padding: .6rem 1rem; }
  .bar > div:first-child { width: 100%; font-size: .85rem; }
  .bar-actions { width: 100%; }
  .bar-actions .btn { flex: 1; }
  main { padding-bottom: 9rem; }
}
