:root {
  --bg: #f5f2ec;
  --panel: #ffffff;
  --ink: #1f1c18;
  --muted: #7a7268;
  --line: #e4ddd2;
  --accent: #9a6a23;
  --accent-ink: #ffffff;
  --accent-soft: #f3e7d3;
  --error: #b3261e;
  --stage: #0e0e10;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17150f;
    --panel: #201d17;
    --ink: #efe9df;
    --muted: #a39a8d;
    --line: #37322a;
    --accent: #d4a256;
    --accent-ink: #1a1408;
    --accent-soft: #3a2f1e;
    --error: #ff8a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Heebo", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  display: flex;
  flex-direction: column;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; border-radius: 8px; padding: 9px 16px; }
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--accent); color: var(--accent-ink); font-weight: 500; width: 100%; padding: 12px; }
.secondary { background: transparent; border: 1px solid var(--line); }
.secondary:hover { border-color: var(--accent); }
.small { padding: 5px 12px; font-size: 13px; }
.button { display: inline-block; text-align: center; text-decoration: none; padding: 10px 16px; border-radius: 8px; width: 100%; }
.muted { color: var(--muted); font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; line-height: 1.5; }
.error { color: var(--error); font-size: 14px; margin: 10px 0 0; }
.row { display: flex; gap: 10px; align-items: center; }

.top {
  display: flex; align-items: center; gap: 24px;
  padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 20px; }
.brand span { font-weight: 400; color: var(--muted); font-size: 14px; margin-inline-start: 6px; }
.tabs { display: flex; gap: 4px; }
.tabs button { background: transparent; color: var(--muted); }
.tabs button.active { background: var(--accent-soft); color: var(--ink); font-weight: 500; }
.folder { display: flex; gap: 8px; align-items: center; margin-inline-start: auto; flex-wrap: wrap; }
.upload-btn { cursor: pointer; border-radius: 8px; padding: 7px 12px; font-size: 14px; }
#logout { text-decoration: none; }
.folder select, .folder input {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; max-width: 260px;
}

main { flex: 1; min-height: 0; display: flex; }
.tab { display: none; flex: 1; min-height: 0; }
.tab.active { display: flex; }

.panel {
  width: 340px; flex-shrink: 0; overflow-y: auto; padding: 20px;
  background: var(--panel); border-inline-end: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 14px;
}
.panel h2 { font-size: 13px; font-weight: 500; color: var(--muted); margin: 0 0 8px; letter-spacing: .02em; }
.field { display: flex; flex-direction: column; }
.field label { font-size: 14px; margin-top: 10px; display: flex; justify-content: space-between; }
.field output { color: var(--muted); font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=number] {
  width: 84px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px;
}
details { margin-top: 10px; font-size: 14px; }
summary { cursor: pointer; color: var(--muted); }

.target-pick {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: start;
  background: var(--bg); border: 1px dashed var(--line); padding: 10px;
}
.target-pick img { width: 64px; height: 80px; object-fit: cover; border-radius: 6px; }

.progress .bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress .bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.progress p { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.progress.indeterminate .bar span { width: 30%; animation: slide 1.2s infinite ease-in-out; }
@keyframes slide { from { transform: translateX(120%); } to { transform: translateX(-340%); } }

.info { background: var(--bg); border-radius: var(--radius); padding: 12px; font-size: 14px; line-height: 1.6; margin: 0; }
.info:empty { display: none; }

.stage { flex: 1; min-width: 0; position: relative; }
.viewer-stage { background: var(--stage); }
#viewer { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#viewer.dragging { cursor: grabbing; }
.viewer-tools {
  position: absolute; bottom: 14px; inset-inline-start: 14px; display: flex; gap: 12px; align-items: center;
  background: rgba(20, 20, 22, .75); color: #ddd; padding: 6px 10px; border-radius: 8px;
}
.viewer-tools .secondary { border-color: #555; color: #eee; }
.viewer-tools .muted { color: #aaa; }
.empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #9a948b; font-size: 16px; padding: 24px; text-align: center;
}

.scroll { overflow-y: auto; padding: 16px 20px; }
.grid-tools { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 14px; }
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; align-content: start;
}
.thumb {
  position: relative; display: block; padding: 0; border-radius: 6px;
  overflow: hidden; background: var(--line); border: 2px solid transparent;
}
/* The image itself is square, so it sizes the grid row even before it loads. */
.thumb img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; }
.thumb:hover { border-color: var(--accent); }
.thumb.selected { border-color: var(--accent); }
.thumb.out img { opacity: .45; }
.thumb .badge {
  position: absolute; top: 6px; inset-inline-start: 6px; min-width: 24px; height: 24px; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; padding: 0 6px;
}
.thumb .tag {
  position: absolute; bottom: 0; inset-inline: 0; font-size: 11px; background: rgba(0,0,0,.55); color: #fff; padding: 2px 4px;
}

