/* Baorie Studio — SketchUp-like light UI; manga mode switches to an ABLUR-like dark palette. */
:root {
  --bg: #e9e9e9; --panel: #f6f6f6; --panel2: #ffffff; --ink: #1d1d1f; --muted: #6b6b70; --line: #cfcfcf;
  --accent: #1a5cff; --accent-ink: #ffffff; --hover: #dde6ff; --menu: #fbfbfb; --bar: #ececec; --vp: #ffffff;
  --danger: #c0392b;
  color-scheme: light;
}
body[data-mode="manga"] {
  --bg: #202020; --panel: #282828; --panel2: #303030; --ink: #ececec; --muted: #9a9aa3; --line: #3b3b3b;
  --accent: #4e4eff; --accent-ink: #ffffff; --hover: #33335a; --menu: #2c2c2c; --bar: #1c1c1c;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
/* Android の Chrome：画面を下に引いて「更新」（ページの開き直し）をしない（2026-10-28 Galaxy で作業中に開き直しが続いた。js/crash_guard.js） */
html, body { overscroll-behavior: none; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 12.5px/1.45 system-ui, "Yu Gothic UI", "Hiragino Sans", "Meiryo", sans-serif;
  display: grid; grid-template-rows: 30px 40px minmax(0, 1fr) 28px; height: 100vh; overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }

/* 窓の題の帯（見込み 2-A＋≡・Windows のデスクトップ版だけ・js/titlebar.js）：帯は上に固定し、body を帯の高さ（--tb-h）だけ下げる。
   body の行（grid-template-rows）は今のまま。上からの位置を決めて置く物（右の欄・引き出しなど）は --tb-h を足す。
   数はモック（topbar_mock_1118.html の .wmerge）から：高さ 32・左の空き 4・間 6・≡ 34×26（角 5・字 17px）・地 #f3f3f3・題の字 12px #1b1b1b */
body { --tb-h: 0px; }
body.has-titlebar { --tb-h: 32px; margin-top: var(--tb-h); height: calc(100vh - var(--tb-h)); }
@supports (height: 100dvh) { body.has-titlebar { height: calc(100dvh - var(--tb-h)); } }
#titlebar { position: fixed; z-index: 1500; top: 0; left: env(titlebar-area-x, 0px); width: env(titlebar-area-width, calc(100vw - 138px)); height: var(--tb-h);
  display: flex; align-items: center; gap: 6px; padding-left: 4px; background: #f3f3f3; color: #1b1b1b;
  font: 12px "Segoe UI", "Yu Gothic UI", system-ui, sans-serif; -webkit-app-region: drag; app-region: drag; user-select: none; }
#titlebar .tb-ham { flex: none; width: 34px; height: 26px; border: 0; border-radius: 5px; background: transparent; font-size: 17px; line-height: 1; color: #333;
  cursor: pointer; -webkit-app-region: no-drag; app-region: no-drag; padding: 0; }
#titlebar .tb-ham:hover, #titlebar .tb-ham.open { background: #e2e2e2; }
#titlebar .tb-title { flex: 0 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 12px; }
body[data-mode="manga"] #titlebar { background: #1c1c1c; color: #e6e6e6; }
body[data-mode="manga"] #titlebar .tb-ham { color: #e6e6e6; }
body[data-mode="manga"] #titlebar .tb-ham:hover, body[data-mode="manga"] #titlebar .tb-ham.open { background: #333; }
/* 自分の AI 接続のボタン（顔の絵）：段 2 の［AIに頼む］の隣（js/menubar_ai.js）。段 2 の高さ 30 に入る 28×26（モックの数） */
#menubar .tb.mb-ai { width: 28px; height: 26px; margin-left: 4px; }
#menubar .tb.mb-ai svg { width: 18px; height: 18px; }
/* 漫画レンダーの暗い時：帯の絵を反転する決まり（下の body[data-mode="manga"] .tb svg）だと顔の地が暗くなって見えないので、明るい時の顔のまま */
body[data-mode="manga"] #menubar .tb.mb-ai { color: #1d1d1f; }
body[data-mode="manga"] #menubar .tb.mb-ai svg { filter: none; }
/* 題の札（#docTitle）：デスクトップ版は窓の題に同じ字が出るので出さない（T5） */
body.desk-title #docTitle { display: none !important; }

