.roto-main { max-width: 1200px; margin: 0 auto; padding: 96px 16px 48px; }
.roto-title { font-size: 1.8rem; margin-bottom: 8px; }
.roto-lead { opacity: .8; margin-bottom: 16px; line-height: 1.7; }

.roto-toolbar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 12px; }
.roto-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.roto-btn { min-height: 44px; padding: 8px 14px; border-radius: 8px; border: 1px solid rgba(128,128,128,.4); background: transparent; color: inherit; font: inherit; cursor: pointer; }
.roto-btn:disabled { opacity: .4; cursor: default; }
.roto-tool.is-active { background: #3b6ef5; border-color: #3b6ef5; color: #fff; }
.roto-primary { background: #3b6ef5; border-color: #3b6ef5; color: #fff; }


.roto-stage { position: relative; height: 70vh; min-height: 360px; overflow: hidden; border-radius: 10px; background: #e9e9e9; touch-action: none; user-select: none; -webkit-user-select: none; }
.roto-canvas-wrap { position: absolute; left: 0; top: 0; transform-origin: 0 0; background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.15); }
.roto-canvas-wrap canvas { position: absolute; left: 0; top: 0; display: block; }
.roto-canvas-wrap canvas[hidden] { display: none; }
.roto-onion { opacity: .35; }
.roto-btn.is-active { background: #3b6ef5; border-color: #3b6ef5; color: #fff; }
.roto-stage[data-tool="pen"] { cursor: crosshair; }
.roto-stage.has-image[data-tool="eraser"] { cursor: none; }
.roto-cursor { position: absolute; pointer-events: none; border: 1.5px solid #3b6ef5; border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 0 1px rgba(255,255,255,.8); }
.roto-cursor[hidden] { display: none; }
.roto-cursor[data-tool="eraser"] { border-color: #e5484d; background: rgba(229,72,77,.12); }
.roto-cursor.is-preview { border-width: 2px; }
.roto-tool .roto-dot { display: inline-block; width: 14px; height: 14px; margin-right: 6px; vertical-align: -2px; border-radius: 50%; border: 1.5px solid currentColor; }
.roto-stage.is-panning { cursor: grab; }
.roto-drop { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; color: #555; padding: 16px; text-align: center; cursor: pointer; }
.roto-drop[hidden] { display: none; }
.roto-resume { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 2; background: #fff; color: #222; white-space: nowrap; }
.roto-resume[hidden], .has-image .roto-resume { display: none; }
.roto-drop input, .roto-file-small input { display: none; }
.roto-drop-btn { padding: 14px 28px; border-radius: 10px; background: #3b6ef5; color: #fff; font-size: 1.1rem; font-weight: bold; }
.roto-stage.is-dragover { outline: 3px dashed #3b6ef5; outline-offset: -8px; }
.roto-toolbar[hidden] { display: none; }
.roto-slider { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.roto-slider input { width: 120px; }
.roto-icon { font-size: 1.2rem; padding: 6px 12px; line-height: 1; min-width: 44px; }
.roto-save { position: relative; }
.roto-save-menu { position: absolute; top: 100%; left: 0; margin-top: 6px; display: flex; flex-direction: column; gap: 6px; padding: 8px; border-radius: 10px; background: #fff; color: #222; box-shadow: 0 4px 16px rgba(0,0,0,.2); z-index: 5; white-space: nowrap; }
.roto-save-menu[hidden], .roto-save-menu [hidden] { display: none; }
.roto-stage.is-busy { opacity: .7; pointer-events: none; }
.roto-file-small { cursor: pointer; }
.roto-more { display: contents; }
.roto-more-btn, .roto-back { display: none; }

.roto-framebar { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.roto-framebar[hidden] { display: none; }
.roto-framebar input { flex: 1; min-width: 0; }
.roto-frame-label { white-space: nowrap; font-variant-numeric: tabular-nums; min-width: 5.5em; text-align: right; }
.roto-slider[hidden] { display: none; }
.roto-slider input.roto-num { width: 3.5em; flex: 0 0 auto; padding: 2px 4px; font: inherit; }
.roto-status { min-height: 1.5em; margin-top: 8px; opacity: .8; }
.roto-help { margin-top: 16px; }
.roto-help summary { cursor: pointer; font-weight: bold; }
.roto-help ul { margin-top: 8px; padding-left: 1.2em; line-height: 1.8; }
/* スマホ：片手の親指が届く画面下にツールとコマ送りをまとめ、上を描く場所にする */
@media (max-width: 600px) {
  .roto-main { padding-bottom: calc(var(--dock-h, 0px) + 16px); }
  .roto-stage { height: calc(100dvh - 150px - var(--dock-h, 0px)); min-height: 260px; }
  /* 読み込み後は見出しを隠し、描く場所を広げる */
  .roto-main.has-file { padding-top: 12px; }
  .roto-main.has-file .roto-title { display: none; }
  .roto-main.has-file .roto-stage { height: calc(100dvh - 88px - var(--dock-h, 0px)); }
  .roto-toolbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; margin: 0; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); gap: 6px 10px; background: #111827; color: #f3f4f6; box-shadow: 0 -2px 12px rgba(0,0,0,.3); }
  .roto-framebar { position: fixed; left: 0; right: 0; bottom: var(--toolbar-h, 0px); z-index: 20; margin: 0; padding: 6px 12px; background: #111827; color: #f3f4f6; border-bottom: 1px solid rgba(255,255,255,.1); }
  .roto-save-menu { top: auto; bottom: 100%; margin: 0 0 6px; }
  .roto-slider { flex: 1 1 40%; }
  .roto-slider input { width: auto; flex: 1; min-width: 0; height: 32px; }
  .roto-framebar input { height: 32px; }
  .roto-lead { display: none; }
  /* 読み込み後はサイトのヘッダを隠し、左上の ← で戻る */
  body.has-file .header { display: none; }
  .roto-main.has-file { padding: 0 0 calc(var(--dock-h, 0px) + 16px); }
  .roto-main.has-file .roto-stage { height: calc(100dvh - var(--dock-h, 0px)); border-radius: 0; }
  .roto-main.has-file .roto-back { display: flex; position: absolute; left: 10px; top: calc(10px + env(safe-area-inset-top)); z-index: 3; width: 44px; height: 44px; align-items: center; justify-content: center; border-radius: 50%; background: rgba(17,24,39,.75); color: #fff; font-size: 1.3rem; text-decoration: none; }
  /* 1段目：ツール・取り消し・保存・⚙。他は ⚙ のパネルへ */
  .roto-toolbar { flex-wrap: nowrap; gap: 4px; }
  .roto-toolbar > .roto-tools { gap: 4px; flex-wrap: nowrap; }
  .roto-toolbar > .roto-tools:first-child { flex: 1; min-width: 0; }
  .roto-toolbar > .roto-tools:first-child .roto-tool { flex: 1; min-width: 0; padding: 0 1px; font-size: .78rem; white-space: nowrap; overflow: hidden; }
  .roto-tool .roto-dot { display: none; }
  .roto-icon { min-width: 40px; padding: 0 4px; }
  .roto-save .roto-btn { padding: 0 10px; }
  .roto-more-btn { display: inline-block; }
  .roto-more { display: none; position: fixed; left: 0; right: 0; bottom: var(--dock-h, 0px); z-index: 22; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px; background: #1f2937; color: #f3f4f6; box-shadow: 0 -4px 16px rgba(0,0,0,.35); }
  .roto-more.is-open { display: flex; }
  /* 状態表示は描く場所の上に重ねる */
  .roto-main.has-file .roto-status { position: fixed; top: calc(14px + env(safe-area-inset-top)); left: 64px; right: 12px; z-index: 3; margin: 0; padding: 6px 10px; border-radius: 8px; background: rgba(17,24,39,.75); color: #fff; font-size: .85rem; opacity: 1; pointer-events: none; min-height: 0; }
  .roto-main.has-file .roto-status:empty { display: none; }
  .roto-more [hidden] { display: none; }
}
@media (max-width: 360px) {
  .roto-toolbar { padding-left: 6px; padding-right: 6px; gap: 3px; }
  .roto-toolbar > .roto-tools { gap: 3px; }
  .roto-toolbar > .roto-tools:first-child .roto-tool { font-size: .7rem; padding: 0; letter-spacing: -.05em; }
  .roto-icon { min-width: 36px; padding: 0 4px; }
  .roto-save .roto-btn { padding: 0 8px; }
}
/* 読み込み後：画面全体を描く場所にする。ヘッダ・見出し・説明は隠し、ボタンとスライダーは右上の ☰ で開くパネルにまとめる */
.roto-panel-btn, .roto-home { display: none; }
body.has-file .header, .roto-main.has-file .roto-title, .roto-main.has-file .roto-lead, .roto-main.has-file .roto-help { display: none; }
.roto-main.has-file { max-width: none; padding: 0; }
.roto-main.has-file .roto-stage { position: fixed; inset: 0; z-index: 10; height: auto; min-height: 0; border-radius: 0; }
.roto-main.has-file .roto-panel-btn { display: flex; position: fixed; top: calc(8px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); z-index: 30; width: 40px; height: 40px; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: rgba(17,24,39,.6); color: #fff; font-size: 1.2rem; cursor: pointer; }
.roto-main.has-file .roto-panel-btn.is-active { background: #3b6ef5; }
.roto-main.has-file .roto-panel { display: none; position: fixed; top: calc(56px + env(safe-area-inset-top)); right: 8px; z-index: 29; width: min(560px, calc(100vw - 16px)); max-height: calc(100dvh - 72px); overflow-y: auto; padding: 12px; border-radius: 12px; background: rgba(17,24,39,.94); color: #f3f4f6; box-shadow: 0 6px 24px rgba(0,0,0,.4); }
.roto-main.has-file .roto-panel.is-open { display: flex; flex-direction: column; gap: 10px; }
.roto-main.has-file .roto-panel .roto-toolbar, .roto-main.has-file .roto-panel .roto-framebar { position: static; margin: 0; padding: 0; background: none; box-shadow: none; border: 0; flex-wrap: wrap; gap: 8px; }
.roto-main.has-file .roto-panel .roto-toolbar[hidden], .roto-main.has-file .roto-panel .roto-framebar[hidden] { display: none; }
.roto-main.has-file .roto-panel .roto-more-btn { display: none; }
.roto-main.has-file .roto-panel .roto-more { display: flex; position: static; flex-wrap: wrap; gap: 10px 14px; padding: 0; background: none; box-shadow: none; width: 100%; }
.roto-main.has-file .roto-panel .roto-more [hidden] { display: none; }
.roto-main.has-file .roto-panel .roto-slider { flex: 1 1 45%; }
.roto-main.has-file .roto-panel .roto-slider input[type=range] { width: auto; flex: 1; min-width: 0; }
.roto-main.has-file .roto-panel .roto-tool { flex: 0 0 auto; font-size: 1rem; padding: 8px 14px; }
.roto-main.has-file .roto-panel .roto-tool .roto-dot { display: inline-block; }
.roto-main.has-file .roto-panel .roto-save-menu { top: 100%; bottom: auto; margin: 6px 0 0; }
.roto-main.has-file .roto-home { display: inline-flex; align-items: center; align-self: flex-start; text-decoration: none; }
.roto-main.has-file .roto-status { position: fixed; top: calc(14px + env(safe-area-inset-top)); left: 12px; right: 60px; z-index: 20; margin: 0; padding: 6px 10px; border-radius: 8px; background: rgba(17,24,39,.75); color: #fff; font-size: .85rem; opacity: 1; pointer-events: none; min-height: 0; }
.roto-main.has-file .roto-status:empty { display: none; }
.roto-main.has-file .roto-panel .roto-slider input[type=checkbox] { width: auto; height: auto; flex: 0 0 auto; }
/* エラー：状態表示と同じ場所に、選択・コピーできる形で出す */
.roto-error { margin-top: 8px; padding: 10px; border-radius: 8px; background: #7f1d1d; color: #fff; }
.roto-error[hidden] { display: none; }
.roto-error-text { margin: 0 0 8px; max-height: 40vh; overflow: auto; white-space: pre-wrap; word-break: break-all; font-size: .8rem; line-height: 1.5; user-select: text; -webkit-user-select: text; }
.roto-error-btns { display: flex; gap: 8px; justify-content: flex-end; }
.roto-error .roto-btn { border-color: rgba(255,255,255,.5); color: #fff; }
.roto-main.has-file .roto-error { position: fixed; top: calc(8px + env(safe-area-inset-top)); left: 12px; right: 60px; z-index: 31; margin: 0; }