.selection { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.selection li { display: flex; align-items: center; gap: 10px; background: var(--bg); border-radius: 8px; padding: 6px; }
.selection img { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; }
.selection .name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: right; }
.selection button { background: transparent; padding: 4px 6px; font-size: 16px; color: var(--muted); }
.selection button.star.on { color: var(--accent); }

#music-select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
}
#music-preview { width: 100%; margin-top: 8px; height: 36px; }
video { width: 100%; max-height: 520px; background: #000; border-radius: var(--radius); }
.film-list { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.film-list li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
.film-list a { color: var(--accent); text-decoration: none; direction: ltr; }
.film-delete { background: transparent; color: var(--muted); padding: 0 0 0 4px; margin-inline-start: 8px; font-size: 14px; }
.film-delete:hover { color: var(--error); }

.text {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; margin-top: 4px;
}
.held { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 8px; }
.held li { display: flex; gap: 10px; align-items: center; background: var(--bg); border-radius: 8px; padding: 6px; }
.held img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.held .why { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); }
.held .why strong { display: block; color: var(--ink); font-size: 13px; }
.held .acts { display: flex; flex-direction: column; gap: 3px; }
.held .acts button { padding: 2px 8px; font-size: 12px; }
.held .acts button.on { border-color: var(--accent); color: var(--accent); }
.event-stage { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; }
.qr-card {
  background: #fffdf8; color: #1f1c18; border-radius: 18px; padding: 32px 36px; text-align: center;
  width: min(420px, 100%); box-shadow: 0 12px 40px rgba(0,0,0,.12);
}
.qr-eyebrow { margin: 0; color: #9a6a23; letter-spacing: .08em; font-size: 14px; }
.qr-card h2 { margin: 2px 0 18px; font-size: 30px; }
.qr-code svg { width: 100%; height: auto; display: block; }
.qr-code:empty { aspect-ratio: 1; background: repeating-linear-gradient(45deg, #eee 0 10px, #f6f6f6 10px 20px); border-radius: 8px; }
.qr-call { font-size: 19px; margin: 18px 0 4px; font-weight: 500; }
.qr-url { font-size: 13px; color: #7a7268; margin: 0; word-break: break-all; }
.qr-missing { max-width: 420px; text-align: center; }

@media print {
  body * { visibility: hidden; }
  #qr-card, #qr-card * { visibility: visible; }
  #qr-card { position: fixed; inset: 0; margin: auto; height: fit-content; box-shadow: none; }
}

dialog {
  width: min(1100px, 94vw); height: 86vh; border: 0; border-radius: 14px; padding: 0;
  background: var(--panel); color: var(--ink);
}
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog[open] { display: flex; flex-direction: column; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 17px; }
.dialog-body { overflow-y: auto; padding: 16px 20px; flex: 1; min-height: 0; }

@media (max-width: 760px) {
  main, .tab.active { flex-direction: column; }
  .panel { width: 100%; border-inline-end: 0; border-bottom: 1px solid var(--line); max-height: 55vh; }
  .stage { min-height: 50vh; }
  .folder { margin-inline-start: 0; }
}

/* The mypiece wordmark: Poppins ExtraBold, lowercase, tight. */
.logo { font-family: "Poppins", "Heebo", sans-serif; font-weight: 800; letter-spacing: -0.045em; }