/* menubar */
#menubar { display: flex; align-items: center; gap: 2px; padding: 0 8px; background: var(--menu); border-bottom: 1px solid var(--line); min-width: 0; }
#menubar .logo { display: flex; align-items: center; flex: none; margin-right: 8px; line-height: 0; }
#menubar .logo img { height: 22px; width: auto; display: block; }
/* logo variants: the light one on the SketchUp-like UI, the onDark one in manga mode */
.logo-dark { display: none !important; }
body[data-mode="manga"] .logo-dark { display: block !important; }
body[data-mode="manga"] .logo-light { display: none !important; }
.about-logo { margin: 2px 0 6px; line-height: 0; }
.about-logo img { height: 64px; width: auto; max-width: 100%; }
@media (max-width: 900px) { #menubar .logo { max-width: 26px; overflow: hidden; } } /* narrow screens: just the BAORIE mark */
#menubar .menus { display: flex; gap: 0; flex: none; }
/* narrow screens (js/menubar_fit.js): the chips at the right fold into 「⋯」; the menus never shrink away */
#menubar { overflow: hidden; }
#menubar.tight .menus { flex: 0 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
#menubar.tight .menus::-webkit-scrollbar { display: none; }
#menubar > *:not(.menus):not(.logo) { flex-shrink: 0; }
#menubar > #docTitle { flex-shrink: 1; min-width: 60px; }
.bar-more { flex: none; margin-left: 6px; border: 1px solid var(--line); background: var(--panel2); color: var(--ink); border-radius: 6px; min-width: 30px; height: 24px; padding: 0 6px; cursor: pointer; font-size: 15px; line-height: 1; }
.bar-more:hover, .bar-more.open { border-color: var(--accent); color: var(--accent); }
.bar-more[hidden] { display: none; }
.bar-more-panel { position: fixed; z-index: 1001; display: flex; flex-direction: column; align-items: stretch; gap: 6px; min-width: 220px; max-width: min(340px, calc(100vw - 8px)); max-height: calc(100vh - 60px); overflow-y: auto;
  padding: 8px; background: var(--menu); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.bar-more-panel[hidden] { display: none; }
.bar-more-panel > * { margin: 0 !important; max-width: none !important; text-align: left; justify-content: flex-start; }
.bar-more-panel > #docTitle { display: block !important; white-space: normal; padding: 0 2px 4px; border-bottom: 1px solid var(--line); }
.bar-more-panel > #verBadge { display: inline-block !important; align-self: flex-start; }
.bar-more-panel > a, .bar-more-panel > button { min-height: 32px; }
body.tablet .bar-more { min-width: 40px; height: 36px; }
body.tablet .bar-more-panel > a, body.tablet .bar-more-panel > button { min-height: 44px; display: flex; align-items: center; }
#modeSwitch .ms-s { display: none; }
@media (max-width: 1100px) { #modeSwitch .ms-l { display: none; } #modeSwitch .ms-s { display: inline; } }
.menu-top { background: none; border: 0; padding: 4px 9px; border-radius: 4px; cursor: default; white-space: nowrap; }
.menu-top:hover, .menu-top.open { background: var(--hover); }
#modeSwitch { margin-left: auto; display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; flex: none; }
#modeSwitch button { border: 0; background: transparent; padding: 3px 12px; cursor: pointer; white-space: nowrap; }
#modeSwitch button.on { background: var(--accent); color: var(--accent-ink); }
#verBadge { margin-left: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--muted); border-radius: 10px; padding: 1px 9px; font: 11.5px ui-monospace, Consolas, monospace; cursor: pointer; white-space: nowrap; flex: none; }
#verBadge:hover { color: var(--accent); border-color: var(--accent); }
.changes h3 { margin: 10px 0 2px; font-size: 13px; color: var(--ink); }
.changes ul { margin: 2px 0 6px 18px; padding: 0; }
#docTitle { color: var(--muted); margin-left: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.dropdown { position: fixed; z-index: 1000; min-width: 230px; background: var(--menu); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 4px 0; }
.dropdown .item { display: grid; grid-template-columns: 18px 1fr auto; gap: 6px; padding: 4px 12px 4px 6px; cursor: default; white-space: nowrap; }
.dropdown .item:hover, .dropdown .item.open { background: var(--accent); color: var(--accent-ink); }
.dropdown .item .key { color: var(--muted); font-size: 11px; }
.dropdown .item:hover .key { color: inherit; }
.dropdown .sep { height: 1px; background: var(--line); margin: 4px 0; }
/* 見込み 2-A：押せない小見出しと、状態の 1 行（ヘルプの一番下） */
.dropdown .head { padding: 4px 12px 1px 30px; font-size: 11px; color: var(--muted); cursor: default; user-select: none; white-space: nowrap; }
.dropdown .item.status, .dropdown .item.status:hover { color: var(--muted); background: transparent; cursor: default; font-size: 12px; }
.dropdown .item.status.status-act { cursor: pointer; } .dropdown .item.status.status-act:hover .lb { text-decoration: underline; }
/* a menu taller than the window (js/menu_scroll.js): ▲ / ▼ at the top and the bottom */
.dropdown.scrolling { display: flex; flex-direction: column; overflow: hidden !important; max-height: none !important; padding: 0; }
.dropdown .dd-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px 0; scrollbar-width: thin; }
.dropdown .dd-arrow { flex: none; text-align: center; font-size: 11px; line-height: 22px; min-height: 22px; color: var(--muted); background: var(--menu); cursor: default; user-select: none; }
.dropdown .dd-arrow.up { border-bottom: 1px solid var(--line); }
.dropdown .dd-arrow.down { border-top: 1px solid var(--line); }
.dropdown .dd-arrow:hover { background: var(--accent); color: var(--accent-ink); }
.dropdown .dd-arrow.off { opacity: .35; pointer-events: none; }
body.tablet .dropdown .dd-arrow { min-height: 40px; line-height: 40px; font-size: 13px; }

/* toolbars */
#toolbar { display: flex; align-items: center; gap: 1px; padding: 0 6px; background: var(--bar); border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.tb { width: 32px; height: 32px; display: inline-grid; place-items: center; background: transparent; border: 1px solid transparent; border-radius: 5px; cursor: pointer; flex: none; color: var(--ink); padding: 0; }
.tb:hover { background: var(--hover); border-color: var(--line); }
.tb.on { background: var(--hover); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tsep { width: 1px; height: 24px; background: var(--line); margin: 0 5px; flex: none; }

#main { display: grid; grid-template-columns: var(--ts-w, 74px) 270px minmax(0, 1fr) var(--tray-w, 300px); min-height: 0; }
body.ol-hidden #main { grid-template-columns: var(--ts-w, 74px) 0 minmax(0, 1fr) var(--tray-w, 300px); }
body.ol-hidden #hier { display: none; }
body.tray-hidden #main { grid-template-columns: var(--ts-w, 74px) 270px minmax(0, 1fr) 26px; }
body.tray-hidden.ol-hidden #main { grid-template-columns: var(--ts-w, 74px) 0 minmax(0, 1fr) 26px; }
body.tray-hidden #trayBody, body.tray-hidden #trayHead span { display: none; }
#toolset { grid-column: 1; display: grid; grid-template-columns: 34px 34px; grid-auto-rows: 34px; gap: 2px; padding: 6px 2px; background: var(--bar); border-right: 1px solid var(--line); align-content: start; overflow-y: auto; overflow-x: hidden; }
#toolset .tb { width: 34px; height: 34px; }
#center { grid-column: 3; display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; min-height: 0; }
#sceneTabs { grid-row: 1; display: flex; gap: 2px; padding: 3px 6px 0; background: var(--bar); overflow-x: auto; border-bottom: 1px solid var(--line); }
#sceneTabs.empty { display: none; }
.stab { border: 1px solid var(--line); border-bottom: 0; background: var(--panel); padding: 3px 12px; border-radius: 6px 6px 0 0; cursor: pointer; white-space: nowrap; }
.stab.on { background: var(--panel2); font-weight: 600; box-shadow: inset 0 2px 0 var(--accent); }
#viewport { grid-row: 2; position: relative; overflow: hidden; background: var(--vp); min-height: 0; }
#viewport canvas { display: block; touch-action: none; }

/* overlay */
.view-overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.inf-dot { position: absolute; display: none; width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px; border-radius: 50%; border: 1.5px solid #000; background: #fff; }
.inf-dot.endpoint { background: #13a538; border-color: #0b6e24; }
.inf-dot.midpoint { background: #18b7c9; border-color: #0d7a87; }
.inf-dot.edge { border-radius: 1px; background: #d22d2d; border-color: #8c1717; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; }
.inf-dot.face { border-radius: 1px; background: #2b5fd9; border-color: #173a8f; transform: rotate(45deg); width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; }
.inf-dot.intersect { background: transparent; border: 0; }
.inf-dot.intersect::before, .inf-dot.intersect::after { content: ""; position: absolute; left: 5px; top: -1px; width: 2px; height: 13px; background: #d22d2d; transform: rotate(45deg); }
.inf-dot.intersect::after { transform: rotate(-45deg); }
.inf-dot.axis, .inf-dot.locked { width: 8px; height: 8px; margin: -4px 0 0 -4px; }
.inf-dot.x { background: #d22d2d; border-color: #8c1717; } .inf-dot.y { background: #2a9d3a; border-color: #17611f; } .inf-dot.z { background: #2b5fd9; border-color: #173a8f; }
.inf-dot.guide { background: #222; }
.inf-tip { position: absolute; display: none; background: #fffbe0; color: #222; border: 1px solid #b9ae6e; padding: 1px 6px; font-size: 11.5px; border-radius: 3px; white-space: nowrap; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.rubber { position: absolute; display: none; border: 1px solid #1a5cff; background: rgba(26, 92, 255, .08); }
.rubber.crossing { border-style: dashed; }
.labels .lbl { position: absolute; transform: translate(-50%, -50%); background: rgba(255,255,255,.92); color: #111; border: 1px solid #888; padding: 0 5px; font-size: 11.5px; border-radius: 3px; white-space: nowrap; }
.labels .lbl.note { transform: none; background: #fff; border-color: #444; }

/* tray */
#tray { grid-column: 4; display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-left: 1px solid var(--line); }
#trayHead { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px; font-weight: 600; border-bottom: 1px solid var(--line); background: var(--bar); }
#trayHead button { border: 0; background: none; cursor: pointer; font-size: 14px; }
#trayBody { overflow-y: auto; flex: 1; min-height: 0; }
.panel { border-bottom: 1px solid var(--line); }
.panel.hidden { display: none; }
.panel h3 { margin: 0; font-size: 12.5px; font-weight: 600; padding: 6px 8px; cursor: pointer; user-select: none; background: var(--sec-head, #e1e6ef); border-top: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
body[data-mode="manga"] { --sec-head: #353843; }
.ei-acts { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.ei-acts .btn { padding: 2px 6px; font-size: 11.5px; }
.ei-acts .ei-sp { flex: 1; }
.ei-ic { width: 26px; height: 22px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: var(--panel2); cursor: pointer; font-size: 13px; line-height: 1; }
.ei-ic:hover { background: var(--hover); }
.ei-ic.on { border-color: var(--accent); background: var(--hover); }
.ei-manga { border-top: 1px dashed var(--line); padding-top: 4px; }
.ei-manga > summary { cursor: pointer; font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 2px 0; }
.panel h3:hover { background: var(--hover); }
.panel .tw { display: inline-block; width: 14px; transition: transform .12s; }
.panel.closed .tw { transform: rotate(-90deg); }
.panel.closed .body { display: none; }
.panel .body { padding: 6px 10px 10px; display: flex; flex-direction: column; gap: 6px; }
.panel h4 { margin: 6px 0 0; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.kv { display: flex; justify-content: space-between; gap: 8px; }
.kv span { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.note { background: #fff6d6; color: #5a4a00; padding: 4px 6px; border-radius: 4px; font-size: 11.5px; }
.row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.btn { border: 1px solid var(--line); background: var(--panel2); border-radius: 5px; padding: 3px 9px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; text-decoration: none; color: var(--ink); }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn svg { width: 15px; height: 15px; }
.ic { border: 0; background: transparent; cursor: pointer; padding: 2px; display: inline-grid; place-items: center; color: var(--ink); }
.ic svg { width: 16px; height: 16px; }
.field { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; color: var(--muted); }
.field input:not([type=range]):not([type=color]), .field select, input.wide { color: var(--ink); background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 3px 6px; width: 100%; }
.field .v { float: right; color: var(--ink); }
.chk { display: flex; align-items: center; gap: 6px; }
input.num { width: 52px; background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; }
input[type=color] { width: 36px; height: 22px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: none; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
/* エンティティ情報（Unity 風）: 名前の行は「見出し｜入力」、位置・回転・スケールは「見出し｜X□ Y□ Z□」 */
.ei-row { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.ei-row > input, .ei-row > select { min-width: 0; width: 100%; }
.ei-row .ei-note { grid-column: 2; font-size: 10.5px; margin-top: -2px; }
.ei-xyz { display: grid; grid-template-columns: 64px repeat(3, minmax(0, 1fr)); align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); }
.ei-xyz label { display: flex; align-items: center; gap: 3px; min-width: 0; }
.ei-xyz label b { font-weight: 600; font-size: 10.5px; width: 9px; }
.ei-xyz label:nth-of-type(1) b { color: #d04a4a; } .ei-xyz label:nth-of-type(2) b { color: #3f9a3f; } .ei-xyz label:nth-of-type(3) b { color: #3f6fd0; }
.ei-xyz input { min-width: 0; width: 100%; }
.tabs { display: flex; border-bottom: 1px solid var(--line); gap: 2px; }
.tabs button { border: 0; background: none; padding: 3px 8px; cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.on { border-color: var(--accent); font-weight: 600; }
.tabbody { display: flex; flex-direction: column; gap: 6px; }
select.cat { background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 2px 4px; }
.matcur { display: grid; grid-template-columns: 44px 1fr auto; gap: 8px; align-items: center; }
.swgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(19px, 1fr)); gap: 3px; } /* 見本は縦横半分（場所を取りすぎ） */
.sw { aspect-ratio: 1; border: 1px solid var(--line); border-radius: 4px; cursor: pointer; padding: 0; }
.sw:hover { outline: 2px solid var(--accent); }
.sw.on { outline: 2px solid var(--accent); }
.sw.big { width: 44px; height: 44px; display: inline-block; }
.sw.def { background: linear-gradient(135deg, #f4f4f1 50%, #a7b7c7 50%); }
.clist { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.citem { display: flex; align-items: center; gap: 6px; text-align: left; border: 1px solid var(--line); background: var(--panel2); border-radius: 5px; padding: 4px 6px; cursor: pointer; min-width: 0; }
.citem span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.citem svg { flex: none; width: 18px; height: 18px; }
.citem:hover { border-color: var(--accent); }
.presets { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
.preset { display: flex; gap: 6px; align-items: center; border: 1px solid var(--line); background: var(--panel2); border-radius: 5px; padding: 3px 6px; cursor: pointer; text-align: left; }
.preset.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.seg { display: flex; gap: 2px; }
.seg button { flex: 1; border: 1px solid var(--line); background: var(--panel2); border-radius: 4px; padding: 2px; cursor: pointer; display: grid; place-items: center; }
.seg button.on { border-color: var(--accent); background: var(--hover); }
.tagrow { display: grid; grid-template-columns: 24px 30px 1fr 24px; gap: 4px; align-items: center; margin-bottom: 2px; }
.tagrow input:not([type=color]) { background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; min-width: 0; }
.clist.comp { grid-template-columns: minmax(0, 1fr); gap: 3px; } /* one per row: names are long and rows carry ☆ / 別案 */
.citem-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 2px; align-items: center; }
.citem-row.variant { padding-left: 10px; border-left: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); }
.citem-row .citem { min-width: 0; }
.citem-row .citem span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cfav, .cvar { border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; border-radius: 4px; font-size: 12px; padding: 0 5px; line-height: 20px; }
.cfav:hover, .cvar:hover { border-color: var(--line); color: var(--fg, inherit); }
.cfav.on { color: #e0a100; }
.cvar.on { color: var(--accent); font-weight: 600; }
.ctags { display: flex; flex-wrap: wrap; gap: 3px; margin: 4px 0; }
.chip { border: 1px solid var(--line); background: var(--panel2); color: inherit; border-radius: 999px; padding: 0 8px; font-size: 11.5px; line-height: 20px; cursor: pointer; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.hist-list { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 4px; margin: 4px 0; }
.hist-row { display: flex; gap: 6px; align-items: center; padding: 2px 6px; cursor: pointer; font-size: 12px; border-bottom: 1px solid var(--line); }
.hist-row:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.hist-row.cur { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.hist-row.future { opacity: .45; }
.hist-t { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 11px; flex: none; }
.hist-row.cur .hist-t { color: inherit; }
.hist-ai { flex: none; font-size: 10px; font-weight: 700; padding: 0 4px; border-radius: 3px; background: #9673a6; color: #fff; }
.hist-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scenerow { display: grid; grid-template-columns: 1fr 24px 24px 24px; gap: 2px; align-items: center; margin-bottom: 2px; }
.scenerow input { background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; min-width: 0; }
.scenerow.on input { border-color: var(--accent); }
.secrow { border: 1px solid var(--line); border-radius: 5px; padding: 4px 6px; }
.secrow input[type=range] { flex: 1; width: auto; min-width: 60px; }
.olist { max-height: 340px; overflow: auto; }
.orow { display: grid; grid-template-columns: 20px 1fr 22px; gap: 4px; align-items: center; padding: 2px 4px; cursor: pointer; border-radius: 4px; }
.orow:hover { background: var(--hover); }
.orow.on { background: var(--accent); color: var(--accent-ink); }
.orow.edit { font-weight: 600; }
.orow .on { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orow svg { width: 16px; height: 16px; }
.instr { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.instr svg { width: 34px; height: 34px; }

/* status bar */
/* a row, not grid columns: js/snap_ui.js adds its own item, and a hidden item must not shift the others into a second row */
#statusbar { display: flex; align-items: center; gap: 8px; padding: 0 8px; background: var(--bar); border-top: 1px solid var(--line); min-width: 0; overflow: hidden; }
#statusbar > * { flex: none; }
#statusbar > #hint { flex: 1 1 auto; min-width: 0; }
#statusbar > #navHint { flex: 0 1 auto; min-width: 0; }
#statusbar > #snapStat { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#vcbInput { width: 200px; }
@media (max-width: 900px) { #vcbInput { width: 120px; } }
#hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
#vcbLabel { color: var(--muted); white-space: nowrap; }
#vcbInput { height: 21px; border: 1px solid var(--line); background: var(--panel2); border-radius: 3px; padding: 0 6px; font-family: ui-monospace, Consolas, monospace; text-align: right; }
#vcbInput.typing { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* dialogs */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 2000; padding: 16px; }
.dialog { background: var(--panel2); color: var(--ink); border-radius: 10px; padding: 16px 18px; width: min(420px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.3); display: flex; flex-direction: column; gap: 10px; }
.dialog.wide { width: min(820px, 100%); }
.dialog h2 { margin: 0; font-size: 16px; }
.dialog h3 { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.welcome .brand { display: flex; gap: 12px; align-items: center; }
.welcome .brand svg { width: 44px; height: 44px; }
/* 新規の画面の分け目（漫画を作る／テンプレート／学校・街…）: 色の帯にして、どこからどこまでが同じ仲間か分かるように */
.welcome h3 { margin: 16px 0 8px; padding: 6px 10px; font-size: 13px; font-weight: 700; color: var(--ink); background: var(--sec-head, #e1e6ef); border-left: 4px solid #8a97ad; border-radius: 4px; position: sticky; top: 0; z-index: 1; }
.welcome h3.wl-comic { background: #fdeccf; border-left-color: #e08a1e; }
.welcome h3.wl-tpl { background: #dfe9fb; border-left-color: var(--accent); }
.welcome h3 .wl-sub { font-weight: 400; font-size: 11.5px; color: var(--muted); margin-left: 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.card { display: flex; flex-direction: column; gap: 4px; text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 10px 12px; cursor: pointer; }
.card:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card span { color: var(--muted); font-size: 11.5px; }
table.keys { border-collapse: collapse; width: 100%; }
table.keys td { padding: 3px 6px; border-bottom: 1px solid var(--line); }
kbd { background: var(--panel); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; }
#toasts { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 3000; pointer-events: none; }
#toasts .toast-setup { pointer-events: auto; }
.toast { background: rgba(30,30,32,.92); color: #fff; padding: 6px 14px; border-radius: 6px; transition: opacity .4s; max-width: 80vw; }
.toast.out { opacity: 0; }

/* manga mode: ABLUR-like right side, drawing tools tucked away */
/* 漫画レンダー: the same columns as モデリング (the view does not move when the mode changes); the tools are not used there */
body[data-mode="manga"] #toolset > * { visibility: hidden; }
body[data-mode="pages"] #main { grid-template-columns: 0 0 minmax(0, 1fr) 0; }
/* コマ割りでは新規・開く・保存と常設の工程だけを上の帯に残す（編集道具はコマ割り自身の帯）。 */
body[data-mode="manga"] #snapBar, body[data-mode="pages"] #snapBar { display: none !important; }
body[data-mode="pages"] { grid-template-rows: 30px 40px minmax(0, 1fr) 28px; }
body.tablet[data-mode="pages"] { grid-template-rows: 44px 44px minmax(0, 1fr) 32px; }
body[data-mode="pages"] #toolbar > :not([data-tbg="file"]):not([data-open-process]):not(.nav-trail):not(.nt-save:not([hidden])) { display: none !important; }
#toolbar .tb-process { width: auto; display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; font-weight: 600; flex-shrink: 0; }
body[data-mode="pages"] #toolset, body[data-mode="pages"] #hier, body[data-mode="pages"] #tray, body[data-mode="pages"] #sceneTabs, body[data-mode="pages"] #olShow { display: none !important; }
body[data-mode="manga"] .panel:not([data-id="manga"]) { display: none; }
body[data-mode="manga"] .panel[data-id="manga"] { border: 0; height: 100%; display: flex; flex-direction: column; }
body[data-mode="manga"] .panel[data-id="manga"] > h3 { display: none; }
body[data-mode="manga"] .panel[data-id="manga"] > .body { padding: 0; flex: 1; min-height: 0; }
body[data-mode="manga"] #trayBody { overflow: hidden; display: flex; flex-direction: column; }
body[data-mode="manga"] #trayHead span::after { content: "（漫画レンダー）"; }
body[data-mode="manga"] .tb svg, body[data-mode="manga"] .seg svg { filter: invert(.85) hue-rotate(180deg); }
body[data-mode="manga"] #sceneTabs { background: #202020; }

@media (max-width: 900px) {
  #main { grid-template-columns: 40px 0 minmax(0, 1fr) 0; }
  #hier { display: none; }
  #toolset { grid-template-columns: 34px; }
  #tray { display: none; }
  body[data-mode="manga"]:not(.tray-hidden) #tray, body.tray-open #tray { grid-column: 4; display: flex; position: fixed; right: 0; top: calc(70px + var(--tb-h, 0px)); bottom: 28px; width: min(320px, 90vw); z-index: 50; }
  #docTitle { display: none; }
  #statusbar { grid-template-columns: minmax(0, 1fr) auto 120px; }
  #statusbar .sicons { display: none; }
}

/* outliner (hierarchy, left dock) */
#hier { grid-column: 2; display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--panel); border-right: 1px solid var(--line); }
.ol-head { display: flex; align-items: center; gap: 2px; padding: 5px 6px; font-weight: 600; background: var(--bar); border-bottom: 1px solid var(--line); }
.ol-title { display: flex; align-items: center; gap: 6px; flex: 1; }
.ol-title svg { width: 18px; height: 18px; }
.ol-head .ic { width: 22px; height: 22px; font-size: 13px; }
.ol-search { padding: 5px 6px; border-bottom: 1px solid var(--line); }
.ol-search input { width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 5px; padding: 3px 7px; color: var(--ink); }
.ol-list { flex: 1; overflow: auto; padding: 3px 0; outline: none; }
.ol-row { display: grid; grid-template-columns: 14px 30px minmax(0, 1fr) auto 20px 22px; align-items: center; gap: 4px; padding: 1px 6px 1px calc(4px + var(--d, 0) * 14px); cursor: pointer; border-radius: 4px; margin: 0 3px; min-height: 32px; }
.ol-row:hover { background: var(--hover); }
.ol-sec { margin: 6px 3px 2px; padding: 2px 8px; font-size: 11px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); }
.ol-sec[data-ol-cut] { color: var(--ink); background: color-mix(in srgb, #c26a1b 14%, transparent); border-radius: 4px 4px 0 0; }
.ol-row.on { background: var(--accent); color: var(--accent-ink); box-shadow: inset 4px 0 0 #ff8a00; font-weight: 600; }
.ol-row.anc { background: color-mix(in srgb, var(--accent) 12%, transparent); box-shadow: inset 2px 0 0 color-mix(in srgb, #ff8a00 60%, transparent); }
.ol-row.on .def, .ol-row.on .cnt { color: inherit; opacity: .85; }
.ol-row.edit { box-shadow: inset 3px 0 0 #e07b00; font-weight: 600; }
.ol-row.hid .nm, .ol-row.taghid .nm, .ol-row.hid .th { opacity: .4; }
.ol-row .tw { font-size: 10px; color: var(--muted); text-align: center; }
.ol-row.on .tw { color: inherit; }
.ol-row .th { width: 30px; height: 30px; border-radius: 4px; background: var(--panel2); border: 1px solid var(--line); object-fit: contain; }
.ol-row .th:not([src]) { background: repeating-linear-gradient(45deg, var(--panel2) 0 4px, var(--bg) 4px 8px); }
.ol-row .th-root { display: grid; place-items: center; }
.ol-row .th-root svg { width: 20px; height: 20px; }
.ol-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ol-row .def { color: var(--muted); font-size: 11px; margin-left: 6px; }
.ol-row .cnt { color: var(--muted); font-size: 11px; }
.ol-row .ic { opacity: .5; padding: 0; }
.ol-row .ic:hover, .ol-row .lk.on { opacity: 1; }
.ol-row .lk { font-size: 11px; }
.ol-row.root { min-height: 28px; }
.ol-rename { width: 100%; font: inherit; padding: 1px 4px; }
.ol-foot { padding: 4px 8px; border-top: 1px solid var(--line); }
#olShow { position: fixed; left: 78px; top: calc(112px + var(--tb-h, 0px)); z-index: 40; display: none; border: 1px solid var(--line); background: var(--panel2); color: var(--ink); border-radius: 0 6px 6px 0; padding: 3px 8px; cursor: pointer; font: inherit; }
body.ol-hidden #olShow { display: block; }
#navHint { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.ep-dlg { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); margin: 6px 0; }
.ep-dlg input { font: inherit; padding: 4px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel2); color: var(--ink); }

/* narrow screens: the toolbar scrolls sideways with ◀ / ▶ at its ends (js/menubar_fit.js); the snap bar scrolls with it
   instead of sitting on top of the buttons */
.tb-scroll { position: sticky; z-index: 2; flex: none; align-self: stretch; width: 26px; border: 0; padding: 0; cursor: pointer; color: var(--accent); font-size: 12px;
  background: linear-gradient(to right, var(--bar) 70%, transparent); }
#tbPrev { left: 0; margin-right: -8px; }
#tbNext { right: 0; margin-left: -8px; background: linear-gradient(to left, var(--bar) 70%, transparent); }
.tb-scroll[hidden] { display: none; }
body.tablet .tb-scroll { width: 36px; font-size: 15px; }
@media (max-width: 1100px) {
  #toolbar #snapBar { position: static; margin-left: 8px; }
  #toolbar #snapBar .sl { display: none; }
}
@media (max-width: 800px) {
  body.tablet #menubar .menu-top { padding: 0 8px; }
  body.tablet #menubar #modeSwitch button { padding: 0 10px; }
}

/* 網点の細かさを見比べる（js/tone_fineness.js） */
.fineness-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 6px; }
.fineness-card { display: flex; flex-direction: column; gap: 3px; padding: 4px; text-align: left; background: #fff; color: #222; border: 2px solid #ccc; border-radius: 4px; cursor: pointer; min-width: 0; }
.fineness-card.on { border-color: #2f7de1; }
.fineness-card img { width: 100%; aspect-ratio: 1; object-fit: none; image-rendering: pixelated; background: #fff; }
.fineness-dot { width: 100%; aspect-ratio: 1; background-color: #fff; background-image: radial-gradient(circle, #000 28%, transparent 30%); background-size: var(--p) var(--p); }
.fineness-hatch { width: 100%; aspect-ratio: 1; background: repeating-linear-gradient(45deg, #000 0 1px, #fff 1px var(--p)); }
.fineness-line { width: 100%; aspect-ratio: 1; background: #fff linear-gradient(transparent calc(50% - var(--w) / 2), #000 0 calc(50% + var(--w) / 2), transparent 0); }
.fineness-kinds { display: flex; gap: 4px; flex-wrap: wrap; }
.fineness-kinds .on { outline: 2px solid #2f7de1; }
.fineness-name { font-weight: 600; font-size: 12px; }

body { --studio-header-bottom:70px; }
body.tablet { --studio-header-bottom:88px; }
