/* 落書きペン: 共通の見た目（shinotools のサイトに合わせる: 白・紫 #6953a9・細い線・角丸。フォントは同梱しない） */
:root {
  --bg: #fff;
  --ink: #292d40;
  --sub: #62687c;
  --line: #e7e9ef;
  --field: #aeb4c3;
  --accent: #6953a9;
  --accent-pale: #f3f0fc;
  --warn: #a84c70;
  --warn-pale: #fff1f5;
  --ok: #2f7d5b;
  --stage: #2b2e3a;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Zen Maru Gothic', 'Hiragino Maru Gothic ProN', 'Yu Gothic', 'YuGothic', sans-serif;
  font-size: 15px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}
a { color: var(--accent); text-underline-offset: 4px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .45; }
input, select { min-height: 42px; border: 1px solid var(--field); border-radius: 4px; background: #fff; padding: 6px 10px; max-width: 100%; }
input[type=checkbox] { min-height: 0; width: 18px; height: 18px; accent-color: var(--accent); margin: 0; flex: none; }
input[type=range] { min-height: 0; border: 0; padding: 0; accent-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, h3 { font-weight: 500; line-height: 1.5; }
[hidden] { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 8px 16px;
  border: 1px solid var(--accent); border-radius: 4px;
  background: var(--accent); color: #fff; font-weight: 500; text-decoration: none; white-space: nowrap;
}
.btn:hover:not(:disabled) { filter: brightness(.94); }
.btn.secondary { background: #fff; color: var(--accent); }
.btn.secondary[aria-pressed=true] { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.small { min-height: 34px; padding: 4px 12px; font-size: 14px; }
.btn.danger { color: var(--warn); border-color: var(--warn); }
.btn.wide { width: 100%; }

.note { font-size: 13px; color: var(--sub); line-height: 1.8; margin: 6px 0; }
.warn { font-size: 13px; color: var(--warn); background: var(--warn-pale); border-radius: 4px; padding: 8px 10px; margin: 8px 0; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand-bars { display: inline-flex; gap: 3px; }
.brand-bars i { display: block; width: 4px; height: 15px; background: #d2c8eb; }
.brand-bars i:nth-child(2) { background: #f0c6d6; }
.brand-bars i:nth-child(3) { background: #bfd4ee; }

/* 小さなお知らせ */
.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  max-width: min(92vw, 520px); padding: 10px 16px; border-radius: 6px;
  background: var(--ink); color: #fff; font-size: 14px; z-index: 50;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .18); pointer-events: none;
}

/* ===== トップ ===== */
.top { max-width: 760px; margin: 0 auto; padding: 0 24px 60px; }
.top header { padding: 26px 0; border-bottom: 1px solid var(--line); }
.top .brand { font-size: 22px; }
.top h1 { font-size: 28px; margin: 36px 0 10px; }
.top .lead { color: var(--sub); font-size: 16px; margin: 0 0 26px; }
.top h2 { font-size: 19px; margin: 40px 0 12px; }
.steps { padding-left: 1.5em; margin: 8px 0; }
.steps li { margin: 10px 0; padding-left: 4px; }
.steps li::marker { color: var(--accent); font-weight: 500; }

/* ===== 書く画面 ===== */
body.pen-page { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.bar { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); min-height: 56px; flex-wrap: wrap; }
.bar .spacer { flex: 1; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--sub); white-space: nowrap; }
.pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #c9ccd6; }
.pill.on::before { background: var(--ok); }
.pill.bad::before { background: var(--warn); }
.layout { flex: 1; min-height: 0; display: flex; }
.stage-area { flex: 1; min-width: 0; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 12px; background: #f6f6f9; }
.stage { position: relative; width: 640px; height: 360px; background: var(--stage); border-radius: 6px; overflow: hidden; box-shadow: 0 0 0 1px var(--line); }
.stage img, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage img { object-fit: contain; -webkit-user-drag: none; user-select: none; pointer-events: none; }
.stage canvas { touch-action: none; cursor: crosshair; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.stage .bg-note { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; color: #c8cbd6; font-size: 14px; pointer-events: none; }
.stage .bg-note strong { color: #fff; font-weight: 500; font-size: 16px; }
.stage .bg-note.dim { opacity: .3; }
.stage .tags { position: absolute; left: 10px; top: 10px; display: flex; gap: 6px; pointer-events: none; }
.stage .tag { font-size: 12px; padding: 2px 10px; border-radius: 999px; background: rgba(255, 255, 255, .92); color: var(--ink); }
.stage .tag.hide { background: var(--warn); color: #fff; }
.stage .flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .35s; }
.stage .flash.on { opacity: .85; transition: none; }

.tools { width: 300px; flex: none; border-left: 1px solid var(--line); overflow-y: auto; padding: 10px 14px 18px; }
.tool-group { padding: 10px 0; border-bottom: 1px solid var(--line); }
.tool-group:last-child { border-bottom: 0; }
.tool-label { font-size: 13px; color: var(--sub); margin-bottom: 6px; display: flex; justify-content: space-between; }
.pens { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pen-btn { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 4px 2px 2px; border: 1px solid var(--line); border-radius: 6px; background: #3a3d4a; color: #fff; font-size: 12px; line-height: 1.6; }
.pen-btn canvas { width: 100%; height: 26px; display: block; }
.pen-btn[aria-pressed=true] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.colors { display: grid; grid-template-columns: repeat(auto-fill, minmax(32px, 1fr)); gap: 6px; }
.swatch { aspect-ratio: 1; min-height: 30px; max-height: 44px; border-radius: 50%; border: 1px solid #c9ccd6; padding: 0; }
.swatch[aria-pressed=true] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }
.swatch.custom { position: relative; overflow: hidden; background: conic-gradient(#ff5f5f, #ffe14d, #3ddc84, #33d1ff, #4a6cff, #ff5fa2, #ff5f5f); }
.swatch.custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }
.size-row { display: flex; align-items: center; gap: 10px; }
.size-row input { flex: 1; }
.size-dot { flex: none; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; background: #3a3d4a; border-radius: 6px; }
.size-dot i { display: block; border-radius: 50%; background: #fff; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--accent); border-radius: 4px; overflow: hidden; }
.seg button { min-height: 38px; border: 0; border-left: 1px solid var(--accent); background: #fff; color: var(--accent); font-size: 14px; padding: 4px 2px; }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed=true] { background: var(--accent); color: #fff; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .span2 { grid-column: span 2; }
.btn.shoot { min-height: 50px; font-size: 16px; }

/* 設定（右から出る板） */
.sheet-back { position: fixed; inset: 0; background: rgba(41, 45, 64, .28); z-index: 20; }
.sheet { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); background: #fff; z-index: 21; overflow-y: auto; padding: 0 20px 40px; border-left: 1px solid var(--line); -webkit-overflow-scrolling: touch; }
.sheet-head { position: sticky; top: 0; background: #fff; display: flex; align-items: center; gap: 10px; padding: 14px 0 10px; border-bottom: 1px solid var(--line); z-index: 1; }
.sheet-head h2 { margin: 0; font-size: 18px; flex: 1; }
.sheet section { padding: 14px 0 6px; border-bottom: 1px solid var(--line); }
.sheet section:last-child { border-bottom: 0; }
.sheet h3 { font-size: 16px; margin: 4px 0 6px; }
.field { display: block; margin: 10px 0; font-size: 13px; color: var(--sub); }
.field input, .field select { display: block; width: 100%; margin-top: 3px; color: var(--ink); font-size: 15px; }
.check { display: flex; align-items: flex-start; gap: 8px; margin: 10px 0; font-size: 14px; line-height: 1.6; }
.check input { margin-top: 2px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.copy-row { display: flex; gap: 6px; margin: 8px 0; }
.copy-row input { flex: 1; min-width: 0; font-size: 13px; color: var(--sub); }
.status-line { font-size: 14px; margin: 6px 0; }
.status-line.ok { color: var(--ok); }
.status-line.bad { color: var(--warn); }

/* 画像ができたとき */
.saved { position: fixed; inset: 0; z-index: 30; background: rgba(41, 45, 64, .5); display: flex; align-items: center; justify-content: center; padding: 16px; }
.saved-box { background: #fff; border-radius: 6px; padding: 16px; width: min(760px, 100%); max-height: 100%; overflow: auto; }
.saved-text { margin: 0 0 10px; }
.saved-box img { width: 100%; height: auto; display: block; border-radius: 4px; background: #3a3d4a; }

@media (max-width: 820px), (max-aspect-ratio: 1/1) {
  .layout { flex-direction: column; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .stage-area { flex: none; padding: 8px; }
  .tools { width: auto; border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .pens { grid-template-columns: repeat(8, 1fr); }
  .bar { padding: 6px 10px; min-height: 48px; gap: 8px; }
}
@media (max-width: 560px) {
  .pens { grid-template-columns: repeat(4, 1fr); }
  .bar .brand-text { display: none; }
  .bar .btn.small { padding: 4px 8px; font-size: 13px; }
}
