/* Candy — レイアウト: 上部バー + 左レール + サイドパネル + キャンバス + ページストリップ
   書体: UI は Inter（欧文・数字）+ Noto Sans JP（和文）、ワードマークは Cookie */
:root {
  --bg: #f4f3f9; --surface: #ffffff; --surface-2: #f3f1fa; --surface-3: #e9e6f4; --fg: #1d1b2e; --fg-2: #66647d; --fg-3: #9a98b0; --line: #e4e2ee; --line-2: #d3d0e3;
  --accent: #7d2ae8; --accent-hover: #6a1fd0; --accent-2: #00c4cc; --accent-soft: #f1eafe; --accent-text: #5e17b9; --danger: #e5484d;
  --canvas: #ebe9f3; --shadow: 0 12px 32px rgba(40, 20, 90, .14); --shadow-sm: 0 2px 8px rgba(40, 20, 90, .10); --radius: 12px; --radius-sm: 8px;
  --font-ui: "Inter", "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  --font-display: "Cookie", "Brush Script MT", cursive;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #15141d; --surface: #1e1d29; --surface-2: #27263a; --surface-3: #312f47; --fg: #ecebf5; --fg-2: #a9a7c2; --fg-3: #77758f; --line: #33324a; --line-2: #43415c; --accent: #a07cff; --accent-hover: #b18fff; --accent-soft: #2d2746; --accent-text: #c3abff; --canvas: #100f17; --shadow: 0 12px 32px rgba(0, 0, 0, .55); --shadow-sm: 0 2px 8px rgba(0, 0, 0, .4); color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #15141d; --surface: #1e1d29; --surface-2: #27263a; --surface-3: #312f47; --fg: #ecebf5; --fg-2: #a9a7c2; --fg-3: #77758f; --line: #33324a; --line-2: #43415c; --accent: #a07cff; --accent-hover: #b18fff; --accent-soft: #2d2746; --accent-text: #c3abff; --canvas: #100f17; --shadow: 0 12px 32px rgba(0, 0, 0, .55); --shadow-sm: 0 2px 8px rgba(0, 0, 0, .4); color-scheme: dark; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-ui); font-size: 13px; line-height: 1.5; overflow: hidden; font-feature-settings: "palt"; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg { fill: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.ico svg, .tb-btn svg, .btn svg { width: 18px; height: 18px; display: block; flex-shrink: 0; }
.logo svg { width: 34px; height: 34px; display: block; }
.logo.sm svg { width: 26px; height: 26px; }
.wordmark { font-family: var(--font-display); font-weight: 400; font-size: 34px; letter-spacing: 0; background: linear-gradient(90deg, #00c4cc, #7d2ae8); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1.1; }
.topbar .wordmark { background: none; -webkit-background-clip: initial; background-clip: initial; color: #fff; font-size: 30px; }
.num-mono { font-variant-numeric: tabular-nums; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== 共通部品 ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--fg); font-weight: 600; font-size: 13px; border: 1px solid transparent; white-space: nowrap; transition: background .12s, box-shadow .12s, transform .06s; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: var(--line-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.light { color: #fff; border-color: rgba(255, 255, 255, .5); }
.btn.light:hover { background: rgba(255, 255, 255, .16); }
.btn.primary.light { background: #fff; color: var(--accent-text); border-color: transparent; }
.btn.primary.light:hover { background: #f3edff; }
.btn.wide { width: 100%; margin: 6px 0; }
.btn:disabled, button.disabled { opacity: .45; cursor: default; }
.link { color: var(--accent-text); font-weight: 600; font-size: 12px; }
.link:hover { text-decoration: underline; }
.tb-btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-width: 32px; height: 32px; padding: 0 7px; border-radius: var(--radius-sm); color: var(--fg); transition: background .12s; flex-shrink: 0; }
.tb-btn:hover { background: var(--surface-2); }
.tb-btn.on { background: var(--accent-soft); color: var(--accent-text); }
.tb-btn.text { padding: 0 10px; font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.tb-btn.sm { min-width: 26px; height: 26px; border-radius: 6px; }
.tb-btn.sm svg { width: 16px; height: 16px; }
.tb-btn.font { max-width: 160px; min-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; line-height: 32px; padding: 0 10px; font-weight: 600; text-align: left; border: 1px solid var(--line); }
.tb-btn:disabled { opacity: .35; cursor: default; }
.tb-sep { width: 1px; height: 22px; background: var(--line); margin: 0 5px; display: inline-block; flex-shrink: 0; }
.tb-sep.light { background: rgba(255, 255, 255, .35); }
.tb-label { font-weight: 700; font-size: 12px; color: var(--fg-2); padding: 0 8px; white-space: nowrap; }
.color-dot { width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(0, 0, 0, .18); display: block; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); }
.num { width: 76px; padding: 7px 8px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); font-variant-numeric: tabular-nums; }
.num:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.num.sm { width: 58px; padding: 5px 6px; text-align: center; }
.num-field { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--fg-2); font-weight: 600; }
.search, .ta { width: 100%; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); margin-bottom: 12px; transition: border-color .12s, box-shadow .12s; }
.search:focus, .ta:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ta { resize: vertical; min-height: 72px; line-height: 1.6; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 6px 0; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 6px 0; }
.chip { padding: 5px 11px; border-radius: 999px; background: var(--surface-2); font-weight: 600; font-size: 12px; white-space: nowrap; border: 1px solid transparent; }
.chip:hover { background: var(--surface-3); }
.chip.on { background: var(--accent); color: #fff; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.chk input { accent-color: var(--accent); }
.hint { color: var(--fg-2); font-size: 12px; margin: 6px 0; line-height: 1.6; }
.empty { color: var(--fg-3); padding: 24px 8px; text-align: center; font-size: 12px; line-height: 1.6; }
.sec-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 12px; margin: 18px 0 8px; color: var(--fg-2); letter-spacing: .02em; }
.sec-head:first-child { margin-top: 2px; }
.tabs { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab { flex: 1; padding: 9px; font-weight: 600; color: var(--fg-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--fg); }
.tab.on { color: var(--accent-text); border-bottom-color: var(--accent); }
.sl { margin: 10px 0; }
.sl-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--fg-2); margin-bottom: 2px; font-weight: 600; }
.sl-val { font-variant-numeric: tabular-nums; color: var(--fg); }
.sl input[type=range] { width: 100%; accent-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; font-size: 12px; color: var(--fg-2); font-weight: 600; }
.field select { width: 100%; font-weight: 500; color: var(--fg); }
kbd { font-family: ui-monospace, Menlo, monospace; font-size: 11px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 6px; color: var(--fg-2); white-space: nowrap; }
.kbd-table { border-collapse: collapse; width: 100%; }
.kbd-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); }
.kbd-table td:first-child { width: 42%; }

/* ===== ホーム ===== */
#home { height: 100%; overflow: auto; }
.home-top { display: flex; align-items: center; justify-content: space-between; padding: 14px max(20px, env(safe-area-inset-right, 0px)) 14px max(20px, env(safe-area-inset-left, 0px)); }
.brand { display: flex; align-items: center; gap: 10px; }
.home-nav { display: flex; gap: 20px; }
.home-nav a { color: var(--fg-2); text-decoration: none; font-weight: 600; }
.home-nav a:hover { color: var(--accent-text); }
.hero { text-align: center; padding: 34px 20px 40px; background: linear-gradient(135deg, #00c4cc 0%, #4a6cf0 45%, #7d2ae8 100%); color: #fff; margin: 0 20px; border-radius: 24px; box-shadow: 0 20px 50px rgba(90, 50, 200, .22); }
.hero h1 { font-size: clamp(24px, 4vw, 40px); margin: 0 0 10px; font-weight: 900; text-wrap: balance; letter-spacing: -.01em; }
.hero-sub { margin: 0 auto 22px; max-width: 560px; opacity: .92; line-height: 1.7; }
.hero-search { position: relative; width: min(640px, 100%); margin: 0 auto; }
.hero-search .search-ico { position: absolute; left: 18px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); fill: #8b86a8; }
.hero-search input { width: 100%; padding: 15px 20px 15px 48px; border-radius: 999px; border: 0; font-size: 15px; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); color: #1d1b2e; background: #fff; }
.hero-search input:focus { outline: none; box-shadow: 0 10px 30px rgba(0, 0, 0, .18), 0 0 0 4px rgba(255, 255, 255, .45); }
.home-chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 26px; }
.home-chip { display: flex; flex-direction: column; align-items: center; gap: 7px; color: #fff; font-size: 11.5px; font-weight: 600; width: 86px; padding: 6px 2px; border-radius: 12px; line-height: 1.3; }
.home-chip:hover { background: rgba(255, 255, 255, .14); }
.chip-ico { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 22px; box-shadow: 0 6px 16px rgba(0, 0, 0, .18); transition: transform .15s; }
.home-chip:hover .chip-ico { transform: translateY(-3px) scale(1.05); }
.home-main { padding: 10px max(20px, env(safe-area-inset-right, 0px)) 40px max(20px, env(safe-area-inset-left, 0px)); max-width: 1400px; margin: 0 auto; }
.home-sec { margin-top: 36px; }
.home-sec-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.home-sec h2 { font-size: 18px; margin: 0; font-weight: 700; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }
.design-card { position: relative; cursor: pointer; }
.design-card.dim { opacity: .25; }
.design-thumb { width: 100%; max-height: 260px; border-radius: 12px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; transition: box-shadow .15s, transform .15s; }
.design-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.design-thumb .thumb-outer { max-width: 100%; }
.design-card:hover .design-thumb { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--line-2); }
.design-title { font-weight: 700; margin-top: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.design-meta { color: var(--fg-2); font-size: 11.5px; margin-top: 2px; }
.card-more { position: absolute; right: 8px; top: 8px; background: rgba(255, 255, 255, .92); color: #333; opacity: 0; box-shadow: var(--shadow-sm); }
.design-card:hover .card-more { opacity: 1; }
.size-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.size-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 8px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); text-align: center; transition: border-color .12s, box-shadow .12s; }
.size-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.size-box { width: 48px; max-height: 60px; border-radius: 6px; display: block; }
.size-name { font-weight: 700; }
.size-dim { color: var(--fg-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.home-foot { margin-top: 48px; color: var(--fg-3); font-size: 12px; text-align: center; }
.proj-ph { width: 100%; height: 100%; min-height: 80px; background: repeating-linear-gradient(45deg, var(--surface-2) 0 10px, var(--surface) 10px 20px); }

/* ===== エディタ骨格 ===== */
#editor { height: 100%; display: flex; flex-direction: column; }
.topbar { height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; background: linear-gradient(90deg, #00b8c4, #4a6cf0 50%, #7d2ae8); color: #fff; gap: 10px; flex-shrink: 0; }
.topbar .tb-btn { color: #fff; }
.topbar .tb-btn:hover { background: rgba(255, 255, 255, .18); }
.topbar .tb-btn.home { padding: 0 8px 0 4px; gap: 6px; }
.tb-group { display: flex; align-items: center; gap: 2px; min-width: 0; }
.tb-group.center { flex: 1; justify-content: center; }
.title-input { background: transparent; border: 1px solid transparent; color: #fff; font-weight: 600; padding: 6px 12px; border-radius: 8px; width: min(360px, 40vw); text-align: center; }
.title-input::placeholder { color: rgba(255, 255, 255, .7); }
.title-input:hover, .title-input:focus { border-color: rgba(255, 255, 255, .5); outline: none; background: rgba(255, 255, 255, .1); }
.save-status { font-size: 11px; opacity: .8; margin-left: 8px; white-space: nowrap; }
.save-status.err { color: #ffde59; opacity: 1; }
.workspace { flex: 1; display: flex; min-height: 0; position: relative; }
.rail { width: 76px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: stretch; padding: 8px 6px; gap: 2px; overflow-y: auto; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.rail-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 2px 7px; border-radius: 10px; font-size: 10.5px; color: var(--fg-2); font-weight: 600; line-height: 1.2; transition: background .12s, color .12s; }
.rail-btn svg { width: 22px; height: 22px; fill: var(--fg); transition: fill .12s; }
.rail-btn:hover { background: var(--surface-2); color: var(--fg); }
.rail-btn.active { background: var(--accent-soft); color: var(--accent-text); }
.rail-btn.active svg { fill: var(--accent); }
.sidepanel { width: 324px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; transition: width .15s; min-width: 0; }
.sidepanel.collapsed { width: 0; border: 0; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 10px 8px 18px; font-weight: 700; font-size: 15px; }
.panel-body { flex: 1; overflow-y: auto; padding: 4px 16px 28px; }
.canvas-area { flex: 1; display: flex; flex-direction: column; position: relative; min-width: 0; background: var(--canvas); }
.ctx-toolbar { height: 48px; display: flex; align-items: center; gap: 2px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; flex-shrink: 0; scrollbar-width: none; mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
.ctx-toolbar::-webkit-scrollbar { display: none; }
.size-ctl { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); margin: 0 2px; }
.size-ctl .tb-btn { min-width: 26px; height: 30px; border-radius: 6px; }
.size-ctl .num { border: 0; background: transparent; width: 48px; padding: 4px 2px; text-align: center; font-weight: 600; }
.canvas-scroll { flex: 1; overflow: auto; position: relative; background-image: radial-gradient(var(--line-2) .8px, transparent .8px); background-size: 22px 22px; }
.canvas-scroll[data-tool="pen"], .canvas-scroll[data-tool="marker"], .canvas-scroll[data-tool="highlighter"] { cursor: crosshair; }
.canvas-scroll[data-tool="eraser"] { cursor: not-allowed; }
.page-holder { position: relative; box-shadow: 0 6px 28px rgba(20, 10, 60, .18), 0 1px 3px rgba(0, 0, 0, .08); background: #fff; }
.page-surface { position: relative; overflow: hidden; transform-origin: 0 0; background: #fff; }
.overlay { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.overlay > * { position: absolute; }
.sel-box { border: 2px solid var(--accent); box-sizing: border-box; pointer-events: none; transform-origin: center; }
.sel-box.multi { border-style: dashed; border-width: 1px; }
.sel-box.group { border: 2px solid var(--accent); }
.sel-box.locked { border-color: #9ca3af; border-style: dashed; }
.handle { position: absolute; width: 12px; height: 12px; background: #fff; border: 2px solid var(--accent); border-radius: 50%; pointer-events: auto; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); touch-action: none; }
.handle:hover { transform: scale(1.2); }
.h-nw { left: -7px; top: -7px; cursor: nwse-resize; } .h-ne { right: -7px; top: -7px; cursor: nesw-resize; } .h-se { right: -7px; bottom: -7px; cursor: nwse-resize; } .h-sw { left: -7px; bottom: -7px; cursor: nesw-resize; }
.h-n, .h-s { left: 50%; margin-left: -11px; width: 22px; height: 8px; border-radius: 4px; cursor: ns-resize; } .h-n { top: -5px; } .h-s { bottom: -5px; }
.h-e, .h-w { top: 50%; margin-top: -11px; height: 22px; width: 8px; border-radius: 4px; cursor: ew-resize; } .h-e { right: -5px; } .h-w { left: -5px; }
.h-n:hover, .h-s:hover, .h-e:hover, .h-w:hover { transform: none; background: var(--accent-soft); }
.rot-handle { position: absolute; left: 50%; bottom: -36px; width: 24px; height: 24px; margin-left: -12px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); pointer-events: auto; cursor: grab; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); touch-action: none; }
.rot-handle::before { content: ''; position: absolute; left: 50%; top: -12px; width: 2px; height: 12px; background: var(--accent); margin-left: -1px; }
.rot-handle::after { content: '⟳'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 14px; color: var(--accent); font-weight: 700; }
.rot-handle:active { cursor: grabbing; }
.guide { background: #ff2bd6; pointer-events: none; box-shadow: 0 0 0 .5px rgba(255, 255, 255, .6); }
.guide.v { width: 1px; top: 0; bottom: 0; } .guide.h { height: 1px; left: 0; right: 0; }
.marquee { border: 1px solid var(--accent); background: rgba(125, 42, 232, .08); }
.drag-label { transform: translateX(-50%); background: #1d1b2e; color: #fff; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; white-space: nowrap; font-variant-numeric: tabular-nums; box-shadow: var(--shadow-sm); pointer-events: none; }
.draw-preview { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.mini-toolbar { position: absolute; display: flex; gap: 2px; padding: 3px; background: var(--surface); border-radius: 10px; box-shadow: var(--shadow); border: 1px solid var(--line); z-index: 5; }
.mini-toolbar .tb-btn { height: 28px; min-width: 28px; }

/* 要素 */
.el { position: absolute; transform-origin: center; user-select: none; -webkit-user-select: none; touch-action: none; cursor: move; }
.el-inner { width: 100%; height: 100%; }
.canvas-scroll[data-tool="select"] .el:hover { outline: 1.5px solid var(--accent); outline-offset: 0; }
.el.locked { cursor: default; }
.el.locked:hover { outline-color: #9ca3af; }
.el.hidden-el { display: none; }
.el.editing { cursor: text; outline: none !important; }
.el-text .txt-wrap { width: 100%; height: 100%; }
.el-text .txt { width: 100%; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; outline: none; cursor: inherit; min-height: 1em; }
.el.editing .txt { cursor: text; user-select: text; -webkit-user-select: text; }
.el-text .txt[contenteditable="true"] { caret-color: var(--accent); }
.el-image img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.shape-text { position: absolute; inset: 7%; display: flex; align-items: center; justify-content: center; text-align: center; white-space: pre-wrap; word-break: break-word; outline: none; line-height: 1.25; }
.el.editing .shape-text { user-select: text; -webkit-user-select: text; cursor: text; }
.tbl { width: 100%; height: 100%; border-collapse: collapse; table-layout: fixed; }
.tbl td { padding: 0 .5em; vertical-align: middle; overflow: hidden; white-space: pre-wrap; outline: none; }
.thumb-outer { overflow: hidden; position: relative; border-radius: 4px; background: #fff; }
.thumb-inner { pointer-events: none; }
.thumb-inner .el { cursor: default; }

/* ボトムバー / ページストリップ */
.notes-bar { background: var(--surface); border-top: 1px solid var(--line); padding: 8px 12px; }
.notes-bar textarea { width: 100%; height: 64px; border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; resize: none; background: var(--surface); line-height: 1.6; }
.notes-bar textarea:focus { outline: none; border-color: var(--accent); }
.bottombar { height: 40px; display: flex; align-items: center; justify-content: space-between; padding: 0 10px; background: var(--surface); border-top: 1px solid var(--line); flex-shrink: 0; gap: 8px; }
.bb-left, .bb-right { display: flex; align-items: center; gap: 2px; }
#zoom-range { width: 110px; accent-color: var(--accent); }
.page-indicator { font-variant-numeric: tabular-nums; color: var(--fg-2); padding: 0 8px; font-weight: 600; font-size: 12px; }
#timer-display { font-variant-numeric: tabular-nums; color: var(--accent-text); }
.pages-strip { height: 116px; display: flex; align-items: center; gap: 10px; padding: 8px 16px; overflow-x: auto; background: var(--surface); border-top: 1px solid var(--line); flex-shrink: 0; }
.page-thumb { position: relative; flex-shrink: 0; border: 2px solid transparent; border-radius: 10px; padding: 3px; cursor: pointer; transition: border-color .12s, background .12s; }
.page-thumb:hover { background: var(--surface-2); }
.page-thumb .thumb-outer { max-height: 84px; box-shadow: var(--shadow-sm); }
.page-thumb.on { border-color: var(--accent); }
.page-thumb.over { border-color: var(--accent-2); }
.page-num { position: absolute; left: 8px; top: 8px; background: rgba(29, 27, 46, .7); color: #fff; font-size: 10px; padding: 1px 6px; border-radius: 999px; font-variant-numeric: tabular-nums; font-weight: 600; }
.page-more { position: absolute; right: 6px; top: 6px; background: rgba(255, 255, 255, .92); color: #333; opacity: 0; box-shadow: var(--shadow-sm); }
.page-thumb:hover .page-more { opacity: 1; }
.page-add { flex-shrink: 0; width: 64px; height: 90px; border-radius: 10px; border: 2px dashed var(--line-2); display: grid; place-items: center; color: var(--fg-2); transition: border-color .12s, color .12s, background .12s; }
.page-add:hover { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
.gridview { position: absolute; inset: 52px 0 0 0; background: var(--bg); z-index: 20; overflow: auto; padding: 24px; }
.grid-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; font-size: 15px; }
.grid-pages { display: flex; flex-wrap: wrap; gap: 20px; }
.grid-page { border: 3px solid transparent; border-radius: 12px; padding: 4px; cursor: pointer; background: var(--surface); box-shadow: var(--shadow-sm); transition: border-color .12s, transform .12s; }
.grid-page:hover { transform: translateY(-2px); }
.grid-page.on { border-color: var(--accent); }
.grid-page.over { border-color: var(--accent-2); }
.grid-page.add { width: 248px; min-height: 140px; display: grid; place-items: center; border: 2px dashed var(--line-2); color: var(--fg-2); box-shadow: none; background: transparent; }
.grid-label { text-align: center; color: var(--fg-2); font-size: 12px; margin-top: 6px; font-weight: 600; }

/* ===== パネル内部品 ===== */
.tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tpl-card { cursor: pointer; }
.tpl-card .thumb-outer { border: 1px solid var(--line); max-height: 220px; transition: box-shadow .15s, transform .15s; }
.tpl-card:hover .thumb-outer { box-shadow: var(--shadow); transform: translateY(-2px); }
.tpl-name { font-weight: 700; font-size: 12px; margin-top: 6px; }
.tpl-meta { color: var(--fg-2); font-size: 11px; }
.el-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.el-item { aspect-ratio: 1; border-radius: 10px; background: var(--surface-2); padding: 10px; display: grid; place-items: center; transition: background .12s, transform .1s; }
.el-item:hover { background: var(--accent-soft); transform: scale(1.06); }
.el-item.on { outline: 2px solid var(--accent); }
.el-item svg { width: 100%; height: 100%; fill: var(--fg); }
.el-item.sticker { font-size: 26px; padding: 4px; }
.el-item.table-item { font-weight: 700; font-size: 12px; }
.txt-preset { display: block; width: 100%; text-align: left; padding: 12px 14px; margin: 6px 0; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); transition: border-color .12s, box-shadow .12s; }
.txt-preset:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.combo-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.combo-card { text-align: center; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); transition: border-color .12s, box-shadow .12s; }
.combo-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.drop-zone { border: 2px dashed var(--line-2); border-radius: 12px; padding: 24px 10px; text-align: center; cursor: pointer; color: var(--fg-2); display: flex; flex-direction: column; gap: 4px; align-items: center; transition: border-color .12s, background .12s; }
.drop-zone .ico { font-size: 24px; }
.drop-zone.over, .drop-zone:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.upload-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.upload-grid.small { grid-template-columns: repeat(4, 1fr); }
.upload-card { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface-2); cursor: pointer; }
.upload-card img, .bg-img { width: 100%; height: 100%; object-fit: cover; display: block; aspect-ratio: 1; border-radius: 10px; cursor: pointer; transition: transform .12s; }
.upload-card:hover img, .bg-img:hover { transform: scale(1.04); }
.upload-card .del { position: absolute; right: 4px; top: 4px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff; opacity: 0; }
.upload-card:hover .del { opacity: 1; }
.tool-row { display: flex; gap: 6px; flex-wrap: wrap; }
.tool-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; width: 58px; border-radius: 10px; background: var(--surface-2); font-size: 10px; font-weight: 600; }
.tool-btn .ico { font-size: 20px; }
.tool-btn.active { background: var(--accent-soft); color: var(--accent-text); outline: 2px solid var(--accent); }
.cp { width: 280px; }
.cp-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cp-add { width: 32px; height: 32px; border-radius: 50%; background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); color: #fff; display: grid; place-items: center; font-weight: 900; cursor: pointer; position: relative; overflow: hidden; text-shadow: 0 0 3px #000; flex-shrink: 0; }
.cp-add input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.cp-native-inline { width: 30px; height: 30px; border: 0; padding: 0; background: none; cursor: pointer; }
.cp-hex { flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: 8px; font-family: ui-monospace, Menlo, monospace; background: var(--surface); }
.cp-none { width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--line-2); background: linear-gradient(45deg, transparent 45%, #f00 45%, #f00 55%, transparent 55%); flex-shrink: 0; }
.cp-sec { margin-top: 10px; }
.cp-title { font-size: 11px; color: var(--fg-2); font-weight: 700; margin: 8px 0 6px; }
.cp-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 30px; height: 30px; border-radius: 8px; border: 1px solid rgba(0, 0, 0, .12); cursor: pointer; transition: transform .1s; }
.swatch:hover { transform: scale(1.12); }
.swatch.on { outline: 2px solid var(--accent); outline-offset: 1px; }
.fp { width: 300px; }
.fp-search { width: 100%; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 8px; margin-bottom: 8px; background: var(--surface); }
.fp-list { max-height: 360px; overflow-y: auto; }
.fp-list.static { max-height: none; }
.fp-item { display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; font-size: 15px; }
.fp-item:hover { background: var(--surface-2); }
.fp-item.on { background: var(--accent-soft); color: var(--accent-text); }
.fp-sample { color: var(--fg-3); font-size: 13px; }
.fx-grid, .filter-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fx-item, .filter-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 4px; border-radius: 10px; border: 2px solid transparent; background: var(--surface-2); font-size: 11px; font-weight: 600; transition: border-color .12s; }
.fx-item:hover, .filter-item:hover { border-color: var(--line-2); }
.fx-item.on, .filter-item.on { border-color: var(--accent); }
.fx-sample { height: 54px; width: 100%; display: grid; place-items: center; font-weight: 900; font-size: 30px; border-radius: 6px; background: #fff; color: #333; overflow: hidden; }
.fx-sample.box { width: 44px; height: 44px; background: var(--accent); border-radius: 8px; margin: 5px; }
.filter-item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px; }
.layer-list { display: flex; flex-direction: column; gap: 3px; }
.layer { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.layer:hover { background: var(--surface-2); }
.layer.on { background: var(--accent-soft); }
.layer.hid { opacity: .5; }
.layer.over { border-color: var(--accent); }
.layer.dragging { opacity: .4; }
.layer-prev { width: 28px; height: 28px; border-radius: 6px; background: var(--surface-2); overflow: hidden; flex-shrink: 0; border: 1px solid var(--line); }
.layer-prev img { width: 100%; height: 100%; object-fit: cover; }
.layer-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.proj-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.proj-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; transition: border-color .12s; }
.proj-card:hover { border-color: var(--line-2); background: var(--surface-2); }
.proj-card.on { border-color: var(--accent); background: var(--accent-soft); }
.proj-card img, .proj-card .proj-ph { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.proj-info { flex: 1; min-width: 0; }
.proj-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-meta { color: var(--fg-2); font-size: 11px; }
.ai-intro { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--fg); margin-bottom: 10px; font-size: 12px; line-height: 1.6; }
.ai-intro .ico svg { fill: var(--accent); }
.ai-out { margin-top: 12px; padding: 12px; border-radius: 10px; background: var(--surface-2); white-space: pre-wrap; min-height: 40px; line-height: 1.7; }
.ai-out.busy { color: var(--fg-2); }
.ai-out:empty { display: none; }

/* ポップオーバー / メニュー / モーダル / トースト */
.popover { position: fixed; z-index: 1000; background: var(--surface); color: var(--fg); border-radius: 12px; box-shadow: 0 14px 40px rgba(0, 0, 0, .22); border: 1px solid var(--line); padding: 6px; max-height: calc(100vh - 20px); overflow: auto; animation: pop-in .12s ease; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } }
.popover.pad { padding: 14px; min-width: 240px; }
.popover.menu { min-width: 220px; padding: 6px; }
.menu-item { display: flex; justify-content: space-between; align-items: center; gap: 20px; width: 100%; text-align: left; padding: 8px 12px; border-radius: 8px; }
.menu-item:hover { background: var(--surface-2); }
.menu-item.disabled { opacity: .4; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.stroke-pop { width: 260px; }
.resize-pop { width: 340px; }
.resize-list { max-height: 240px; overflow-y: auto; margin-bottom: 8px; }
.resize-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 6px 8px; border-radius: 8px; }
.resize-item:hover { background: var(--surface-2); }
.resize-item .size-box { width: 28px; max-height: 32px; }
.resize-item small { color: var(--fg-2); }
.share-pop { width: 320px; }
.share-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.share-item { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border-radius: 10px; background: var(--surface-2); font-size: 11px; font-weight: 600; text-align: center; }
.share-item:hover { background: var(--accent-soft); }
.share-ico { font-size: 22px; }
.modal { position: fixed; inset: 0; background: rgba(20, 10, 50, .45); display: grid; place-items: center; z-index: 2000; padding: 16px; backdrop-filter: blur(2px); }
.modal-box { background: var(--surface); color: var(--fg); border-radius: 16px; width: min(480px, 100%); box-shadow: var(--shadow); animation: pop-in .15s ease; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 6px; font-size: 15px; }
.modal-body { padding: 6px 18px; max-height: 60vh; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 18px; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: #1d1b2e; color: #fff; padding: 10px 18px; border-radius: 999px; opacity: 0; transition: .2s; z-index: 3000; pointer-events: none; font-weight: 600; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* プレゼンテーション */
.present { position: fixed; inset: 0; background: #000; z-index: 1500; display: flex; align-items: center; justify-content: center; flex-direction: column; }
.present-stage { position: relative; overflow: hidden; animation: trans-fade .5s ease; }
.present-page { transform-origin: 0 0; }
.present-nav { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; color: #fff; background: rgba(0, 0, 0, .5); padding: 6px 12px; border-radius: 999px; opacity: .25; transition: .2s; }
.present:hover .present-nav { opacity: 1; }
.present-notes { position: absolute; left: 20px; bottom: 60px; max-width: 40%; background: rgba(0, 0, 0, .6); color: #fff; padding: 10px 14px; border-radius: 10px; font-size: 14px; white-space: pre-wrap; opacity: .85; }
.trans-fade { animation: trans-fade .5s ease; } .trans-slide { animation: trans-slide .5s ease; } .trans-zoom { animation: trans-zoom .5s ease; } .trans-flip { animation: trans-flip .6s ease; } .trans-none { animation: none; }
@keyframes trans-fade { from { opacity: 0; } }
@keyframes trans-slide { from { transform: translateX(60px); opacity: 0; } }
@keyframes trans-zoom { from { transform: scale(.9); opacity: 0; } }
@keyframes trans-flip { from { transform: perspective(1200px) rotateY(60deg); opacity: 0; } }
.anim-fade { animation: a-fade .7s both; } .anim-rise { animation: a-rise .7s cubic-bezier(.2, .8, .2, 1) both; } .anim-pan { animation: a-pan .7s cubic-bezier(.2, .8, .2, 1) both; }
.anim-pop { animation: a-pop .6s cubic-bezier(.3, 1.6, .5, 1) both; } .anim-wipe { animation: a-wipe .7s ease both; } .anim-blur { animation: a-blur .8s ease both; }
.anim-tumble { animation: a-tumble .8s cubic-bezier(.2, .8, .2, 1) both; } .anim-breathe { animation: a-breathe 1.2s ease both; } .anim-baseline { animation: a-baseline .7s ease both; }
@keyframes a-fade { from { opacity: 0; } }
@keyframes a-rise { from { opacity: 0; translate: 0 40px; } }
@keyframes a-pan { from { opacity: 0; translate: -60px 0; } }
@keyframes a-pop { from { opacity: 0; scale: .3; } }
@keyframes a-wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes a-blur { from { opacity: 0; filter: blur(20px); } }
@keyframes a-tumble { from { opacity: 0; rotate: -25deg; translate: -40px 40px; } }
@keyframes a-breathe { 0% { opacity: 0; scale: .85; } 60% { scale: 1.04; } 100% { opacity: 1; scale: 1; } }
@keyframes a-baseline { from { opacity: 0; clip-path: inset(100% 0 0 0); translate: 0 20px; } to { clip-path: inset(0 0 0 0); } }
.el.anim-fade, .el.anim-rise, .el.anim-pan, .el.anim-pop, .el.anim-wipe, .el.anim-blur, .el.anim-tumble, .el.anim-breathe, .el.anim-baseline { animation-fill-mode: backwards; }
@media (prefers-reduced-motion: reduce) { .el[class*="anim-"], .present-stage, .popover, .modal-box { animation: none !important; } }

/* レスポンシブ（狭い画面） */
@media (max-width: 1100px) { .btn-present-label { display: none; } .save-status { display: none; } }
@media (max-width: 900px) {
  .sidepanel { position: absolute; left: 76px; top: 0; bottom: 0; z-index: 10; width: min(324px, calc(100vw - 76px)); box-shadow: var(--shadow); }
  .sidepanel.collapsed { width: 0; }
  .home-nav { display: none; }
  .title-input { width: 36vw; }
}
@media (max-width: 600px) {
  .rail { width: 60px; padding: 6px 3px; } .rail-btn { font-size: 9px; padding: 8px 1px 6px; } .rail-btn svg { width: 20px; height: 20px; }
  .sidepanel { left: 60px; width: calc(100vw - 60px); }
  .tb-group.center { display: none; }
  .topbar .wordmark { display: none; }
  .pages-strip { height: 88px; padding: 6px 10px; } .page-thumb .thumb-outer { max-height: 60px; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  #zoom-range { display: none; }
  .el-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 600px) {
  #btn-help, #btn-redo, .topbar .tb-sep { display: none; }
  .topbar { padding: 0 8px; } .topbar .btn { padding: 6px 10px; }
}

/* アカウント */
.home-right { display: flex; align-items: center; gap: 18px; }
.auth-area { display: flex; align-items: center; gap: 8px; }
.avatar-btn { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; font-weight: 600; }
.avatar-btn:hover { background: var(--surface-2); }
.avatar-btn.light { color: #fff; padding: 2px; }
.avatar-btn.light:hover { background: rgba(255, 255, 255, .18); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, #00c4cc, #7d2ae8); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.avatar-btn.light .avatar { background: #fff; color: var(--accent-text); }
.avatar-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-block; margin-left: 6px; padding: 0 7px; border-radius: 999px; font-size: 10px; font-weight: 700; line-height: 16px; vertical-align: middle; }
.badge.cloud { background: var(--accent-soft); color: var(--accent-text); }
.badge.local { background: var(--surface-3); color: var(--fg-2); }
.auth-form .search { margin-bottom: 10px; }
.form-error { color: var(--danger); font-size: 12px; min-height: 18px; margin: 2px 0 6px; font-weight: 600; }
.form-error:empty { display: none; }
@media (max-width: 600px) { .avatar-name { display: none; } .auth-area .btn { padding: 6px 10px; } }

/* ログインゲート */
#gate { height: 100%; overflow: auto; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); background: linear-gradient(135deg, #00c4cc 0%, #4a6cf0 45%, #7d2ae8 100%); }
.gate-card { width: min(420px, 100%); background: var(--surface); color: var(--fg); border-radius: 20px; padding: 28px 26px 22px; box-shadow: 0 24px 60px rgba(20, 10, 60, .35); }
.gate-brand { justify-content: center; margin-bottom: 6px; }
.gate-lead { text-align: center; color: var(--fg-2); margin: 0 0 16px; font-size: 13px; }
.gate-card .auth-form .search { margin-bottom: 10px; }
.serial-input { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .08em; font-size: 15px; text-align: center; }
