:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --text: #1d232b;
  --muted: #6a7280;
  --line: #e3dfd6;
  --accent: #e8833a;
  --accent-ink: #ffffff;
  --danger: #c43d3d;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 24, 31, .06), 0 6px 20px rgba(20, 24, 31, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181d;
    --surface: #1e2229;
    --text: #e9e6df;
    --muted: #9aa2ae;
    --line: #2e333c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}
a { color: inherit; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1100px; margin: 0 auto; padding: 18px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; font-size: 18px; }
.topbar nav a { text-decoration: none; color: var(--muted); }
.topbar nav a:hover { color: var(--text); }
.topnav { display: flex; align-items: center; gap: 12px; }
.topnav .who { color: var(--muted); font-size: 13px; }
.topnav .btn { padding: 5px 10px; font-size: 13px; }

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

.hero { text-align: center; padding: 36px 0 24px; }
.hero h1 { font-size: clamp(28px, 5vw, 44px); line-height: 1.2; margin: 0 0 12px; letter-spacing: -.02em; }
.hero > p { max-width: 560px; margin: 0 auto 28px; color: var(--muted); }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  max-width: 640px; margin: 0 auto; padding: 40px 20px;
  border: 2px dashed var(--line); border-radius: 18px; background: var(--surface);
  cursor: pointer; transition: border-color .15s, background .15s; color: var(--muted);
}
.dropzone strong { color: var(--text); }
.dropzone:hover, .dropzone:focus-visible, .dropzone.over { border-color: var(--accent); outline: none; }
.dropzone.over { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }

.upload-panel {
  max-width: 640px; margin: 18px auto 0; padding: 18px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.upload-row { display: flex; gap: 16px; }
.upload-cover { width: 96px; height: auto; max-height: 140px; object-fit: contain; border-radius: 4px; box-shadow: var(--shadow); background: #fff; flex: none; }
.upload-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); flex: 1; }
.field input[type=text], .field select, .field textarea, .copy-row input {
  font: inherit; font-size: 15px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
}
.field textarea { resize: none; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.field input[type=color] { width: 100%; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.field-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 6px; padding-bottom: 8px; font-size: 14px; }
.copy-row { display: flex; gap: 8px; align-items: stretch; }

.btn {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 8px; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.primary:disabled { opacity: .6; cursor: default; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; padding: 32px 0; }
.features div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.features h3 { margin: 0 0 6px; font-size: 16px; }
.features p { margin: 0; color: var(--muted); font-size: 14px; }

.library { padding: 16px 0 48px; }
.library-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.library-head h2 { margin: 0 0 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.card .thumb { display: block; aspect-ratio: 3 / 4; background: color-mix(in srgb, var(--line) 60%, var(--bg)); position: relative; }
.card .thumb img { position: absolute; inset: 12px; width: calc(100% - 24px); height: calc(100% - 24px); object-fit: contain; filter: drop-shadow(0 4px 10px rgba(0,0,0,.18)); }
.card .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; }
.card .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .meta { font-size: 12px; }
.card .actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.card .actions .btn { padding: 5px 9px; font-size: 12px; }
.card.missing { opacity: .6; }
.card .paid-badge { position: absolute; top: 8px; right: 8px; z-index: 1; padding: 2px 8px; border-radius: 99px; background: #1f9d55; color: #fff; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.empty { text-align: center; padding: 30px 0; }

.foot { text-align: center; padding: 24px 16px 32px; font-size: 13px; }

.dlg { border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: min(480px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.dlg::backdrop { background: rgba(10, 12, 16, .45); }
.dlg h3 { margin: 0 0 14px; }
.dlg form { display: flex; flex-direction: column; gap: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: #1d232b; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px;
  transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100vw - 32px); z-index: 90;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); }

@media (max-width: 520px) {
  .upload-row { flex-direction: column; }
  .upload-cover { align-self: center; }
}
