/*
VOICE: 推し活仲間の作業台。短く、迷わせない言葉。
IDEA: 公演前夜にうちわを作る机。主役は、ライトに照らされた実物大のうちわの見本。
PICTURE: 画面上部の大きなうちわの完成見本（客席のペンライトの光の粒つき）。
COLOUR and TYPE: 白い紙の上に、本人の推しカラーが差し色として全体に広がる。会場は深い紫。ロゴはうちわ文字そのもの（極太ゴシック＋二重のフチ）。
LAYOUT: スマホは「見本 → 言葉 → 調整 → 下の固定ボタン」の一列。広い画面は見本を左に固定、調整を右に。
*/
:root {
  color-scheme: light dark;
  --oshi: #ff4fa3;
  --accent: #ff4fa3;
  --on-accent: #ffffff;
  --bg: light-dark(#ffffff, #17121b);
  --ink: light-dark(#2a1d2e, #f4ecf6);
  --muted: light-dark(#76687c, #b7a9bc);
  --line: light-dark(rgba(42, 29, 46, 0.13), rgba(244, 236, 246, 0.16));
  --surface: light-dark(color-mix(in srgb, var(--accent) 7%, #ffffff), color-mix(in srgb, var(--accent) 12%, #17121b));
  --surface-2: light-dark(#f6f1f7, #221a27);
  --stage: #2a1f33;
  --radius: 18px;
  --shadow: 0 10px 30px -18px rgba(42, 29, 46, 0.55);
  --font: "Hiragino Maru Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", "Noto Sans JP", "Yu Gothic", system-ui, sans-serif;
}
:root[data-theme=light] { color-scheme: light; }
:root[data-theme=dark] { color-scheme: dark; }

* { box-sizing: border-box; min-width: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--font);
  overflow-x: clip;
  padding-bottom: calc(92px + env(safe-area-inset-bottom));
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
a { color: inherit; }

/* ---------- 上の帯 ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  max-width: 1240px; margin: 0 auto;
}
.logo { height: 40px; width: auto; display: block; flex: 0 1 auto; max-width: 46vw; object-fit: contain; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.pill {
  border: 0; border-radius: 999px; min-height: 40px; padding: 0 14px; white-space: nowrap; flex: none;
  background: var(--surface); color: var(--ink); font-weight: 700; font-size: 14px;
}
.pill.is-full { background: var(--accent); color: var(--on-accent); }
.icon-btn {
  width: 44px; height: 44px; border-radius: 999px; border: 0; background: transparent;
  display: grid; place-items: center;
}
.icon-btn svg { width: 24px; height: 24px; }

/* ---------- 作るものの切り替え ---------- */
.modes {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  max-width: 1240px; margin: 4px auto 12px; padding: 0 16px;
}
.modes button {
  border: 0; min-height: 48px; border-radius: 14px; background: var(--surface-2);
  font-weight: 700; font-size: 16px; color: var(--muted);
}
.modes button[aria-selected=true] { background: var(--ink); color: var(--bg); }

/* ---------- 作業スペース ---------- */
.workspace {
  max-width: 1240px; margin: 0 auto; padding: 0 16px;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px;
}
.stage-wrap { position: relative; }
.stage {
  width: 100%; aspect-ratio: 4 / 5; display: block;
  border-radius: 24px; background: var(--stage);
  box-shadow: var(--shadow);
  touch-action: manipulation;
}
.stage-meta {
  display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  font-size: 13px; color: var(--muted); padding: 8px 4px 0;
}
.trial {
  position: absolute; left: 12px; top: 12px; right: 12px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: rgba(23, 18, 27, 0.72); color: #fff; border-radius: 14px;
  padding: 8px 8px 8px 14px; font-size: 13px; backdrop-filter: blur(6px);
}
.trial button {
  border: 0; border-radius: 999px; min-height: 36px; padding: 0 14px;
  background: var(--oshi); color: #fff; font-weight: 700; font-size: 13px;
}

.controls { display: grid; gap: 14px; align-content: start; }
.field { display: grid; gap: 6px; }
.field > span { font-weight: 700; font-size: 15px; }
.field small { color: var(--muted); font-size: 13px; }
textarea, input[type=text], input[type=number] {
  width: 100%; border: 2px solid var(--line); border-radius: 16px; background: var(--bg);
  padding: 12px 14px; font-size: 20px; line-height: 1.4; resize: none;
}
textarea:focus, input[type=text]:focus, input[type=number]:focus { border-color: var(--accent); outline: none; }

.inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: 15px; cursor: pointer; }
.switch input { appearance: none; width: 46px; height: 28px; border-radius: 999px; background: var(--line); position: relative; margin: 0; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(18px); }

/* ---------- 調整のタブ ---------- */
.tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 4px; margin: 0 -2px;
  scrollbar-width: none; scroll-snap-type: x proximity;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: none; border: 2px solid var(--line); background: var(--bg); border-radius: 999px;
  min-height: 42px; padding: 0 16px; font-weight: 700; font-size: 14px; scroll-snap-align: start;
}
.tabs button[aria-selected=true] { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }

.panel { display: grid; gap: 14px; padding: 4px 0 8px; }
.panel h3 { margin: 4px 0 0; font-size: 15px; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.badge {
  display: inline-block; font-size: 11px; font-weight: 700; line-height: 1;
  padding: 4px 7px; border-radius: 999px; background: var(--ink); color: var(--bg); vertical-align: middle;
}

/* おまかせ */
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.preset {
  border: 2px solid transparent; border-radius: 16px; background: var(--surface-2); padding: 6px 6px 8px;
  display: grid; gap: 4px; justify-items: center; position: relative; font-size: 13px; font-weight: 700;
}
.preset canvas { width: 100%; aspect-ratio: 4 / 5; border-radius: 12px; display: block; }
.preset[aria-pressed=true] { border-color: var(--accent); }
.preset .badge { position: absolute; top: 10px; right: 10px; }

/* 書体 */
.fonts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.font {
  border: 2px solid var(--line); border-radius: 14px; background: var(--bg); padding: 8px 10px;
  display: grid; gap: 2px; text-align: left; position: relative;
}
.font img { width: 100%; height: 40px; object-fit: contain; object-position: left center; }
.font span { font-size: 12px; color: var(--muted); }
.font[aria-pressed=true] { border-color: var(--accent); background: var(--surface); }
.font .badge { position: absolute; bottom: 8px; right: 8px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme=light]) .font img { filter: invert(1) hue-rotate(180deg); } }
:root[data-theme=dark] .font img { filter: invert(1) hue-rotate(180deg); }

/* 色 */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 14px; }
.seg button { border: 0; min-height: 40px; border-radius: 10px; background: transparent; font-weight: 700; font-size: 14px; color: var(--muted); }
.seg button[aria-pressed=true] { background: var(--bg); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 8px; }
.sw {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); padding: 0;
  background: var(--c); position: relative; justify-self: center;
}
.sw[aria-pressed=true] { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--accent); }
.sw.custom { background: conic-gradient(#ff3045, #ffd21f, #18c27a, #38c9ff, #9b4dff, #ff4fa3, #ff3045); }
.sw.custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

/* フチ */
.layers { display: grid; gap: 10px; }
.layer {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center;
  background: var(--surface-2); border-radius: 16px; padding: 10px 12px;
}
.layer .name { font-weight: 700; font-size: 14px; white-space: nowrap; }
.layer .sw { width: 40px; height: 40px; }
.layer-colors { grid-column: 1 / -1; }
.mini-btn { border: 0; background: transparent; min-height: 40px; min-width: 40px; border-radius: 999px; color: var(--muted); font-size: 14px; font-weight: 700; }
.add-btn { border: 2px dashed var(--line); background: transparent; border-radius: 16px; min-height: 48px; font-weight: 700; }

input[type=range] { width: 100%; accent-color: var(--accent); min-height: 32px; }
.slider { display: grid; gap: 2px; }
.slider label { display: flex; justify-content: space-between; font-size: 14px; font-weight: 700; }
.slider output { color: var(--muted); font-weight: 400; }

/* 効果・飾り */
.toggles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.tog {
  border: 2px solid var(--line); border-radius: 14px; background: var(--bg); min-height: 56px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; font-weight: 700; font-size: 14px; text-align: left;
}
.tog[aria-pressed=true] { border-color: var(--accent); background: var(--surface); }
.tog svg { width: 26px; height: 26px; flex: none; }

/* ---------- 下の固定ボタン ---------- */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 10px;
  padding: 10px max(16px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.btn {
  border: 0; border-radius: 999px; min-height: 54px; padding: 0 18px; font-weight: 700; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.btn.primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 8px 20px -10px var(--accent); }
.btn.ghost { background: var(--surface-2); color: var(--ink); }
.btn.line { background: transparent; border: 2px solid var(--line); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.small { min-height: 44px; font-size: 14px; }

/* ---------- 下から出るシート ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(20, 12, 24, 0.5); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-height: 92vh; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 24px 24px 0 0;
  padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 -20px 50px -20px rgba(0,0,0,.4);
  animation: rise .22s ease-out;
}
@media (min-width: 720px) {
  .sheet { left: 50%; right: auto; bottom: 50%; transform: translate(-50%, 50%); width: min(640px, 92vw); border-radius: 24px; animation: none; }
}
@keyframes rise { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.sheet .grab { width: 44px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 10px; }
.sheet h2 { margin: 0 0 4px; font-size: 22px; line-height: 1.25; }
.sheet .lead { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.sheet-close { position: absolute; top: 10px; right: 10px; }
.stack { display: grid; gap: 10px; }
.thumbs { display: flex; gap: 10px; overflow-x: auto; padding: 4px 0 8px; scroll-snap-type: x mandatory; }
.thumbs img { height: 180px; width: auto; border-radius: 6px; border: 1px solid var(--line); background: #fff; scroll-snap-align: start; flex: none; }
.summary { font-size: 18px; font-weight: 700; margin: 4px 0; }
.note { background: var(--surface-2); border-radius: 14px; padding: 12px 14px; font-size: 14px; }
.note p { margin: 0 0 6px; }
.note p:last-child { margin: 0; }
details.note summary { font-weight: 700; cursor: pointer; min-height: 32px; }
.perks { display: grid; gap: 0; border: 2px solid var(--line); border-radius: 16px; overflow: hidden; margin: 4px 0 14px; }
.perks div { display: flex; justify-content: space-between; gap: 12px; padding: 11px 14px; font-size: 14px; }
.perks div + div { border-top: 1px solid var(--line); }
.perks b { white-space: nowrap; }
.price { font-size: 34px; font-weight: 800; line-height: 1.1; margin: 2px 0 2px; }
.price small { font-size: 14px; font-weight: 700; color: var(--muted); margin-left: 6px; }
.menu-list { display: grid; gap: 4px; }
.menu-list a, .menu-list button {
  display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 0 14px;
  border: 0; background: var(--surface-2); border-radius: 14px; text-decoration: none; font-weight: 700; font-size: 15px; text-align: left;
}
.saved { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.saved figure { margin: 0; display: grid; gap: 6px; }
.saved img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 12px; background: var(--stage); }
.saved .row { display: grid; grid-template-columns: 1fr auto; gap: 4px; }
.oshi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.oshi-grid button {
  border: 2px solid var(--line); border-radius: 16px; background: var(--bg); min-height: 76px;
  display: grid; justify-items: center; gap: 4px; padding: 8px 4px; font-size: 13px; font-weight: 700;
}
.oshi-grid button i { width: 32px; height: 32px; border-radius: 50%; background: var(--c); border: 2px solid var(--line); display: block; }
.oshi-grid button[aria-pressed=true] { border-color: var(--accent); }
.viewer-imgs { display: grid; gap: 12px; }
.viewer-imgs img { width: 100%; border-radius: 8px; border: 1px solid var(--line); background: #fff; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 999px; font-size: 14px; font-weight: 700;
  z-index: 60; max-width: calc(100vw - 32px); text-align: center; box-shadow: var(--shadow);
}
.busy {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(20, 12, 24, 0.45);
  color: #fff; font-weight: 700;
}
.busy div { background: var(--stage); padding: 18px 24px; border-radius: 18px; display: flex; gap: 12px; align-items: center; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 痛バ ---------- */
.itaba-canvas { width: 100%; aspect-ratio: 4 / 5; display: block; border-radius: 24px; background: var(--surface-2); box-shadow: var(--shadow); touch-action: manipulation; }
.count-line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.count-line b { font-size: 22px; }
.photo-row { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; }
.photo-row button { flex: none; width: 56px; height: 56px; border-radius: 50%; border: 2px solid var(--line); padding: 0; overflow: hidden; background: var(--surface-2); }
.photo-row button[aria-pressed=true] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--surface); }
.photo-row img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

footer {
  max-width: 1240px; margin: 28px auto 0; padding: 18px 16px 8px; color: var(--muted); font-size: 13px;
  display: flex; flex-wrap: wrap; gap: 6px 16px; border-top: 1px solid var(--line);
}
footer a { text-decoration: none; }

@media (min-width: 900px) {
  body { padding-bottom: 24px; }
  .workspace { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 32px; align-items: start; }
  .stage-wrap { position: sticky; top: 16px; }
  .actionbar { position: sticky; bottom: 0; max-width: 1240px; margin: 16px auto 0; border-radius: 22px 22px 0 0; }
  .toast { bottom: 32px; }
}
.sheet:focus { outline: none; }

@media (max-width: 380px) {
  .logo { height: 34px; }
  .pill { font-size: 13px; padding: 0 12px; }
  .top-actions { gap: 4px; }
}
