/* 即売会の値札メーカー
   紙モノの作業台がモチーフ。主役は「トンボ付きの値札プレビュー」で、それ以外は静かに。 */

:root {
  --ink: #172033;
  --muted: #5b667a;
  --desk: #e7ebf2;
  --dot: #c3ccdb;
  --panel: #ffffff;
  --line: #cdd5e2;
  --accent: #2447d6;
  --accent-ink: #ffffff;
  --accent-soft: #e4e9fb;
  --danger: #b4232a;
  --focus: #ff9f1c;
  --mark: #4a5470; /* トンボ */
  --ui: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e8ecf5;
    --muted: #9aa6bd;
    --desk: #12161e;
    --dot: #232a38;
    --panel: #1a202b;
    --line: #2e3748;
    --accent: #86a0ff;
    --accent-ink: #0d1530;
    --accent-soft: #232c4a;
    --danger: #ff8d92;
    --mark: #8d97b3;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  color: var(--ink);
  font: 15px/1.7 var(--ui);
  background-color: var(--desk);
  background-image: radial-gradient(var(--dot) 1px, transparent 1.3px);
  background-size: 22px 22px;
}

a { color: var(--accent); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- ヘッダー ---------- */
.top {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 16px 8px;
}
.top h1 {
  margin: 0 0 6px;
  font-size: clamp(24px, 4.4vw, 36px);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: .01em;
}
.lead {
  margin: 0;
  max-width: 44em;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- レイアウト ---------- */
.layout {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  grid-template-areas: "form stage";
  align-items: start;
}
.form  { grid-area: form; }
.stage { grid-area: stage; }

.stage {
  position: sticky;
  top: 12px;
  max-height: calc(100dvh - 24px);
  overflow: auto;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

@media (max-width: 860px) {
  .out-row select { flex-basis: 100%; }
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage" "form"; }
  .stage { position: static; max-height: none; overflow: visible; }
}

/* ---------- プレビュー ---------- */
.stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.count { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.tools { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

.desk {
  padding: 26px 26px 10px;
  background-color: var(--desk);
  background-image: radial-gradient(var(--dot) 1px, transparent 1.3px);
  background-size: 14px 14px;
  border-radius: 6px;
}

.paper {
  position: relative;
  background: #fff;
  box-shadow: 0 1px 0 rgba(23, 32, 51, .08), 0 8px 22px -10px rgba(23, 32, 51, .45);
}
.paper canvas { display: block; width: 100%; height: auto; }

/* トンボ（断裁位置の目印） */
.tk { position: absolute; width: 0; height: 0; pointer-events: none; }
.tk::before, .tk::after { content: ""; position: absolute; background: var(--mark); }
.tk.tl { left: 0; top: 0; }
.tk.tr { right: 0; top: 0; }
.tk.bl { left: 0; bottom: 0; }
.tk.br { right: 0; bottom: 0; }
.tk.tl::before { right: 6px; top: 0; width: 14px; height: 1px; }
.tk.tl::after  { left: 0; bottom: 6px; width: 1px; height: 14px; }
.tk.tr::before { left: 6px; top: 0; width: 14px; height: 1px; }
.tk.tr::after  { right: 0; bottom: 6px; width: 1px; height: 14px; }
.tk.bl::before { right: 6px; bottom: 0; width: 14px; height: 1px; }
.tk.bl::after  { left: 0; top: 6px; width: 1px; height: 14px; }
.tk.br::before { left: 6px; bottom: 0; width: 14px; height: 1px; }
.tk.br::after  { right: 0; top: 6px; width: 1px; height: 14px; }

.size { margin: 28px 0 0; text-align: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- 値札リスト ---------- */
.strip {
  display: flex;
  gap: 8px;
  margin: 12px 0 0;
  padding: 4px 2px 8px;
  list-style: none;
  overflow-x: auto;
  scroll-snap-type: x proximity;
}
.strip li { flex: 0 0 auto; scroll-snap-align: start; }

.thumb {
  display: block;
  width: 116px;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  overflow: hidden;
}
.thumb canvas { display: block; width: 100%; height: auto; }
.thumb[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.thumb:hover { border-color: var(--accent); }

.add {
  display: grid;
  place-items: center;
  width: 116px;
  height: 100%;
  min-height: 82px;
  border: 2px dashed var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.add:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 保存 ---------- */
.out { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.out-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.out-row label { font-size: 13px; color: var(--muted); }
.out-row select { flex: 1 1 14em; }
.actions { gap: 8px; }
.actions button { flex: 1 1 12em; }
.hint { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.hint a { margin-right: 1em; }

/* ---------- フォーム ---------- */
.form fieldset {
  margin: 0 0 16px;
  padding: 16px 16px 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.form legend { padding: 0 8px; font-weight: 700; font-size: 14px; }

.field { margin-bottom: 16px; }
.label-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 10px; margin-bottom: 6px; min-height: 30px; }
.label-row label, .label { font-weight: 600; font-size: 14px; white-space: nowrap; }
.label { display: block; margin-bottom: 6px; }
.muted { color: var(--muted); font-size: 11.5px; }
.field.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

input[type="text"], input[type="url"], textarea, select {
  width: 100%;
  padding: 9px 11px;
  color: var(--ink);
  font: inherit;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
}
input[type="text"]:focus, input[type="url"]:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 5.6em; }
select { background: var(--panel); }

input[type="color"] {
  width: 44px;
  height: 30px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  cursor: pointer;
}
.field.two input[type="color"] { width: 100%; height: 38px; }

input[type="range"] { width: 100%; accent-color: var(--accent); }
output { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.range-note { margin: 4px 0 0; }

.error { margin: 6px 0 0; font-size: 12.5px; color: var(--danger); }
.font-state { font-size: 12px; color: var(--muted); }

/* 中央/左 切り替え */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: block; padding: 7px 18px; font-size: 14px; cursor: pointer; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }

.fonts-credit { margin: 0 0 16px; font-size: 12.5px; color: var(--muted); }
.fonts-credit summary { cursor: pointer; }
.fonts-credit ul { margin: 8px 0 0; padding-left: 1.2em; }
.fonts-credit li { margin-bottom: 4px; }

/* ---------- ボタン ---------- */
button { font: inherit; }
.primary, .secondary {
  padding: 11px 16px;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid var(--accent);
}
.primary { background: var(--accent); color: var(--accent-ink); }
.secondary { background: transparent; color: var(--accent); }
.primary:hover { filter: brightness(1.08); }
.secondary:hover { background: var(--accent-soft); }
button:disabled { opacity: .55; cursor: progress; }

.ghost {
  padding: 4px 10px;
  color: var(--ink);
  font-size: 13px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.ghost.danger:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }

.linkish { padding: 0; color: var(--muted); font-size: 12.5px; text-decoration: underline; background: none; border: 0; cursor: pointer; }

/* ---------- フッター ---------- */
.foot { max-width: 1120px; margin: 0 auto; padding: 8px 16px 40px; color: var(--muted); font-size: 13px; }
.foot p { margin: 4px 0; }
.share { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-bottom: 6px; }

/* ---------- トースト ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  color: #fff;
  font-size: 14px;
  background: #1f2840;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  transform: translateX(-50%);
}
.toast[hidden] { display: none; }
.toast button { padding: 2px 6px; color: #ffd27a; font-weight: 700; background: none; border: 0; cursor: pointer; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
