:root {
  --paper: #f8f8f4;
  --surface: #ffffff;
  --ink: #0f1512;
  --muted: #6a746f;
  --line: #dfe2dc;
  --line-strong: #c7ccc4;
  --go: #00c25a;
  --go-ink: #007a38;
  --go-wash: #e5f7ec;
  --wait: #b88700;
  --danger: #c4352b;
  --stage: #1a201c;
  color-scheme: light;
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Pretendard', 'Malgun Gothic', 'Noto Sans KR', sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
h1 { font-size: 1.6rem; margin: 0 0 12px; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
h3 { font-size: 0.95rem; margin: 18px 0 8px; }
a { color: var(--go-ink); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.danger { color: var(--danger); }
.loading { padding: 40px; color: var(--muted); }

button, .button {
  font: inherit; cursor: pointer; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  padding: 7px 14px; border-radius: 8px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .button:hover { border-color: var(--ink); }
button:disabled { opacity: 0.5; cursor: wait; }
button.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
button.link { border: 0; background: none; padding: 0; color: var(--go-ink); text-decoration: underline; }
button.link.danger { color: var(--danger); }
input, select, textarea {
  font: inherit; color: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface);
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--go); outline-offset: 1px; }
label { display: grid; gap: 4px; font-size: 0.9rem; }
label.check { display: flex; align-items: center; gap: 8px; }
label.check input { width: auto; }
progress { width: 100%; }

.top { display: flex; align-items: center; gap: 16px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.top a { text-decoration: none; color: inherit; }
.brand { font-weight: 700; display: inline-flex; align-items: center; gap: 8px; letter-spacing: -0.01em; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--go); display: inline-block; }
.top-title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top nav { display: flex; align-items: center; gap: 16px; font-size: 0.9rem; }
.who { color: var(--muted); }
.badge { margin-left: 10px; font-size: 0.75rem; font-weight: 500; padding: 2px 8px; border-radius: 99px; background: var(--go-wash); color: var(--go-ink); }

.center { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
.narrow { width: min(420px, 100%); display: grid; gap: 14px; }
.narrow h1 { margin: 0; }
.narrow p { margin: 0; }
.page { max-width: 1100px; margin: 0 auto; padding: 28px 20px 60px; }
.page.two { max-width: 1200px; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 28px; align-items: start; }
@media (max-width: 900px) { .page.two { grid-template-columns: 1fr; } }
.stack { display: grid; gap: 10px; }
.row { display: flex; gap: 8px; align-items: center; }
.row input { flex: 1; }
.inline-form { margin-top: 28px; display: grid; grid-template-columns: 2fr 1fr auto; gap: 10px; align-items: center; }
.inline-form h2 { grid-column: 1 / -1; margin: 0; }

.decks { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.decks a { text-decoration: none; color: inherit; }
.deck-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; transition: border-color 0.15s; }
.deck-card:hover { border-color: var(--ink); }
.deck-card img, .empty-thumb { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--paper); border-bottom: 1px solid var(--line); }
.empty-thumb { display: grid; place-items: center; color: var(--muted); font-size: 0.85rem; }
.deck-meta { padding: 12px 14px; display: grid; gap: 2px; }

.viewer { display: grid; grid-template-columns: 168px minmax(0, 1fr) auto; height: calc(100vh - 53px); }
.strip { list-style: none; margin: 0; padding: 12px 10px; overflow-y: auto; border-right: 1px solid var(--line); display: grid; gap: 10px; align-content: start; }
.strip button { padding: 0; border: 2px solid transparent; border-radius: 6px; width: 100%; display: grid; background: none; position: relative; }
.strip img { width: 100%; border-radius: 4px; display: block; aspect-ratio: 16 / 9; background: var(--line); }
.strip span { position: absolute; left: 4px; bottom: 2px; font-size: 0.7rem; color: var(--muted); background: rgba(255,255,255,0.85); padding: 0 4px; border-radius: 3px; }
.strip li.on button { border-color: var(--go); }
.view-main { display: grid; grid-template-rows: auto 1fr; min-width: 0; }
.toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.toolbar .spacer { flex: 1; }
.counter { font-variant-numeric: tabular-nums; color: var(--muted); }
.stage { position: relative; display: grid; place-items: center; padding: 24px; min-height: 0; background: var(--paper); }
.stage .slide { max-width: 100%; max-height: 100%; aspect-ratio: 16 / 9; object-fit: contain; box-shadow: 0 4px 24px rgba(15, 21, 18, 0.12); border-radius: 4px; background: #fff; cursor: pointer; user-select: none; }
.stage:fullscreen { background: #000; padding: 0; }
.stage:fullscreen .slide { box-shadow: none; border-radius: 0; width: 100vw; height: 100vh; }
.stage:fullscreen .nav { display: none; }
.nav { position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 64px; font-size: 1.8rem; justify-content: center; opacity: 0.0; transition: opacity 0.15s; background: rgba(255,255,255,0.9); }
.stage:hover .nav { opacity: 1; }
.nav.prev { left: 8px; }
.nav.next { right: 8px; }
.empty-stage { color: var(--muted); text-align: center; max-width: 360px; }
@media (max-width: 760px) {
  .viewer { grid-template-columns: minmax(0, 1fr); height: auto; }
  .strip { display: none; }
  .stage { padding: 8px; }
  .nav { opacity: 1; }
}

.panel { width: 380px; border-left: 1px solid var(--line); background: var(--surface); padding: 16px 18px 40px; overflow-y: auto; }
.panel[hidden] { display: none; }
@media (max-width: 760px) { .panel { position: fixed; inset: 53px 0 0 0; width: auto; z-index: 6; } }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.panel-head h2 { margin: 0; }
.grants, .versions, .mail-log { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.grants li, .versions li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.grants li strong { word-break: break-all; font-weight: 600; font-size: 0.9rem; }
.grants select { width: auto; padding: 4px 6px; }
.versions li { grid-template-columns: minmax(0, 1fr) auto; }
.versions li.current { background: var(--go-wash); margin: 0 -8px; padding: 8px; border-radius: 8px; }
.status { font-size: 0.75rem; padding: 1px 7px; border-radius: 99px; background: var(--paper); border: 1px solid var(--line); }
.status.ready { color: var(--go-ink); }
.status.converting, .status.uploading { color: var(--wait); }
.status.failed { color: var(--danger); border-color: var(--danger); }
.mail-log li { border-bottom: 1px solid var(--line); padding: 8px 0; }
.mail-log summary { cursor: pointer; }
.mail-log pre { white-space: pre-wrap; font: inherit; background: var(--paper); padding: 10px; border-radius: 8px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 20; box-shadow: 0 6px 24px rgba(0,0,0,0.2); }
.toast.error { background: var(--danger); }
