:root {
  --bg: #f6f5f2; --surface: #ffffff; --ink: #1c1f24; --muted: #6b6f76; --line: #e4e1db;
  --accent: #1d2a3a; --accent-ink: #ffffff; --hover: #f0eee9; --err: #b3261e; --ok: #2e7d4f;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a; --surface: #1d2024; --ink: #e8e6e1; --muted: #9a9ea5; --line: #2e3237;
    --accent: #c9b99a; --accent-ink: #15171a; --hover: #25292e; --err: #f2b8b5; --ok: #8fd4a8;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15171a; --surface: #1d2024; --ink: #e8e6e1; --muted: #9a9ea5; --line: #2e3237;
  --accent: #c9b99a; --accent-ink: #15171a; --hover: #25292e; --err: #f2b8b5; --ok: #8fd4a8;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; letter-spacing: .02em; }
.brand b { font-weight: 600; }
.mark {
  width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-family: Georgia, serif; font-size: 17px;
}
nav { display: flex; align-items: center; gap: 18px; }
.who { color: var(--muted); font-size: 14px; }

main { max-width: 1080px; margin: 0 auto; padding: 28px 24px 120px; }
h1 { font-size: 22px; margin: 0 0 18px; font-weight: 600; }
h2 { font-size: 16px; margin: 0 0 14px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; margin-bottom: 18px;
}
.narrow { max-width: 400px; margin: 60px auto; }
form label { display: block; margin-bottom: 14px; font-size: 14px; color: var(--muted); }
form label input { display: block; width: 100%; margin-top: 5px; }
input, select {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.pw { position: relative; display: block; margin-top: 5px; }
form label .pw input { margin-top: 0; padding-right: 42px; }
.pw-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; display: grid; place-items: center;
  background: none; border: 0; border-radius: 6px; cursor: pointer; color: var(--muted);
}
.pw-eye:hover { color: var(--ink); background: var(--hover); }
.pw-eye .ico { width: 20px; height: 20px; }
.err { color: var(--err); min-height: 1.2em; margin: 4px 0 10px; font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); font-size: 14px;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink); font-size: 14px; }
.link:hover { text-decoration: underline; }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; font-size: 16px; }
.crumbs li + li::before { content: "/"; color: var(--muted); margin-right: 6px; }
.crumbs a { color: var(--ink); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs li:last-child a { font-weight: 600; }
.hint { color: var(--muted); font-size: 13px; margin: -4px 0 14px; }

.listing { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.item {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto auto auto; align-items: center; gap: 14px;
  padding: 11px 16px; border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: 0; }
.item:hover { background: var(--hover); }
.item a { color: var(--ink); text-decoration: none; }
.item > :nth-child(2) { overflow-wrap: anywhere; }
.item .sub { color: var(--muted); font-size: 13px; }
.item .meta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.ico { width: 22px; height: 22px; color: var(--muted); }
.ico.dir { color: var(--accent); }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

.roots { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.root {
  display: block; padding: 26px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); text-decoration: none;
}
.root:hover { border-color: var(--accent); }
.root b { display: block; font-size: 17px; margin: 10px 0 4px; }
.root span { color: var(--muted); font-size: 14px; }

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row input { flex: 1 1 220px; }
.invout { display: flex; gap: 8px; margin-top: 12px; }
.invout input { flex: 1; font-family: ui-monospace, monospace; font-size: 13px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; }
.events { font-size: 13px; max-height: 360px; overflow: auto; }
.events div { padding: 5px 0; border-bottom: 1px solid var(--line); }
.events time { color: var(--muted); margin-right: 8px; font-variant-numeric: tabular-nums; }

.progress {
  position: fixed; right: 20px; bottom: 20px; width: min(380px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: 0 8px 30px rgba(0,0,0,.12);
}
.p-head { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 14px; }
.p-bar { height: 6px; background: var(--hover); border-radius: 3px; overflow: hidden; }
#p-fill { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.p-meta { display: flex; justify-content: space-between; margin-top: 8px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.dropzone {
  position: fixed; inset: 0; background: color-mix(in srgb, var(--accent) 18%, transparent);
  display: grid; place-items: center; z-index: 10; pointer-events: none;
}
.dropzone div {
  background: var(--surface); padding: 22px 30px; border-radius: var(--radius);
  border: 2px dashed var(--accent); font-size: 16px;
}

@media (max-width: 640px) {
  .top { padding: 12px 16px; }
  main { padding: 20px 16px 120px; }
  .item { grid-template-columns: 24px minmax(0, 1fr) auto; gap: 10px; }
  .item .meta.date { display: none; }
  .item .meta.size { display: none; }
  .who { display: none; }
}

/* ---------- casting ---------- */
.cast-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.cast-head h1 { margin-bottom: 4px; }
.cast-head p { margin: 0; max-width: 60ch; }
.cast-sum { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cast-sum b { color: var(--ink); }
.cast-filter { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 13px; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.cast-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.cast-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.cast-card.v-si { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok); }
.cast-card.v-no { opacity: .55; }
.cast-img { position: relative; aspect-ratio: 2 / 3; background: var(--hover); cursor: zoom-in; border: 0; padding: 0; display: block; width: 100%; }
.cast-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cast-img .swap { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; padding: 3px 8px; border-radius: 999px; }
.cast-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.cast-meta { display: flex; justify-content: space-between; align-items: baseline; }
.cast-meta b { font-size: 15px; }
.cast-meta span { color: var(--muted); font-size: 13px; }
.votes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.vote { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 0; cursor: pointer; font-size: 14px; }
.vote:hover { background: var(--hover); }
.vote.on[data-v="si"] { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.vote.on[data-v="forse"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.vote.on[data-v="no"] { background: var(--muted); border-color: var(--muted); color: var(--surface); }
.cast-body textarea { width: 100%; min-height: 54px; resize: vertical; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font: inherit; font-size: 13px; color: inherit; }
.saved { font-size: 12px; color: var(--ok); height: 14px; margin-top: -6px; }
.others { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: grid; place-items: center; z-index: 20; cursor: zoom-out; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }

.note { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; padding: 12px 16px; margin: 0 0 16px; font-size: 14px; }
.note p { margin: 0 0 6px; }
.note p:last-child { margin-bottom: 0; }
.note ul { margin: 4px 0 6px; padding-left: 20px; }
.note .muted { font-size: 13px; }
