:root {
  color-scheme: light;
  font-family: "Helvetica Neue", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", sans-serif;
  --ink: #181818;
  --muted: #707070;
  --line: #cfcfcf;
  --canvas: #f4f4f2;
  --panel: #fff;
  --accent: #ff4e2f;
  --accent-soft: #fff0eb;
  --selection: #1959d1;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { color: var(--ink); background: var(--canvas); font-size: 16px; }
button, input, textarea { font: inherit; }
button { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-linecap: square; stroke-linejoin: miter; stroke-width: 1.6; }

.app-shell { display: grid; grid-template-rows: 58px 1fr; width: 100%; height: 100%; }
.topbar {
  position: relative; z-index: 20; display: grid; grid-template-columns: 226px 1fr auto; align-items: center;
  gap: 16px; height: 58px; padding: 0 14px; background: #fff; border-bottom: 1px solid #999;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: .92rem; font-weight: 700; letter-spacing: .01em; }
.brand-mark { position: relative; width: 26px; height: 26px; border: 1px solid var(--ink); background: #fff; }
.brand-mark::before, .brand-mark::after, .brand-mark span, .brand-mark i, .brand-mark b { content: ""; position: absolute; display: block; }
.brand-mark::before { left: 5px; top: 7px; width: 14px; height: 1px; background: var(--ink); }
.brand-mark::after { left: 12px; top: 8px; width: 1px; height: 10px; background: var(--ink); }
.brand-mark span { left: 10px; bottom: 5px; width: 8px; height: 1px; background: var(--ink); transform: rotate(42deg); }
.brand-mark i { left: 3px; top: 5px; width: 5px; height: 5px; background: var(--accent); }
.brand-mark b { right: 3px; bottom: 3px; width: 5px; height: 5px; border: 1px solid var(--ink); background: #fff; }
.project-heading { min-width: 0; display: flex; align-items: center; justify-content: center; gap: 14px; }
.project-title { width: min(320px, 36vw); border: 0; border-bottom: 1px solid transparent; padding: 6px 4px; text-align: center; color: #222; background: transparent; font-size: .94rem; font-weight: 700; }
.project-title:hover { border-bottom-color: #aaa; }
.project-title:focus { border-bottom-color: var(--selection); outline: 0; }
.save-state { display: inline-flex; align-items: center; gap: 7px; color: #777; font: 500 .7rem/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }
.save-state span { width: 6px; height: 6px; background: #1b7845; }
.save-state.saving span { background: var(--accent); }
.top-actions { display: flex; align-items: center; gap: 0; }
.mode-switch { display: inline-flex; margin-right: 5px; padding: 2px; border: 1px solid #d7dae0; border-radius: 7px; background: #f5f6f7; }
.mode-switch button { min-height: 26px; padding: 0 8px; border: 0; border-radius: 5px; color: #69717d; background: transparent; cursor: pointer; font-size: .66rem; font-weight: 700; }
.mode-switch button.active { color: #fff; background: #303740; }
.storage-mode-label { display: none; }
.compact-action { min-width: 42px; padding: 0 7px; }
#align-mode-button.active { color: #244fae; background: #edf2ff; box-shadow: inset 0 0 0 1px #a9bce9; }
.history-actions { display: flex; align-items: center; margin-right: 4px; padding-right: 4px; border-right: 1px solid #e1e3e6; }
.button, .icon-button { border: 0; background: none; cursor: pointer; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 34px; padding: 0 11px; border-radius: 0; font-size: .78rem; font-weight: 650; }
.button svg { width: 16px; height: 16px; }
.button:hover { background: #eee; }
.button:focus-visible, .icon-button:focus-visible, .tool:focus-visible, .node-card:focus-visible { outline: 2px solid var(--selection); outline-offset: 2px; }
.button-primary { color: white; background: var(--ink); }
.button-primary:hover { background: var(--accent); }
.button-danger { color: #b02b22; }
.button-danger:hover { background: #f7e9e7; }
.icon-button { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 0; font-size: .9rem; font-weight: 700; }
.icon-button:hover { background: #eee; }
.icon-button:disabled, .button:disabled { color: #b7bac0; background: transparent; cursor: default; }
.icon-button.quiet { color: #666; font-size: 1.15rem; }

.workspace { position: relative; min-width: 0; min-height: 0; }
.tool-rail {
  position: absolute; z-index: 16; left: 12px; top: 12px; bottom: 12px; display: flex; flex-direction: column; align-items: center;
  width: 58px; padding: 4px; border: 1px solid #8f8f8f; border-radius: 0; background: #fff; box-shadow: 3px 3px 0 rgba(0,0,0,.08);
}
.tool { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; width: 48px; min-height: 51px; padding: 4px; border: 0; border-radius: 0; color: #555; background: transparent; cursor: pointer; font-size: .66rem; }
.tool svg { width: 20px; height: 20px; }
.tool:hover { background: #ececec; color: #111; }
.tool.active { color: white; background: var(--ink); }
.rail-divider { width: 38px; height: 1px; margin: 4px 0; background: #aaa; }
.rail-spacer { flex: 1; }

.board { position: absolute; inset: 0; overflow: hidden; touch-action: none; outline: none; background: var(--canvas); cursor: grab; }
.board.dragging { cursor: grabbing; }
.board-grid {
  position: absolute; inset: 0; opacity: .72;
  background-image: linear-gradient(#dededb 1px, transparent 1px), linear-gradient(90deg, #dededb 1px, transparent 1px), linear-gradient(#c9c9c5 1px, transparent 1px), linear-gradient(90deg, #c9c9c5 1px, transparent 1px);
  background-size: 24px 24px, 24px 24px, 120px 120px, 120px 120px;
  background-position: var(--grid-x, 0px) var(--grid-y, 0px);
}
.world { position: absolute; left: 0; top: 0; width: 3000px; height: 4800px; transform-origin: 0 0; will-change: transform; }
.timeline-label { position: absolute; left: 130px; top: 92px; display: flex; align-items: baseline; gap: 16px; color: #222; }
.timeline-label span { padding-bottom: 4px; border-bottom: 3px solid var(--accent); font: 750 .72rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .13em; }
.timeline-label small { color: #6d6d6d; font-size: .72rem; }
.connections { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.connections .timeline-path { stroke: #555; stroke-width: 1.5; }
.connections .timeline-halo { stroke: var(--canvas); stroke-width: 7; }
.connections .branch-path { stroke: #555; stroke-width: 1.35; stroke-dasharray: none; }
.connections circle { stroke: var(--canvas); stroke-width: 5; fill: var(--ink); }

.node-card { position: absolute; z-index: 2; border: 1px solid #7d7d7d; background: #fff; text-align: left; cursor: pointer; user-select: none; }
.node-card.selected { border-color: var(--selection); box-shadow: 3px 3px 0 rgba(25,89,209,.22); }
.scene-card { display: flex; flex-direction: column; width: 226px; min-height: 134px; padding: 15px 15px 13px; border-radius: 0; box-shadow: 3px 3px 0 rgba(0,0,0,.09); cursor: grab; }
.scene-card::before { content: ""; position: absolute; left: -1px; top: -1px; bottom: -1px; width: 5px; background: var(--node-color, var(--accent)); }
.scene-card .drag-grip { position: absolute; right: 11px; top: 13px; display: grid; grid-template-columns: repeat(2, 2px); gap: 3px; opacity: .5; }
.scene-card .drag-grip i { width: 2px; height: 2px; background: #333; }
.scene-card.dragging-node { z-index: 10; opacity: .92; cursor: grabbing; }
.node-label { display: flex; align-items: center; gap: 7px; margin-bottom: 10px; color: #656565; font: 650 .66rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .05em; text-transform: uppercase; }
.node-label .chapter { overflow: hidden; max-width: 110px; white-space: nowrap; text-overflow: ellipsis; }
.node-label .dot { width: 6px; height: 6px; background: var(--node-color, var(--accent)); }
.node-title { margin: 0 0 7px; color: #151515; font-size: .94rem; line-height: 1.4; font-weight: 700; letter-spacing: .01em; }
.node-body { flex: 1; min-height: 0; overflow: auto; margin: 0; color: #555; font-size: .75rem; line-height: 1.58; white-space: normal; scrollbar-width: thin; user-select: text; }
.node-body p { margin: 0 0 6px; white-space: pre-wrap; }
.node-body p:last-child { margin-bottom: 0; }
.node-body ul { margin: 0 0 7px; padding-left: 1.25em; }
.node-body li { margin: 0 0 3px; padding-left: .12em; }
.scene-card .branch-count { position: absolute; right: 8px; bottom: -12px; display: inline-flex; align-items: center; gap: 4px; height: 23px; padding: 0 7px; border: 1px solid #777; border-radius: 0; color: #333; background: #fff; font: 600 .64rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.scene-card .branch-count svg { width: 11px; height: 11px; }
.scene-order-actions { position: absolute; z-index: 6; right: 9px; top: 8px; display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.scene-card:hover .scene-order-actions, .scene-order-actions:focus-within { opacity: 1; }
.scene-order-actions button { display: grid; place-items: center; width: 25px; height: 24px; padding: 0; border: 1px solid #ccd0d5; border-radius: 5px; color: #4b535e; background: #fff; cursor: pointer; font-size: .75rem; }
.scene-order-actions button:hover:not(:disabled) { color: #fff; border-color: #3d4652; background: #3d4652; }
.scene-order-actions button:disabled { color: #c5c8cd; cursor: default; }
.collapse-tree { position: absolute; z-index: 6; right: 10px; bottom: -12px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 24px; min-width: 30px; padding: 0 7px; border: 1px solid #c9cdd3; border-radius: 999px; color: #4e5661; background: #fff; box-shadow: 0 2px 6px rgba(27,31,40,.08); cursor: pointer; font: 750 .7rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.collapse-tree span { color: #858b94; font-size: .58rem; }
.collapse-tree:hover { color: #fff; border-color: #3d4652; background: #3d4652; }
.node-control-dock { position: absolute; z-index: 9; right: -14px; bottom: 30px; display: flex; flex-direction: column-reverse; align-items: center; gap: 5px; opacity: 0; pointer-events: none; transition: opacity .12s ease; }
.node-card:hover .node-control-dock, .node-control-dock:focus-within { opacity: 1; pointer-events: auto; }
.node-add-menu { position: relative; }
.node-add-trigger, .node-control-dock .collapse-tree { position: static; display: inline-flex; align-items: center; justify-content: center; height: 27px; min-width: 29px; padding: 0 8px; border: 1px solid #cbd0d6; border-radius: 999px; color: #4c5562; background: #fff; box-shadow: 0 3px 10px rgba(28,33,41,.11); cursor: pointer; font: 750 .72rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.node-add-trigger:hover, .node-control-dock .collapse-tree:hover { color: #fff; border-color: #39424d; background: #39424d; }
.node-add-popover { position: absolute; z-index: 30; right: 36px; bottom: 0; min-width: 126px; padding: 5px; border: 1px solid #cdd2d8; border-radius: 9px; background: #fff; box-shadow: 0 12px 30px rgba(20,25,33,.18); }
.node-add-popover button { display: block; width: 100%; padding: 8px 9px; border: 0; border-radius: 6px; text-align: left; color: #37404b; background: transparent; cursor: pointer; font-size: .72rem; }
.node-add-popover button:hover { color: #fff; background: #39424d; }

.branch-card { display: flex; flex-direction: column; width: 200px; min-height: 102px; padding: 12px 13px; border-radius: 0; background: #fff; box-shadow: 2px 2px 0 rgba(0,0,0,.08); cursor: grab; }
.branch-card::before { content: ""; position: absolute; left: -5px; top: 17px; width: 8px; height: 8px; border: 1px solid #333; background: var(--node-color, var(--accent)); }
.branch-card .node-label { margin-bottom: 7px; font-size: .63rem; }
.branch-card .node-title { margin-bottom: 5px; font-size: .86rem; }
.branch-card .node-body { font-size: .71rem; }
.branch-add { position: absolute; right: -11px; top: 39px; display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid #555; border-radius: 0; color: #222; background: #fff; opacity: 0; cursor: pointer; transition: opacity .12s; }
.branch-card:hover .branch-add, .branch-card.selected .branch-add { opacity: 1; }
.branch-add:hover { color: white; background: var(--ink); }

.memo-card { display: flex; flex-direction: column; width: 188px; min-height: 138px; padding: 14px 14px 17px; border: 1px solid #8b8063; border-radius: 0; background: var(--memo-color, #fff4c8); box-shadow: 3px 3px 0 rgba(0,0,0,.1); cursor: grab; transform: none; }
.memo-card::after { content: none; }
.memo-card.dragging-node { z-index: 10; cursor: grabbing; }
.memo-card .node-label { color: #6b624d; }
.memo-card .node-title { color: #29261e; }
.memo-card .node-body { color: #5b5547; }
.image-card { overflow: hidden; min-width: 120px; min-height: 90px; padding: 0; border-color: #cbd0d6; background: #eef0f2; cursor: move; }
.image-card img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.image-card img[hidden] { display: none; }
.image-placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: #7a828d; background: repeating-linear-gradient(135deg, #f2f3f4 0 10px, #e8eaec 10px 20px); font-size: .72rem; }
.image-placeholder[hidden] { display: none; }
.image-caption { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 8px; min-height: 31px; padding: 6px 36px 6px 9px; color: #fff; background: linear-gradient(transparent, rgba(15,18,22,.82)); pointer-events: none; }
.image-caption span { font: 700 .55rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; opacity: .8; }
.image-caption strong { overflow: hidden; font-size: .72rem; white-space: nowrap; text-overflow: ellipsis; }
.image-edit-button { position: absolute; z-index: 7; right: 6px; top: 6px; display: grid; place-items: center; width: 27px; height: 26px; border: 1px solid rgba(255,255,255,.7); border-radius: 6px; color: #fff; background: rgba(18,21,25,.64); cursor: pointer; letter-spacing: 1px; opacity: 0; }
.image-card:hover .image-edit-button, .image-edit-button:focus-visible { opacity: 1; }
.design-box-card { overflow: hidden; min-width: 220px; min-height: 170px; padding: 0; border: 0; background: rgba(255,255,255,.16); box-shadow: none; cursor: grab; }
.design-box-head { position: relative; z-index: 4; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 9px 10px 7px; pointer-events: none; }
.design-box-head div > span { color: #8c949e; font: 700 .52rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; opacity: .72; }
.design-box-head h3 { margin: 3px 0 0; color: #313842; font-size: .76rem; font-weight: 650; }
.design-box-head > span { color: #a5abb3; font: 600 .54rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; opacity: .68; }
.design-box-stage { position: absolute; inset: 0; overflow: hidden; }
.design-box-item { position: absolute; z-index: 2; min-width: 56px; min-height: 56px; margin: 0; overflow: hidden; border: 1px solid rgba(92,102,114,.28); border-radius: 4px; background: #eceff2; box-shadow: 0 2px 7px rgba(25,31,39,.12); cursor: grab; touch-action: none; }
.design-box-item.dragging-asset, .design-box-item.resizing-asset { z-index: 6; cursor: grabbing; box-shadow: 0 7px 18px rgba(25,31,39,.2); }
.design-box-item img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.design-box-placeholder { display: grid; place-items: center; height: 100%; color: #8b929b; font-size: .65rem; }
.design-box-item figcaption { position: absolute; left: 0; right: 0; bottom: 0; overflow: hidden; padding: 12px 5px 4px; color: #fff; background: linear-gradient(transparent, rgba(18,22,27,.72)); font-size: .56rem; white-space: nowrap; text-overflow: ellipsis; pointer-events: none; }
.design-box-item button { position: absolute; right: 4px; top: 4px; display: grid; place-items: center; width: 21px; height: 21px; border: 0; border-radius: 50%; color: #fff; background: rgba(23,27,33,.72); cursor: pointer; opacity: 0; }
.design-box-item:hover button, .design-box-item button:focus-visible { opacity: 1; }
.design-asset-resize { position: absolute; z-index: 4; right: 2px; bottom: 2px; width: 21px; height: 21px; border-right: 3px solid rgba(255,255,255,.96); border-bottom: 3px solid rgba(255,255,255,.96); filter: drop-shadow(0 1px 1px rgba(17,22,28,.55)); cursor: nwse-resize; opacity: 0; touch-action: none; }
.design-box-item:hover .design-asset-resize, .design-box-item:focus-within .design-asset-resize, .design-box-card.selected .design-asset-resize { opacity: 1; }
.design-box-empty { position: absolute; inset: 46px 10px 12px; display: grid; place-items: center; color: #949ba4; font-size: .68rem; text-align: center; }
.design-box-add { position: absolute; z-index: 7; left: 11px; bottom: 10px; min-height: 27px; padding: 0 9px; border: 1px solid #c8cdd4; border-radius: 999px; color: #4c5562; background: #fff; box-shadow: 0 3px 10px rgba(28,33,41,.11); cursor: pointer; font-size: .66rem; font-weight: 700; opacity: 0; }
.design-box-card:hover .design-box-add, .design-box-add:focus-visible { opacity: 1; }
.connections .image-path { stroke-dasharray: 4 4; }

.node-blue { --node-color: #1959d1; }
.node-coral { --node-color: #ff4e2f; }
.node-green { --node-color: #15724a; }
.node-yellow { --node-color: #d18a00; }
.memo-yellow { --memo-color: #fff2b8; }
.memo-blue { --memo-color: #e3ebff; }
.memo-coral { --memo-color: #ffe3dc; }
.memo-green { --memo-color: #dff1e7; }

.board-status { position: absolute; z-index: 12; left: 82px; bottom: 12px; display: flex; align-items: center; height: 34px; padding: 0 4px; border: 1px solid #8f8f8f; border-radius: 0; color: #555; background: #fff; box-shadow: 2px 2px 0 rgba(0,0,0,.08); font: 500 .7rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.board-status button { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 0; background: transparent; font-size: 1rem; cursor: pointer; }
.board-status button:hover { color: white; background: var(--ink); }
.board-status output { width: 43px; text-align: center; }
.status-divider { width: 1px; height: 18px; margin: 0 7px; background: #aaa; }
.drag-hint { padding-right: 5px; }
kbd { display: inline-flex; align-items: center; min-height: 20px; padding: 0 5px; border: 1px solid #888; border-radius: 0; color: #333; background: #fff; font: 600 .66rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.minimap { position: absolute; z-index: 11; right: 12px; bottom: 12px; width: 132px; height: 76px; overflow: hidden; border: 1px solid #777; border-radius: 0; background-color: #fff; background-image: linear-gradient(90deg, transparent 20%, #d4d4d4 20% 21%, transparent 21% 43%, #d4d4d4 43% 44%, transparent 44% 66%, #d4d4d4 66% 67%, transparent 67%), linear-gradient(#444 1px, transparent 1px); background-size: 100% 100%, 100% 22px; box-shadow: 2px 2px 0 rgba(0,0,0,.08); opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(6px); transition: opacity .14s ease, transform .14s ease, visibility 0s linear .14s; }
.board.viewport-moving .minimap { opacity: 1; visibility: visible; transform: translateY(0); transition-delay: 0s; }
.minimap-viewport { position: absolute; left: 12px; top: 8px; width: 72px; height: 44px; border: 1px solid var(--selection); border-radius: 0; background: rgba(25,89,209,.05); }

.inspector { position: absolute; z-index: 18; top: 0; right: 0; bottom: 0; display: flex; flex-direction: column; width: 310px; min-height: 440px; border: 0; border-left: 1px solid #777; border-radius: 0; background: #fff; box-shadow: -3px 0 0 rgba(0,0,0,.06); transform: translateX(100%); opacity: 1; pointer-events: none; transition: transform .16s ease; }
.inspector.open { transform: translateX(0); pointer-events: auto; }
.inspector-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 18px 17px 13px; border-bottom: 1px solid #aaa; }
.eyebrow { color: var(--accent); font: 700 .65rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .11em; }
.inspector h2 { margin: 6px 0 0; font-size: 1rem; letter-spacing: .01em; }
.inspector-form { display: grid; gap: 16px; padding: 17px; overflow: auto; }
.inspector-form label, .inspector-form legend { display: grid; gap: 7px; color: #555; font: 650 .7rem/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; }
.inspector-form input, .inspector-form textarea { width: 100%; border: 1px solid #aaa; border-radius: 0; padding: 10px; color: #222; background: #fff; font-size: .82rem; line-height: 1.55; resize: vertical; }
.inspector-form input:focus, .inspector-form textarea:focus { outline: 1px solid var(--selection); border-color: var(--selection); }
.body-editor-field { display: grid; gap: 7px; }
.body-editor-head { display: flex; align-items: center; gap: 7px; color: #555; font: 650 .7rem/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; }
.body-editor-head button { min-height: 26px; margin-left: auto; padding: 0 8px; border: 1px solid #cdd1d6; border-radius: 5px; color: #4e5762; background: #fff; cursor: pointer; font-size: .66rem; }
.body-editor-head button:hover { color: #fff; border-color: #39424d; background: #39424d; }
.body-editor-head output { min-width: 72px; color: #9298a1; font-size: .58rem; text-align: right; }
.body-editor-field textarea { min-height: 180px; max-height: 55vh; }
.inspector-form fieldset { margin: 0; padding: 0; border: 0; }
.color-options { display: flex; gap: 9px; margin-top: 8px; }
.swatch { width: 24px; height: 24px; border: 3px solid white; border-radius: 0; cursor: pointer; box-shadow: 0 0 0 1px #888; }
.swatch.active { box-shadow: 0 0 0 2px var(--ink); }
.swatch.blue { background: #1959d1; }.swatch.coral { background: #ff4e2f; }.swatch.green { background: #15724a; }.swatch.yellow { background: #d18a00; }
.inspector-footer { display: flex; justify-content: space-between; gap: 8px; margin-top: auto; padding: 12px; border-top: 1px solid #aaa; }
.empty-state { position: absolute; z-index: 7; left: 50%; top: 45%; width: 280px; transform: translate(-50%, -50%); padding: 28px; border: 1px solid #777; border-radius: 0; text-align: center; background: white; box-shadow: 4px 4px 0 rgba(0,0,0,.09); }
.empty-icon { display: grid; place-items: center; width: 42px; height: 42px; margin: 0 auto 14px; color: white; background: var(--ink); font-size: 1.3rem; }
.empty-state h2 { margin: 0 0 7px; font-size: 1rem; }.empty-state p { margin: 0 0 18px; color: var(--muted); font-size: .8rem; }

.toast-region { position: fixed; z-index: 80; left: 50%; bottom: 24px; transform: translateX(-50%); pointer-events: none; }
.toast { min-width: 230px; padding: 10px 14px; border: 1px solid #000; border-radius: 0; color: white; background: #191919; box-shadow: 3px 3px 0 rgba(0,0,0,.2); text-align: center; font-size: .78rem; animation: toast-in .15s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(5px); } }
.help-dialog { width: min(440px, calc(100vw - 32px)); padding: 0; border: 1px solid #333; border-radius: 0; color: var(--ink); box-shadow: 7px 7px 0 rgba(0,0,0,.18); }
.help-dialog::backdrop { background: rgba(0,0,0,.22); }
.help-dialog form { padding: 20px; }.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h2 { margin: 0; font-size: 1rem; }.shortcut-list { display: grid; gap: 13px; margin: 20px 0; }
.shortcut-list div { display: grid; grid-template-columns: 142px 1fr; align-items: center; gap: 12px; color: #555; font-size: .8rem; }
.shortcut-list kbd { justify-self: start; }.dialog-note { margin: 0; padding: 12px; border: 1px solid #bbb; border-radius: 0; color: #555; background: #f5f5f3; font-size: .74rem; line-height: 1.55; }
.local-project-dialog form { padding: 22px; }
.local-project-lead { margin: 16px 0 14px; color: #5f6670; font-size: .82rem; line-height: 1.55; }
.local-project-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.local-project-options button { display: grid; gap: 7px; min-height: 112px; padding: 15px; border: 1px solid #cfd3d9; border-radius: 8px; color: var(--ink); background: #fff; text-align: left; cursor: pointer; }
.local-project-options button:hover, .local-project-options button:focus-visible { border-color: #69727e; background: #f7f8fa; outline: none; }
.local-project-options strong { font-size: .86rem; }
.local-project-options span { color: #666e79; font-size: .72rem; line-height: 1.55; }
.folder-structure { margin: 14px 0 0; padding: 13px 15px; overflow: auto; border: 1px solid #dfe2e6; border-radius: 7px; color: #4e5661; background: #f6f7f8; font: 500 .72rem/1.65 ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Softer canvas and mind-map branch language */
:root { --canvas: #f7f7f6; --line: #dfe1e4; --selection: #2f5fce; }
.topbar { border-bottom-color: #e1e3e6; }
.brand-mark { border-color: #9fa3aa; border-radius: 4px; }
.button { border-radius: 6px; }
.icon-button { border-radius: 6px; }
.project-title { border-radius: 4px; }
.tool-rail { border-color: #d5d8dc; border-radius: 11px; box-shadow: 0 5px 18px rgba(27,31,40,.08); }
.tool { border-radius: 7px; }
.tool.active { color: #244fae; background: #edf2ff; }
.rail-divider { background: #e3e4e7; }
.board-grid { opacity: .72; background-image: radial-gradient(circle, #cdd0d4 1px, transparent 1.15px); background-size: 24px 24px; }
.timeline-label span { border-bottom-width: 2px; }
.connections .timeline-path { stroke: #aeb3ba; stroke-width: 2; }
.connections .timeline-halo { stroke: var(--canvas); stroke-width: 8; }
.connections .branch-path { stroke: #7a8492; stroke-width: 1.7; }
.connections circle { stroke: var(--canvas); stroke-width: 4; fill: #5b6573; }
.node-card { border-color: #d2d5da; border-radius: 8px; box-shadow: 0 4px 14px rgba(27,31,40,.09); }
.node-card.selected { z-index: 6; border-color: var(--selection); box-shadow: 0 0 0 3px rgba(47,95,206,.14), 0 5px 16px rgba(27,31,40,.1); }
.scene-card { border-radius: 10px; box-shadow: 0 5px 16px rgba(27,31,40,.1); }
.scene-card::before { border-radius: 10px 0 0 10px; }
.scene-card .branch-count { border-color: #cfd3d8; border-radius: 999px; box-shadow: 0 2px 6px rgba(27,31,40,.08); }
.node-label .dot { border-radius: 50%; }
.branch-card { width: 190px; min-height: 92px; padding: 11px 13px 12px; border: 0; border-bottom: 2px solid var(--node-color, var(--accent)); border-radius: 8px 8px 2px 2px; background: rgba(255,255,255,.96); box-shadow: 0 4px 13px rgba(27,31,40,.09); }
.branch-card::before { left: -6px; top: 43px; width: 9px; height: 9px; border: 2px solid var(--canvas); border-radius: 50%; background: var(--node-color, var(--accent)); box-shadow: 0 0 0 1px #aeb4bc; }
.branch-card .node-body { -webkit-line-clamp: 1; }
.branch-add { right: -12px; top: 35px; width: 24px; height: 24px; border-color: #c8ccd2; border-radius: 50%; color: #505864; box-shadow: 0 2px 7px rgba(27,31,40,.1); }
.branch-add:hover { color: white; background: #3d4652; }
.memo-card { border-color: #d5c890; border-radius: 4px; box-shadow: 0 4px 12px rgba(57,53,34,.1); }
.board-status { border-color: #d4d7db; border-radius: 8px; box-shadow: 0 3px 12px rgba(27,31,40,.08); }
.board-status button { border-radius: 5px; }
kbd { border-color: #ccd0d5; border-radius: 4px; }
.minimap { border-color: #d0d3d8; border-radius: 7px; box-shadow: 0 3px 12px rgba(27,31,40,.08); }
.minimap-viewport { border-radius: 3px; }
.inspector { top: 12px; right: 12px; bottom: 12px; width: 300px; border: 1px solid #d2d5da; border-radius: 12px; box-shadow: 0 10px 32px rgba(27,31,40,.13); transform: translateX(calc(100% + 20px)); }
.inspector-head { border-bottom-color: #e3e5e8; }
.inspector-form input, .inspector-form textarea { border-color: #d5d8dc; border-radius: 7px; background: #fbfbfb; }
.swatch { border-radius: 50%; box-shadow: 0 0 0 1px #c4c8ce; }
.inspector-footer { border-top-color: #e3e5e8; }
.empty-state { border-color: #d2d5da; border-radius: 12px; box-shadow: 0 8px 28px rgba(27,31,40,.12); }
.empty-icon { border-radius: 8px; }
.toast { border: 0; border-radius: 7px; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.help-dialog { border-color: #d1d4d8; border-radius: 12px; box-shadow: 0 18px 50px rgba(0,0,0,.2); }
.dialog-note { border-color: #e0e2e5; border-radius: 7px; }

/* Direct-manipulation editing */
.create-tool { cursor: grab; touch-action: none; }
.create-tool:active { cursor: grabbing; }
.board.placement-armed { cursor: crosshair; }
.board.drop-ready { box-shadow: inset 0 0 0 3px rgba(47,95,206,.16); }
.node-card { touch-action: none; }
.scene-card, .branch-card, .memo-card { min-height: 0; cursor: grab; }
.branch-card { height: 92px; }
.node-card.dragging-node { cursor: grabbing; }
.node-card.dragging-node, .node-card.resizing-node { z-index: 10; opacity: .9; box-shadow: 0 10px 30px rgba(27,31,40,.16); }
.node-card.drop-parent { box-shadow: 0 0 0 4px rgba(47,95,206,.2), 0 7px 22px rgba(27,31,40,.12); }
.node-card.reparent-target { z-index: 11; border-color: #2f5fce; box-shadow: 0 0 0 5px rgba(47,95,206,.18), 0 9px 26px rgba(27,31,40,.16); }
.node-card.reparent-target::after {
  content: "子にする"; position: absolute; z-index: 12; left: 50%; top: -13px; padding: 4px 8px;
  transform: translate(-50%, -100%); border-radius: 5px; color: #fff; background: #2f5fce;
  box-shadow: 0 4px 12px rgba(34,58,110,.22); font-size: .7rem; font-weight: 750; line-height: 1; white-space: nowrap;
}
.board.reparenting { cursor: grabbing; }
.branch-handle {
  position: absolute; z-index: 7; right: -9px; top: var(--anchor); width: 16px; height: 16px; padding: 0;
  transform: translateY(-50%); border: 3px solid var(--canvas); border-radius: 50%;
  background: var(--node-color, #5b6573); box-shadow: 0 0 0 1px #aeb4bc; cursor: crosshair; touch-action: none; opacity: 0;
}
.node-card:hover .branch-handle, .node-card.drop-parent .branch-handle { opacity: 1; }
.branch-handle::after { content: ""; position: absolute; inset: -8px; }
.branch-handle-bottom { right: auto; left: var(--anchor); top: auto; bottom: -9px; transform: translateX(-50%); }
.design-box-card.selected { outline: 1px solid rgba(49,95,199,.3); outline-offset: 3px; }
.resize-handle {
  position: absolute; z-index: 8; right: 3px; bottom: 3px; width: 22px; height: 22px;
  border-right: 3px solid #687382; border-bottom: 3px solid #687382; border-radius: 0 0 6px 0;
  cursor: nwse-resize; touch-action: none; opacity: 0;
}
.node-card:hover .resize-handle { opacity: 1; }
.branch-preview { stroke: #2f5fce !important; stroke-width: 2 !important; stroke-dasharray: 7 6; }
.placement-proxy {
  position: fixed; z-index: 100; min-width: 136px; padding: 10px 13px; transform: translate(-18px, -50%);
  border: 1px solid #c8cdd5; border-radius: 9px; color: #59616d; background: rgba(255,255,255,.92);
  box-shadow: 0 8px 25px rgba(27,31,40,.13); pointer-events: none; font-size: .78rem; font-weight: 700;
}
.placement-proxy.can-drop { color: #214ba8; border-color: #6f91dc; background: #f4f7ff; }
.placement-memo { background: #fff7cd; border-color: #d8c677; }
.numeric-fieldset { display: grid; gap: 8px; }
.numeric-fieldset[hidden] { display: none; }
.numeric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.numeric-grid label { gap: 5px; }
.numeric-grid input { padding: 8px 9px; font-variant-numeric: tabular-nums; }
.size-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.size-actions .button { border: 1px solid #d5d8dc; background: #fbfbfb; }
.size-actions .button:hover { color: #fff; border-color: #3d4652; background: #3d4652; }
.inspector-tip { max-width: 160px; color: #6d7480; font-size: .72rem; line-height: 1.45; text-align: right; }
.inspector-tip[hidden] { display: none; }
.shortcut-list div { grid-template-columns: 154px 1fr; }
.node-body { font-size: .82rem; }
.branch-card .node-body { font-size: .78rem; }
.aligned-mode .node-card { cursor: default; }
.aligned-mode .branch-handle { display: none; }
.aligned-mode .timeline-label small::after { content: " · 整列表示（位置固定）"; color: #244fae; }
.image-editor-launch { order: -1; border: 1px solid #ccd1d8; background: #f7f8fa; }

.image-context-menu { position: fixed; z-index: 120; min-width: 178px; padding: 5px; border: 1px solid #cfd3d8; border-radius: 9px; background: #fff; box-shadow: 0 12px 32px rgba(21,25,32,.2); }
.image-context-menu[hidden] { display: none; }
.image-context-menu button { display: block; width: 100%; padding: 9px 11px; border: 0; border-radius: 6px; text-align: left; color: #333b46; background: transparent; cursor: pointer; font-size: .76rem; }
.image-context-menu button:hover { color: #fff; background: #303740; }
.image-editor { width: min(980px, calc(100vw - 28px)); max-height: calc(100vh - 28px); padding: 0; border: 1px solid #cfd3d8; border-radius: 12px; box-shadow: 0 20px 60px rgba(16,20,27,.24); }
.image-editor::backdrop { background: rgba(17,20,25,.42); }
.image-editor form { padding: 18px; }
.image-editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 18px; margin: 16px 0; }
.image-preview { display: grid; place-items: center; min-height: 320px; overflow: auto; border: 1px solid #d7dbe0; border-radius: 8px; background-color: #f7f7f7; background-image: linear-gradient(45deg,#ddd 25%,transparent 25%),linear-gradient(-45deg,#ddd 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#ddd 75%),linear-gradient(-45deg,transparent 75%,#ddd 75%); background-size: 20px 20px; background-position: 0 0,0 10px,10px -10px,-10px 0; }
.image-preview canvas { display: block; max-width: 100%; max-height: 58vh; }
.image-editor-controls { display: grid; align-content: start; gap: 17px; color: #59616c; font-size: .75rem; line-height: 1.5; }
.image-editor-controls fieldset { margin: 0; padding: 12px; border: 1px solid #d8dce1; border-radius: 8px; }
.image-editor-controls legend { padding: 0 5px; font-weight: 700; }
.crop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.crop-grid label, .image-editor-controls > label { display: grid; gap: 5px; }
.image-editor-controls .check-row { display: flex; align-items: center; gap: 8px; }
.image-editor-controls p { margin: 0; color: #7a818b; }
.image-editor-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Refined editor shell */
:root {
  --ink: #20242b;
  --muted: #69717d;
  --canvas: #f6f7f8;
  --panel: #ffffff;
  --accent: #e94f37;
  --selection: #315fc7;
}
.topbar { grid-template-columns: 190px minmax(240px, 1fr) auto; padding: 0 12px; border-bottom-color: #e5e7ea; background: rgba(255,255,255,.98); }
.brand { gap: 9px; color: #252a32; font-size: .88rem; }
.brand-mark { width: 28px; height: 28px; border-color: #c3c7cd; box-shadow: 0 2px 5px rgba(25,30,38,.07); }
.project-heading { gap: 10px; }
.project-title { width: min(360px, 38vw); padding: 7px 9px; border: 1px solid transparent; border-radius: 7px; font-size: .9rem; }
.project-title:hover { border-color: #e0e3e7; background: #f8f9fa; }
.project-title:focus { border-color: #8eaae5; background: #fff; box-shadow: 0 0 0 3px rgba(49,95,199,.1); }
.save-state { padding: 4px 7px; border-radius: 999px; color: #747c87; background: #f4f5f6; font-size: .63rem; }
.save-state span { border-radius: 50%; }
.top-actions { gap: 3px; }
.history-actions { margin-right: 3px; padding-right: 6px; }
.button.button-ghost { min-height: 32px; border: 1px solid transparent; border-radius: 7px; }
.button.button-ghost:hover { border-color: #e1e4e8; background: #f5f6f7; }
.action-menu { position: relative; flex: 0 0 auto; }
.action-menu summary { list-style: none; cursor: pointer; }
.action-menu summary::-webkit-details-marker { display: none; }
.action-menu[open] summary { color: #244fae; border-color: #cbd7f2; background: #eef3ff; }
.action-menu-panel { position: absolute; z-index: 60; right: 0; top: calc(100% + 7px); display: grid; width: 206px; padding: 6px; border: 1px solid #d8dce2; border-radius: 10px; background: #fff; box-shadow: 0 14px 38px rgba(25,30,38,.18); }
.menu-action { display: grid; gap: 2px; width: 100%; padding: 9px 10px; border: 0; border-radius: 7px; text-align: left; background: transparent; cursor: pointer; }
.menu-action:hover, .menu-action:focus-visible { color: #234fae; outline: 0; background: #f1f5ff; }
.menu-action strong { font-size: .76rem; font-weight: 720; }
.menu-action small { color: #858c96; font-size: .65rem; }
.tool-rail { width: 62px; padding: 6px; border-color: #dfe2e6; border-radius: 14px; background: rgba(255,255,255,.98); box-shadow: 0 8px 28px rgba(25,30,38,.09); }
.tool { width: 48px; min-height: 50px; border-radius: 9px; color: #626a76; }
.tool:hover { color: #262c35; background: #f1f2f4; }
.tool.active { color: #244fae; background: #ebf1ff; box-shadow: inset 0 0 0 1px #cdd9f3; }
.board-grid { opacity: .62; background-image: radial-gradient(circle, #c9cdd3 1px, transparent 1.1px); }
.scene-card { border-color: #dfe2e6; box-shadow: 0 7px 20px rgba(30,36,45,.1); }
.branch-card { background: rgba(255,255,255,.98); box-shadow: 0 5px 16px rgba(30,36,45,.09); }
.node-card { transition: border-color .12s ease, box-shadow .12s ease, opacity .12s ease; }
.node-card.selected { box-shadow: 0 0 0 3px rgba(49,95,199,.13), 0 8px 22px rgba(30,36,45,.11); }
.node-card.dragging-node { opacity: .96; box-shadow: 0 16px 40px rgba(22,28,37,.19); }
.board-status { left: 86px; border-color: #dfe2e6; border-radius: 9px; box-shadow: 0 5px 18px rgba(25,30,38,.09); }
.interaction-hint { position: absolute; z-index: 15; left: 50%; top: 14px; display: flex; align-items: center; gap: 8px; padding: 8px 11px; transform: translate(-50%, -8px); border: 1px solid #d5dbe6; border-radius: 999px; color: #526071; background: rgba(255,255,255,.96); box-shadow: 0 8px 24px rgba(29,35,44,.12); opacity: 0; pointer-events: none; transition: opacity .12s ease, transform .12s ease; font-size: .72rem; }
.interaction-hint span { width: 7px; height: 7px; border: 2px solid #315fc7; border-radius: 50%; }
.board.tree-reparent-dragging .interaction-hint { opacity: 1; transform: translate(-50%, 0); }
.board.reparenting .interaction-hint { color: #fff; border-color: #315fc7; background: #315fc7; }
.board.reparenting .interaction-hint span { border-color: #fff; background: #fff; }
.inspector { border-color: #dfe2e6; box-shadow: 0 16px 46px rgba(25,30,38,.16); }
.toast { background: #242a33; }

@media (max-width: 820px) {
  .app-shell { grid-template-rows: 94px 1fr; }
  .topbar { grid-template-columns: auto 1fr; grid-template-areas: "brand project" "actions actions"; grid-template-rows: 44px 42px; gap: 0 8px; height: 94px; padding: 0 8px 7px; }
  .brand { grid-area: brand; }.project-heading { grid-area: project; }.top-actions { grid-area: actions; min-width: 0; overflow: visible; justify-content: space-between; gap: 2px; scrollbar-width: none; }
  .top-actions::-webkit-scrollbar { display: none; }
  .brand > span:last-child, .save-state, .button-ghost span { display: none; }
  .action-menu summary span { display: inline; }
  .action-menu-panel { right: 0; width: 196px; }
  .local-project-options { grid-template-columns: 1fr; }
  .project-title { width: 100%; text-align: left; }.history-actions { margin-right: 2px; padding-right: 2px; border-right: 0; }.top-actions .icon-button { width: 30px; }.compact-action { min-width: 38px; }.mode-switch { flex: 0 0 auto; }.mode-switch button { padding: 0 7px; }.tool-rail { top: auto; left: 50%; bottom: 10px; flex-direction: row; width: auto; max-width: calc(100vw - 12px); height: 58px; overflow-x: auto; transform: translateX(-50%); }
  .tool { flex: 0 0 48px; width: 48px; min-height: 46px; }.rail-divider { flex: 0 0 1px; width: 1px; height: 34px; margin: 0 2px; }.rail-spacer { display: none; }
  .board-status { left: 10px; bottom: 78px; }.drag-hint, .status-divider { display: none; }.minimap { display: none; }
  .interaction-hint { top: 10px; max-width: calc(100vw - 30px); white-space: nowrap; }
  .inspector { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: min(56vh, 490px); min-height: 0; border: 0; border-top: 1px solid #777; transform: translateY(100%); }
  .inspector.open { transform: translateY(-70px); }.scene-card { width: 216px; }
  .placement-proxy { min-width: 118px; }
  .timeline-label small { display: none; }
  .scene-order-actions { opacity: 0; }
  .node-card.selected .scene-order-actions, .node-card.selected .node-control-dock, .node-card.selected .branch-handle, .node-card.selected .resize-handle, .node-card.selected .image-edit-button, .node-card.selected .design-box-add { opacity: 1; pointer-events: auto; }
  .image-editor form { padding: 14px; }.image-editor-layout { grid-template-columns: 1fr; }.image-preview { min-height: 210px; }.image-editor-controls { grid-template-columns: 1fr 1fr; gap: 12px; }.image-editor-controls p { display: none; }
}

@media (max-width: 520px) {
  .image-editor-controls { grid-template-columns: 1fr; }
  .image-preview { min-height: 170px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; } }
