:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1b1f24;
  --muted: #5d6673;
  --line: #d9dde3;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --bad: #cf222e;
  --bad-bg: #ffebe9;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --card: #181c22;
    --text: #e6e9ee;
    --muted: #9aa4b2;
    --line: #2c333d;
    --accent: #4c8dff;
    --accent-text: #0b0e12;
    --bad: #f85149;
    --bad-bg: #3a1d1d;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 16px;
}
.brand { font-weight: 700; }
.logout { display: flex; align-items: center; gap: 10px; margin: 0; }
.who { color: var(--muted); font-size: 0.93rem; }
.top-right { display: flex; align-items: center; gap: 16px; }
.lang { display: flex; gap: 8px; margin: 0; }
.lang button { font-size: 0.93rem; color: var(--muted); }
.lang button[aria-pressed="true"] { color: var(--text); font-weight: 700; }

main { max-width: 720px; margin: 0 auto; padding: 0 16px 32px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 16px;
  margin: 8px 0 16px;
}
.card.narrow { max-width: 440px; margin-left: auto; margin-right: auto; }

h1 { font-size: 1.35rem; margin: 0 0 16px; }

label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 0.95rem; }
.hint { font-weight: 400; color: var(--muted); }

input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
input[readonly] { color: var(--muted); }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}
button.primary, .button.primary { width: 100%; margin-top: 20px; background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.link { min-height: 0; padding: 4px 0; border: 0; background: none; color: var(--accent); }

.error {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bad-bg);
  color: var(--bad);
}
.note { color: var(--muted); font-size: 0.93rem; margin-top: 16px; }

/* ---- Uploader (Phase 5) ---- */
:root { --ok: #1a7f37; --ok-bg: #dafbe1; --warn: #9a6700; }
@media (prefers-color-scheme: dark) { :root { --ok: #3fb950; --ok-bg: #12261a; --warn: #d29922; } }

a { color: var(--accent); }
.brand { color: var(--text); text-decoration: none; }
h2 { font-size: 1.1rem; margin: 20px 0 10px; }
.card > h2:first-child { margin-top: 0; }
.center { text-align: center; }
.break { overflow-wrap: anywhere; }
[hidden] { display: none !important; }

textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  resize: vertical;
}
form button[type="submit"]:not(.link) { margin-top: 12px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.notice, .ok {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--ok-bg);
  color: var(--ok);
}
.status { min-height: 1.45em; margin: 8px 0; color: var(--muted); font-size: 0.93rem; }
.status.ok { padding: 0; background: none; }
.status.warn { color: var(--warn); }
.status.bad, .snap.bad { color: var(--bad); }
.snap { font-size: 0.93rem; }
#edit-status:empty { display: none; }

/* The file input sits inside its label button. */
.button.file { position: relative; overflow: hidden; }
.button.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.actions .primary { margin-top: 0; }
.actions button:not(.primary):not(.link) { flex: 1 1 auto; }

video { display: block; width: 100%; max-height: 60vh; margin-top: 12px; border-radius: 8px; background: #000; }
.file-summary { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
progress { width: 100%; height: 14px; margin-top: 12px; accent-color: var(--accent); }

.cut-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: end; margin-top: 10px; }
.cut-row label { grid-column: 1 / -1; margin: 0; }
.cut-row button { white-space: nowrap; }

ul.plain { list-style: none; padding: 0; margin: 6px 0 0; }
ul.plain li { padding: 6px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }

.tips { margin-top: 20px; color: var(--muted); font-size: 0.93rem; }
.tips summary { cursor: pointer; color: var(--text); }
.tips ul { padding-left: 20px; }

/* Gallery */
.gallery { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px 12px; }
.item a { display: flex; flex-direction: column; gap: 3px; color: var(--text); text-decoration: none; }
.thumb { position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: var(--bg); border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.portrait { background: #000; }
.thumb.portrait img { object-fit: contain; }
.thumb-text { color: var(--muted); font-size: 0.9rem; }
.duration { position: absolute; right: 6px; bottom: 6px; padding: 1px 6px; border-radius: 4px; background: rgb(0 0 0 / 0.7); color: #fff; font-size: 0.8rem; }
.item-name { font-weight: 600; font-size: 0.93rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { color: var(--muted); font-size: 0.82rem; }
.badge { align-self: flex-start; padding: 1px 8px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); font-size: 0.8rem; }
.state-stored .badge { color: var(--ok); border-color: currentColor; }
.state-deletion .badge, .state-uploading .badge { color: var(--warn); border-color: currentColor; }
.state-rejected .badge { color: var(--bad); border-color: currentColor; }
.state-deleted, .state-rejected { opacity: 0.75; }
.badge-line { margin: -8px 0 8px; }

/* One clip */
.player.portrait { max-height: 75vh; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 16px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

/* Shot details (ammunition and distance) */
.shot { border: 0; padding: 0; margin: 16px 0 0; min-width: 0; }
.shot > legend { padding: 0; font-weight: 700; font-size: 1.05rem; }
.shot > .note { margin: 2px 0 0; }
.shot .choice { border: 0; padding: 0; margin: 12px 0 0; min-width: 0; }
.shot .choice > legend { padding: 0; margin-bottom: 6px; font-weight: 600; font-size: 0.95rem; }
.shot .error { margin: 12px 0 0; }
.shot:disabled .chip span { cursor: default; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
label.chip { position: relative; margin: 0; font-weight: 400; }
.chip input { position: absolute; top: 0; left: 0; width: 1px; height: 1px; min-height: 0; opacity: 0; }
.chip span {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 21px;
  background: var(--card);
  cursor: pointer;
  user-select: none;
}
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip input:disabled:not(:checked) + span { opacity: 0.5; }
#ammo-custom-row label { margin-top: 10px; }
.item-shot { color: var(--text); }
.prewrap { white-space: pre-wrap; }
#shot-count-row label, .shot .desc label { margin-top: 10px; }
#shot-count-custom { max-width: 9em; }
.shot .desc { margin-top: 14px; }
.shot .desc label { font-size: 0.95rem; }
