/* DesignStudio — styles */
:root {
  --bg: #0e1016; --bg-2: #151922; --bg-3: #1d2230; --bg-4: #262c3b; --line: #2b3243; --line-2: #3a4358;
  --text: #eef0f6; --muted: #8b93a7; --faint: #5e667a;
  --accent: #6ea8ff; --accent-2: #8b7cff; --accent-ink: #0c1220;
  --danger: #ff6b7a; --ok: #3dd68c; --warn: #f5c542;
  --shadow: 0 18px 50px rgba(0, 0, 0, .5);
  --radius: 10px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 13px/1.4 var(--font); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .4; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.app { height: 100%; }
.ic { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 11.5px; margin: 6px 0; line-height: 1.45; }
.hint.error, .error { color: var(--danger); }
.hint.inline { margin: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; flex-shrink: 0; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-2); background: var(--bg-3); color: var(--text); padding: 7px 12px; border-radius: 8px; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: #56617c; background: var(--bg-4); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: #86b7ff; }
.btn.danger { color: var(--danger); border-color: #5a2a32; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--bg-3); }
.btn.small { padding: 5px 9px; font-size: 12px; }
.btn.icon-only { padding: 5px 6px; }
.btn.wide { width: 100%; }
.icon-btn { width: 30px; height: 30px; border: 0; background: transparent; color: var(--text); border-radius: 7px; display: inline-grid; place-items: center; flex-shrink: 0; }
.icon-btn:hover:not(:disabled) { background: var(--bg-3); }
.icon-btn.on { background: #243150; color: var(--accent); }
.icon-btn.tiny { width: 24px; height: 24px; color: var(--muted); }
.icon-btn.tiny.on { background: transparent; color: var(--warn); }
.chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line-2); background: var(--bg-3); border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; }
.chip.on { background: #243150; border-color: var(--accent); color: var(--accent); }
.chip.small { padding: 3px 8px; font-size: 11px; }

/* ---------- home ---------- */
.home { height: 100%; display: flex; flex-direction: column; background: radial-gradient(1200px 500px at 10% -10%, #6ea8ff18, transparent), radial-gradient(900px 400px at 90% 0%, #8b7cff14, transparent), var(--bg); }
.home-hero { padding: 36px 56px 8px; display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; gap: 14px; align-items: center; }
.logo-mark { width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; font-weight: 800; font-size: 18px; color: var(--accent-ink); }
.brand h1 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.home-actions { display: flex; gap: 8px; }
.home-body { padding: 4px 56px 56px; overflow: auto; flex: 1; min-height: 0; }
.section-title { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; margin: 28px 0 12px; font-weight: 600; }
.size-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.size-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-align: left; min-height: 96px; display: flex; flex-direction: column; gap: 3px; transition: border-color .12s, transform .12s; }
.size-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.size-card b { font-size: 13px; }
.size-card span { color: var(--muted); font-size: 11px; }
.ratio { height: 38px; margin-bottom: 8px; border-radius: 5px; background: #0b0d12; border: 1px solid #262d3c; display: grid; place-items: center; }
.ratio i { display: block; background: #cfd5e4; border-radius: 1px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.doc-card { position: relative; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.doc-card:hover { border-color: var(--line-2); }
.doc-open { display: flex; flex-direction: column; gap: 3px; width: 100%; background: none; border: 0; padding: 10px; text-align: left; }
.doc-open b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-open span { color: var(--muted); font-size: 11px; }
.thumb { height: 130px; border-radius: 8px; background: #0b0d12; display: grid; place-items: center; color: var(--faint); margin-bottom: 6px; overflow: hidden; }
.thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.card-x, .card-tools { position: absolute; top: 14px; right: 14px; background: #0e1016cc; border-radius: 7px; opacity: 0; transition: opacity .12s; display: flex; }
.doc-card:hover .card-x, .doc-card:hover .card-tools, .card-x:focus-visible { opacity: 1; }
.foot { margin-top: 32px; }
.notice { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--bg-3); border: 1px solid var(--line-2); margin: 10px 0; }
.notice.warn { border-color: #6b5a1d; color: #f3dc8c; }

/* ---------- editor frame ---------- */
.editor { height: 100%; display: grid; grid-template-rows: 48px 38px minmax(0, 1fr) 44px; }
.editor.preview-mode { grid-template-rows: minmax(0, 1fr); }
.editor.preview-mode .topbar, .editor.preview-mode .alignbar, .editor.preview-mode .tools, .editor.preview-mode .panel, .editor.preview-mode .statusbar { display: none; }
.editor.preview-mode .workspace { grid-template-columns: minmax(0, 1fr); }
.topbar, .alignbar, .statusbar { background: var(--bg-2); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 4px; padding: 0 10px; min-width: 0; }
.alignbar { gap: 2px; }
.alignbar .lbl { color: var(--muted); font-size: 12px; margin-right: 4px; }
.statusbar { border-top: 1px solid var(--line); border-bottom: 0; }
.doc-title { background: transparent; border: 1px solid transparent; min-width: 120px; width: 260px; padding: 6px 8px; border-radius: 6px; font-weight: 600; }
.doc-title:hover, .doc-title:focus { background: var(--bg-3); border-color: var(--line-2); outline: none; }
/* host title (open.title) above the design name */
.title-stack { display: flex; flex-direction: column; min-width: 0; justify-content: center; }
.title-stack .host-title { font-size: 11px; line-height: 1.2; color: var(--muted); padding: 0 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.title-stack .doc-title { padding-top: 1px; padding-bottom: 3px; }
.save-state { color: var(--faint); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.workspace { display: grid; grid-template-columns: 48px 272px minmax(0, 1fr) 300px; min-height: 0; }
.tools { background: var(--bg-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 8px 0; gap: 3px; overflow: auto; }
.tools .icon-btn { width: 34px; height: 34px; }
.panel { background: var(--bg-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.panel.right { border-right: 0; border-left: 1px solid var(--line); }
.tabs { display: flex; border-bottom: 1px solid var(--line); flex-shrink: 0; background: #131722; }
.tab { flex: 1; display: flex; gap: 6px; align-items: center; justify-content: center; background: transparent; border: 0; padding: 11px 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.panel-body { padding: 12px 14px 32px; overflow: auto; flex: 1; min-height: 0; }
.canvas-host { position: relative; min-width: 0; min-height: 0; }
.pages { display: flex; align-items: center; gap: 6px; overflow-x: auto; min-width: 0; flex: 0 1 auto; max-width: 55%; padding: 2px 0; }
.page-pill { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line-2); background: var(--bg-3); border-radius: 999px; padding: 4px 11px; font-size: 12px; white-space: nowrap; max-width: 180px; }
.page-pill span { overflow: hidden; text-overflow: ellipsis; }
.page-pill b { color: var(--muted); font-weight: 600; }
.page-pill.on { border-color: var(--accent); color: var(--accent); }
.zoom { min-width: 58px; }

/* ---------- inspector ---------- */
.insp-section { padding: 10px 0 12px; border-bottom: 1px solid var(--line); }
.insp-section:last-child { border-bottom: 0; }
.insp-section h3 { margin: 0 0 8px; font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.insp-section h4 { margin: 12px 0 2px; font-size: 12px; }
.insp-head { display: flex; gap: 8px; align-items: center; padding-bottom: 8px; border-bottom: 1px solid var(--line); color: var(--muted); }
.insp-head .input { font-weight: 600; color: var(--text); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; min-width: 0; }
.field > span { font-size: 11px; color: var(--muted); }
.input { width: 100%; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 6px; padding: 6px 8px; min-width: 0; }
.input:focus { border-color: var(--accent); outline: none; }
textarea.input { resize: vertical; min-height: 54px; line-height: 1.4; }
select.input { padding: 5px 6px; }
.num-field { position: relative; }
.num-field em { position: absolute; right: 8px; bottom: 7px; font-style: normal; color: var(--faint); font-size: 11px; pointer-events: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 8px; }
.row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.row.wrap { flex-wrap: wrap; }
.icon-row { display: flex; gap: 2px; flex-wrap: wrap; margin-bottom: 8px; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.btn-grid .btn { justify-content: flex-start; }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.sub { padding: 4px 0 4px 10px; border-left: 2px solid var(--line-2); margin: 2px 0 8px 6px; }
.slider-field input[type=range] { width: 100%; accent-color: var(--accent); }
.slider-top { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.slider-val { color: var(--text); font-variant-numeric: tabular-nums; }
.segmented { display: inline-flex; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 8px; padding: 2px; gap: 2px; }
.seg { border: 0; background: transparent; padding: 4px 9px; border-radius: 6px; font-size: 12px; color: var(--muted); display: grid; place-items: center; }
.seg.on { background: var(--bg-4); color: var(--text); }
.color-row { display: flex; gap: 6px; align-items: center; }
.swatch-btn { width: 34px; height: 30px; padding: 0; border: 1px solid var(--line-2); border-radius: 6px; flex-shrink: 0; box-shadow: inset 0 0 0 2px #0e101699; }
.swatch-btn:hover { border-color: #7a86a3; }
.color-row .hex { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.cmyk { margin-top: 6px; }
.cmyk-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.cmyk-row label { display: flex; flex-direction: column; gap: 2px; font-size: 10px; color: var(--muted); }
.mini-swatches { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.mini-swatch { width: 16px; height: 16px; border-radius: 4px; border: 1px solid #0007; padding: 0; }
.kv { display: flex; justify-content: space-between; margin: 4px 0; color: var(--muted); }
.kv b { color: var(--text); font-weight: 600; }
.legend.bleed, .legend.trim { color: #ff8b96; }
.legend.safe { color: var(--ok); }

/* ---------- left panel ---------- */
.text-add { display: block; width: 100%; text-align: left; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 12px; margin-bottom: 6px; }
.text-add:hover { border-color: #56617c; }
.text-add.h1 { font-size: 20px; font-weight: 700; }
.text-add.h2 { font-size: 15px; font-weight: 600; }
.text-add.h3 { font-size: 12.5px; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 6px; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 9px; padding: 11px 4px 8px; font-size: 11px; color: var(--muted); }
.tile:hover { border-color: var(--accent); color: var(--text); }
.tile .ic { color: var(--text); }
.font-list { display: flex; flex-direction: column; gap: 2px; max-height: 52vh; overflow: auto; margin-top: 6px; }
.font-row { display: flex; align-items: center; }
.font-item { flex: 1; text-align: left; background: transparent; border: 0; padding: 7px 8px; border-radius: 6px; font-size: 16px; }
.font-item:hover { background: var(--bg-3); }
.swatch-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.swatch-wrap { position: relative; }
.swatch { width: 28px; height: 28px; border-radius: 7px; border: 1px solid #0008; padding: 0; box-shadow: inset 0 0 0 1px #ffffff14; }
.swatch-x { position: absolute; top: -6px; right: -6px; width: 16px; height: 16px; border-radius: 50%; border: 0; background: var(--bg-4); color: var(--text); display: none; place-items: center; padding: 0; }
.swatch-wrap:hover .swatch-x { display: grid; }

/* ---------- layers ---------- */
.layers { display: flex; flex-direction: column; gap: 1px; }
.layer { display: flex; align-items: center; gap: 6px; padding: 3px 4px 3px 8px; border-radius: 6px; cursor: pointer; color: var(--muted); border: 1px solid transparent; }
.layer:hover { background: var(--bg-3); }
.layer.on { background: #213050; color: var(--text); }
.layer.hidden .layer-name { opacity: .45; }
.layer-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.layer.drop-above { border-top-color: var(--accent); }
.layer.drop-below { border-bottom-color: var(--accent); }
.twisty { width: 14px; height: 14px; border: 0; background: none; padding: 0; color: var(--muted); display: grid; place-items: center; flex-shrink: 0; }

/* ---------- stage ---------- */
.stage-wrap { position: absolute; inset: 0; overflow: hidden; background: #0b0d12; }
.ruler { position: absolute; background: #141821; z-index: 3; }
.ruler-h { top: 0; left: 20px; right: 0; height: 20px; width: calc(100% - 20px); cursor: s-resize; border-bottom: 1px solid var(--line); }
.ruler-v { top: 20px; left: 0; bottom: 0; width: 20px; height: calc(100% - 20px); cursor: e-resize; border-right: 1px solid var(--line); }
.ruler-corner { position: absolute; top: 0; left: 0; width: 20px; height: 20px; background: #141821; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); z-index: 4; }
.viewport { position: absolute; inset: 20px 0 0 20px; overflow: hidden; outline: none; cursor: default; touch-action: none; user-select: none; -webkit-user-select: none; }
.stage-wrap.preview .ruler, .stage-wrap.preview .ruler-corner { display: none; }
.stage-wrap.preview .viewport { inset: 0; background: #000; }
.viewport[data-tool=hand], .viewport.space-pan { cursor: grab; }
.viewport.panning { cursor: grabbing !important; }
.viewport[data-tool=text] { cursor: text; }
.viewport[data-tool=rect], .viewport[data-tool=ellipse], .viewport[data-tool=line], .viewport[data-tool=arrow], .viewport[data-tool=polygon], .viewport[data-tool=star], .viewport[data-tool=pen] { cursor: crosshair; }
.viewport[data-tool=select].over-obj { cursor: move; }
.page-svg { position: absolute; filter: drop-shadow(0 10px 30px rgba(0, 0, 0, .55)); overflow: hidden; }
.stage-wrap.preview .page-svg { filter: none; }
.editing-hidden { opacity: 0; }
.overlay { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.overlay .handle { fill: #fff; stroke: #3b82f6; stroke-width: 1.3; pointer-events: all; }
.overlay .handle.side { fill: #fff; }
.overlay .handle.round { rx: 6px; }
.overlay .handle.rot { fill: #fff; stroke: var(--accent-2); cursor: grab; }
.overlay [data-h=nw], .overlay [data-h=se] { cursor: nwse-resize; }
.overlay [data-h=ne], .overlay [data-h=sw] { cursor: nesw-resize; }
.overlay [data-h=n], .overlay [data-h=s] { cursor: ns-resize; }
.overlay [data-h=e], .overlay [data-h=w] { cursor: ew-resize; }
.overlay [data-h=p1], .overlay [data-h=p2] { cursor: crosshair; }
.overlay .rot-stem { stroke: #3b82f6; stroke-width: 1; }
.overlay .sel-box { fill: none; stroke: #3b82f6; stroke-width: 1.5; }
.overlay .sel-box.sub { stroke-width: 1; stroke-dasharray: 3 3; }
.overlay .sel-box.locked { stroke: var(--warn); stroke-dasharray: 5 4; }
.overlay .hover-box { fill: none; stroke: #3b82f6; stroke-width: 1; stroke-opacity: .7; }
.overlay .group-frame { fill: none; stroke: var(--accent-2); stroke-dasharray: 6 4; stroke-width: 1; }
.overlay .guide { stroke: #19c2ff; stroke-width: 1; }
.overlay .guide-hit { stroke: transparent; stroke-width: 9; pointer-events: stroke; cursor: move; }
.overlay .snap-line { stroke: #ff4fb4; stroke-width: 1; }
.overlay .marquee { fill: #3b82f61a; stroke: #3b82f6; stroke-width: 1; }
.overlay .create-box { fill: none; stroke: #3b82f6; stroke-width: 1; stroke-dasharray: 4 3; }
.overlay .pen-path { fill: none; stroke: var(--accent-2); stroke-width: 1.5; }
.overlay .pen-anchor { fill: #fff; stroke: var(--accent-2); stroke-width: 1.3; }
.overlay .pen-anchor.first { fill: var(--accent-2); }
.overlay .pen-handle { fill: var(--accent-2); }
.overlay .pen-handle-line { stroke: var(--accent-2); stroke-width: 1; }
.overlay .readout rect { fill: #111827ee; }
.overlay .readout text { fill: #fff; font: 11px var(--font); }
.text-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.inline-text { position: absolute; pointer-events: auto; background: transparent; border: 0; outline: 1.5px solid #3b82f6; outline-offset: 2px; padding: 0; margin: 0; resize: none; overflow: hidden; white-space: pre; overflow-wrap: normal; transform-origin: center; caret-color: #3b82f6; user-select: text; -webkit-user-select: text; }
.preview-bar { display: none; }
.editor.preview-mode .preview-bar { display: flex; position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); align-items: center; gap: 8px; background: #151922e6; border: 1px solid var(--line-2); border-radius: 999px; padding: 5px 8px; z-index: 30; opacity: .25; transition: opacity .2s; }
.editor.preview-mode .preview-bar:hover { opacity: 1; }

/* ---------- menus, modals, toast ---------- */
.menu { position: fixed; z-index: 70; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px; min-width: 220px; padding: 5px; box-shadow: var(--shadow); }
.menu-item { display: flex; justify-content: space-between; gap: 16px; width: 100%; text-align: left; background: transparent; border: 0; padding: 6px 10px; border-radius: 6px; font-size: 12.5px; }
.menu-item:hover:not(:disabled) { background: var(--bg-3); }
.menu .k { color: var(--faint); font-size: 11px; }
.menu .sep { height: 1px; width: auto; background: var(--line); margin: 4px 2px; }
.modal-bg { position: fixed; inset: 0; background: #05070bb3; display: grid; place-items: center; z-index: 60; padding: 16px; }
.modal { background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 14px; width: min(520px, 100%); max-height: 88vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 6px; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 6px 18px 12px; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--line); }
.export-form .segmented { width: 100%; }
.export-form .seg { flex: 1; padding: 7px; font-weight: 600; }
.page-picks { max-height: 160px; overflow: auto; padding: 4px 8px; background: var(--bg-3); border-radius: 8px; margin-bottom: 8px; }
.progress { height: 6px; background: var(--bg-4); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .2s; }
.toast { position: fixed; bottom: 60px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--bg-4); border: 1px solid var(--line-2); padding: 9px 14px; border-radius: 10px; z-index: 80; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; display: flex; gap: 12px; align-items: center; max-width: min(640px, 92vw); box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translateX(-50%); pointer-events: auto; }
.toast.error { border-color: #7a2d38; background: #2a1519; }
.toast-action { background: none; border: 0; color: var(--accent); font-weight: 700; padding: 0; }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 44px 230px minmax(0, 1fr) 270px; }
  .hint.inline { display: none; }
  .doc-title { width: 180px; }
}
@media (max-width: 900px) {
  .workspace { grid-template-columns: 44px 0 minmax(0, 1fr) 250px; }
  .workspace > .panel:not(.right) { display: none; }
  .home-hero, .home-body { padding-left: 16px; padding-right: 16px; }
}

/* ---------- colour picker ---------- */
.cpick { position: fixed; z-index: 75; width: 272px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow); padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 10px; touch-action: none; }
.cp-head { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; }
.cp-sv { position: relative; height: 160px; border-radius: 8px; cursor: crosshair; outline-offset: 2px; }
.cp-sv-white, .cp-sv-black { position: absolute; inset: 0; border-radius: 8px; }
.cp-sv-white { background: linear-gradient(to right, #fff, #fff0); }
.cp-sv-black { background: linear-gradient(to top, #000, #0000); }
.cp-knob { position: absolute; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px #0008, 0 2px 6px #0007; pointer-events: none; }
.cp-row { display: flex; align-items: center; gap: 10px; }
.cp-hue { position: relative; flex: 1; height: 14px; border-radius: 99px; cursor: pointer; background: linear-gradient(to right, #f00 0%, #ff0 16.66%, #0f0 33.33%, #0ff 50%, #00f 66.66%, #f0f 83.33%, #f00 100%); outline-offset: 3px; }
.cp-hue-knob { position: absolute; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px #0008, 0 2px 6px #0007; pointer-events: none; }
.cp-preview { width: 34px; height: 34px; border-radius: 8px; overflow: hidden; display: grid; grid-template-rows: 1fr 1fr; border: 1px solid var(--line-2); cursor: pointer; flex-shrink: 0; }
.cp-inputs { display: grid; grid-template-columns: 2.2fr 1fr 1fr 1fr; gap: 6px; }
.cp-inputs label { display: flex; flex-direction: column; gap: 3px; font-size: 10.5px; color: var(--muted); min-width: 0; }
.cp-inputs .input { padding: 5px 6px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.cp-swatches { display: flex; flex-direction: column; gap: 5px; font-size: 10.5px; color: var(--muted); }
.cp-swatches > div { display: flex; flex-wrap: wrap; gap: 5px; }
.cp-swatches .mini-swatch { width: 20px; height: 20px; }
.cp-foot { display: flex; justify-content: flex-end; }
/* phones: the picker slides up from the bottom with big touch targets */
.cpick.cp-sheet { left: 0; right: 0; bottom: 0; width: auto; border-radius: 16px 16px 0 0; padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px)); max-height: 88dvh; overflow: auto; }
.cpick.cp-sheet .cp-sv { height: min(34dvh, 240px); }
.cpick.cp-sheet .cp-hue { height: 26px; }
.cpick.cp-sheet .cp-hue-knob, .cpick.cp-sheet .cp-knob { width: 28px; height: 28px; margin: -14px 0 0 -14px; }
.cpick.cp-sheet .cp-preview { width: 44px; height: 44px; }
.cpick.cp-sheet .cp-inputs .input { font-size: 16px; padding: 8px; }
.cpick.cp-sheet .cp-swatches .mini-swatch { width: 32px; height: 32px; border-radius: 8px; }
.cpick.cp-sheet .cp-done { padding: 11px 28px; font-size: 15px; }
@media (min-width: 700px) { .cpick.cp-sheet { left: 50%; right: auto; width: 520px; transform: translateX(-50%); } }
html.is-phone .swatch-btn { width: 44px; height: 38px; }

/* =====================================================================
   PHONE LAYOUT (html.is-phone is set by js/mobile.js) and touch tweaks
   ===================================================================== */
.mobile-nav, .sel-bar, .sheet-close, .tool-label { display: none; }
html:not(.is-phone) .mobile-only { display: none !important; }
[hidden] { display: none !important; }

html.is-touch { touch-action: manipulation; }
html.is-touch .card-x, html.is-touch .card-tools { opacity: 1; }
html.is-touch .swatch-x { display: grid; }
html.is-touch .overlay .handle { stroke-width: 1.8; }

html.is-phone {
  --nav-h: 60px;
  --sheet-h: min(56dvh, 560px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
html.is-phone .app { height: 100%; height: 100dvh; }
html.is-phone .desk-only { display: none !important; }
html.is-phone .mobile-only { display: flex; }

/* editor frame: top bar / canvas / bottom navigation */
html.is-phone .editor { grid-template-rows: calc(52px + var(--safe-t)) minmax(0, 1fr) calc(var(--nav-h) + var(--safe-b)); }
html.is-phone .topbar { padding: var(--safe-t) 6px 0; gap: 2px; border-bottom: 1px solid var(--line); }
html.is-phone .topbar .doc-title { flex: 1; width: auto; min-width: 0; padding: 6px; }
html.is-phone .topbar .title-stack { flex: 1; min-width: 0; }
html.is-phone .topbar .title-stack .doc-title { width: 100%; padding: 2px 6px 4px; }
html.is-phone .topbar .title-stack .host-title { padding: 0 7px; max-width: none; }
html.is-phone .topbar .btn.small { padding: 7px 9px; }
html.is-phone .topbar .icon-btn { width: 38px; height: 38px; }
html.is-phone .alignbar { display: none; }
html.is-phone .workspace { grid-template-columns: minmax(0, 1fr); }
html.is-phone .workspace > .tools, html.is-phone .workspace > .panel, html.is-phone .statusbar { display: none; }
html.is-phone .ruler, html.is-phone .ruler-corner { display: none; }
html.is-phone .viewport { inset: 0; }

/* bottom navigation */
html.is-phone .mobile-nav { display: flex; background: var(--bg-2); border-top: 1px solid var(--line); padding: 0 4px var(--safe-b); z-index: 30; }
.mnav-btn { flex: 1; background: none; border: 0; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; min-width: 0; }
.mnav-btn.on { color: var(--accent); }

/* slide-up panels ("sheets") reuse the desktop panels */
html.is-phone .sheet-active {
  display: flex !important; position: fixed; left: 0; right: 0; z-index: 25;
  bottom: calc(var(--nav-h) + var(--safe-b)); height: var(--sheet-h);
  background: var(--bg-2); border: 0; border-top: 1px solid var(--line-2); border-radius: 16px 16px 0 0;
  box-shadow: 0 -14px 40px rgba(0, 0, 0, .55); overflow: hidden;
}
html.is-phone .panel.sheet-active { flex-direction: column; }
html.is-phone .panel.sheet-active .tabs { border-radius: 16px 16px 0 0; padding-right: 52px; }
html.is-phone .panel.sheet-active .panel-body { padding-bottom: 28px; }
html.is-phone #tools.sheet-active { flex-direction: row; flex-wrap: wrap; align-content: flex-start; justify-content: flex-start; padding: 56px 12px 18px; gap: 8px; overflow: auto; }
html.is-phone #tools.sheet-active::before { content: "Tools"; position: absolute; top: 18px; left: 16px; font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
html.is-phone #tools.sheet-active .icon-btn { width: calc(25% - 6px); height: 74px; display: flex; flex-direction: column; gap: 6px; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 12px; }
html.is-phone #tools.sheet-active .icon-btn.on { border-color: var(--accent); }
html.is-phone #tools.sheet-active .tool-label { display: block; font-size: 11px; color: var(--muted); }
html.is-phone #statusbar.sheet-active { flex-wrap: wrap; align-content: flex-start; padding: 56px 14px 18px; gap: 10px; overflow: auto; }
html.is-phone #statusbar.sheet-active::before { content: "Pages"; position: absolute; top: 18px; left: 16px; font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
html.is-phone #statusbar.sheet-active .pages { max-width: 100%; width: 100%; flex-wrap: wrap; overflow: visible; }
html.is-phone #statusbar.sheet-active .page-pill { padding: 9px 14px; font-size: 14px; max-width: 100%; }
html.is-phone #statusbar.sheet-active .icon-btn { width: 44px; height: 44px; background: var(--bg-3); }
html.is-phone #statusbar.sheet-active .spacer { flex-basis: 100%; }
html.is-phone .sheet-close {
  display: grid; place-items: center; position: fixed; z-index: 26; right: 10px;
  bottom: calc(var(--nav-h) + var(--safe-b) + var(--sheet-h) - 44px);
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--bg-3); color: var(--text);
}

/* quick actions for the selection */
html.is-phone .sel-bar {
  display: flex; position: fixed; left: 50%; transform: translateX(-50%); z-index: 24;
  bottom: calc(var(--nav-h) + var(--safe-b) + 10px); max-width: calc(100vw - 16px); overflow-x: auto;
  background: #151922f2; border: 1px solid var(--line-2); border-radius: 14px; padding: 4px; gap: 2px; box-shadow: var(--shadow);
}
.sel-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 52px; padding: 6px 4px; background: none; border: 0; border-radius: 10px; color: var(--text); font-size: 10.5px; }
.sel-btn:active { background: var(--bg-3); }
.sel-btn.danger { color: var(--danger); }

/* bigger, easier controls; 16px inputs stop iPhones from zooming in on focus */
html.is-phone .input, html.is-phone select, html.is-phone textarea, html.is-phone .doc-title { font-size: 16px; }
html.is-phone .tab { padding: 14px 6px; }
html.is-phone .insp-section h3 { font-size: 11px; }
html.is-phone .icon-row .icon-btn { width: 40px; height: 40px; }
html.is-phone .layer { padding: 6px 4px 6px 8px; }
html.is-phone .layer .icon-btn.tiny { width: 34px; height: 34px; }
html.is-phone .layer-move { display: inline-flex; }
html.is-phone .tiles { grid-template-columns: repeat(4, 1fr); }
html.is-phone .font-list { max-height: none; }
html.is-phone .menu { max-width: calc(100vw - 16px); }
html.is-phone .menu-item { padding: 11px 12px; font-size: 15px; }
html.is-phone .toast { bottom: calc(var(--nav-h) + var(--safe-b) + 76px); }

/* dialogs slide up from the bottom */
html.is-phone .modal-bg { place-items: end stretch; padding: 0; }
html.is-phone .modal { width: 100%; max-height: 92dvh; border-radius: 16px 16px 0 0; }
html.is-phone .modal-actions { padding-bottom: calc(16px + var(--safe-b)); }
html.is-phone .modal-actions .btn { flex: 1; padding: 11px; }
/* three or more buttons: wrap instead of running off the screen */
html.is-phone .modal-actions:has(.btn:nth-child(3)) { flex-wrap: wrap; }
html.is-phone .modal-actions:has(.btn:nth-child(3)) .btn { flex: 1 1 auto; white-space: nowrap; }

/* present mode */
html.is-phone .editor.preview-mode { grid-template-rows: minmax(0, 1fr); }
html.is-phone .editor.preview-mode .mobile-nav, html.is-phone .editor.preview-mode .sel-bar, html.is-phone .editor.preview-mode .sheet-close { display: none !important; }

/* home screen */
html.is-phone .home-hero { padding: calc(18px + var(--safe-t)) 16px 4px; }
html.is-phone .brand h1 { font-size: 20px; }
html.is-phone .brand p { font-size: 12px; }
html.is-phone .home-actions { width: 100%; }
html.is-phone .home-actions .btn { flex: 1; padding: 10px; }
html.is-phone .home-body { padding: 0 16px calc(40px + var(--safe-b)); }
html.is-phone .size-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
html.is-phone .card-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
html.is-phone .thumb { height: 110px; }

/* very small phones */
@media (max-width: 360px) {
  html.is-phone .topbar .doc-title { min-width: 56px; }
  html.is-phone .topbar .export-btn span { display: none; }
  .sel-btn { min-width: 44px; font-size: 10px; }
}
/* phones in landscape: slimmer bars, icons only */
@media (max-height: 520px) {
  html.is-phone { --nav-h: 46px; --sheet-h: min(70dvh, 420px); }
  html.is-phone .editor { grid-template-rows: calc(44px + var(--safe-t)) minmax(0, 1fr) calc(var(--nav-h) + var(--safe-b)); }
  html.is-phone .mnav-btn span, html.is-phone .sel-btn span { display: none; }
  html.is-phone .sel-btn { min-width: 42px; padding: 8px 4px; }
  html.is-phone .mobile-nav { padding-left: max(4px, env(safe-area-inset-left)); padding-right: max(4px, env(safe-area-inset-right)); }
}
/* tablets using the compact layout: wider panels look better centred */
@media (min-width: 700px) {
  html.is-phone .sheet-active { left: 50%; right: auto; width: 640px; transform: translateX(-50%); }
  html.is-phone .sheet-close { right: calc(50% - 320px + 10px); }
}

/* =====================================================================
   HOME: choose Photo editor or Layout design
   ===================================================================== */
.start-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 18px; }
.start-card { display: flex; gap: 16px; align-items: center; text-align: left; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 16px; padding: 20px; min-height: 120px; transition: border-color .12s, transform .12s; }
.start-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.start-card b { display: block; font-size: 17px; margin-bottom: 4px; }
.start-card span { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.start-icon { width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; flex-shrink: 0; color: var(--accent-ink); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.start-card.photo .start-icon { background: linear-gradient(135deg, #ff9f43, #ff6b7a); }
.start-card.small { min-height: 84px; padding: 14px; border-radius: 14px; }
.start-card.small .start-icon { width: 48px; height: 48px; border-radius: 12px; }
.start-card.small b { font-size: 14.5px; }
.photo-starts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-top: 18px; }
.home-hero.sub .brand { gap: 10px; }
.home-back { margin-right: 4px; }
.kind-badge { position: absolute; top: 16px; left: 16px; font-style: normal; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 7px; border-radius: 99px; background: #0e1016cc; color: var(--accent); border: 1px solid #6ea8ff55; }
.kind-badge.photo { color: #ffb070; border-color: #ff9f4355; }
.storage-row { display: flex; align-items: center; gap: 12px; margin-top: 16px; padding: 12px 14px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; color: var(--muted); }
.storage-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.storage-info b { color: var(--text); font-size: 12.5px; font-weight: 600; }
.storage-info span { font-size: 11px; }
.meter { height: 6px; border-radius: 99px; background: var(--bg-4); overflow: hidden; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.meter.high i { background: linear-gradient(90deg, var(--warn), var(--danger)); }
.storage-list { display: flex; flex-direction: column; gap: 6px; }
.storage-item { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-3); }
.thumb.small { width: 48px; height: 48px; margin: 0; flex-shrink: 0; border-radius: 6px; }
.si-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.si-text b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.si-text span { color: var(--muted); font-size: 11px; }
.si-actions { display: flex; gap: 6px; flex-shrink: 0; }
.menu-head { padding: 8px 10px 3px; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.menu { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); overflow: auto; }
.progress.indeterminate i { width: 35%; animation: indet 1.1s ease-in-out infinite; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }

/* layout additions */
.multi-bar { position: fixed; top: 58px; left: 50%; transform: translateX(-50%); z-index: 27; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  background: #1d2a44f2; border: 1px solid var(--accent); border-radius: 12px; padding: 7px 8px 7px 14px; box-shadow: var(--shadow); max-width: calc(100vw - 16px); }
.multi-bar span { font-weight: 600; }
.multi-bar small { color: var(--muted); font-size: 11px; }
html.is-phone .multi-bar { top: calc(58px + var(--safe-t)); }
.sel-btn.accent { color: var(--accent); }
html.is-phone .sel-bar.raised { bottom: calc(var(--nav-h) + var(--safe-b) + 10px); }
.edit-photo-btn { margin-bottom: 8px; }
.notice.photo-kept { font-size: 12px; }
.notice.photo-kept span { flex: 1; }

/* =====================================================================
   PHOTO EDITOR
   ===================================================================== */
.photo-editor .workspace { grid-template-columns: 52px minmax(0, 1fr) 300px; }
.photo-editor .ph-options { overflow-x: auto; overflow-y: hidden; gap: 10px; scrollbar-width: thin; }
.photo-editor .ph-options > * { flex-shrink: 0; }
.ph-tool-name { font-weight: 600; color: var(--text) !important; }
.ph-opt { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.ph-opt input[type=range] { width: 110px; accent-color: var(--accent); }
.ph-opt b { color: var(--text); font-weight: 600; min-width: 38px; font-variant-numeric: tabular-nums; }
.ph-opt.check input { accent-color: var(--accent); }
.ph-opt select.input { width: auto; max-width: 170px; padding: 3px 6px; }
.ph-opt .segmented .seg { padding: 3px 8px; }
.ph-opt-btns { display: inline-flex; gap: 6px; }
.ph-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; padding: 0 6px; }
.photo-editor .tools { gap: 2px; }
.photo-editor .tools .icon-btn { width: 36px; height: 34px; }
.ph-chips { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 8px; }
.ph-chips-row { flex-direction: row; margin: 0; }
.ph-chip-stack { position: relative; width: 38px; height: 38px; }
.ph-chip { position: absolute; width: 24px; height: 24px; border-radius: 6px; border: 2px solid #fff; box-shadow: 0 0 0 1px #0009; padding: 0; }
.ph-chip.fg { left: 0; top: 0; z-index: 1; }
.ph-chip.bg { right: 0; bottom: 0; }
.icon-btn.ph-swap { width: 24px; height: 24px; }
.ph-stage { background: #0b0d12; }
.ph-viewport { position: absolute; inset: 0; overflow: hidden; outline: none; touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; }
.ph-viewport[data-tool=move] { cursor: move; }
.ph-viewport[data-tool=hand], .ph-viewport.space-pan { cursor: grab; }
.ph-viewport.panning { cursor: grabbing !important; }
.ph-viewport[data-tool=zoom] { cursor: zoom-in; }
.ph-viewport[data-tool=text] { cursor: text; }
.ph-viewport[data-tool=brush], .ph-viewport[data-tool=eraser], .ph-viewport[data-tool=clone], .ph-viewport[data-tool=heal], .ph-viewport[data-tool=smudge], .ph-viewport[data-tool=blurbrush], .ph-viewport[data-tool=sharpenbrush], .ph-viewport[data-tool=redeye] { cursor: none; }
html.is-touch .ph-viewport { cursor: default; }
.ph-paper { position: absolute; background-color: #fff; background-image: linear-gradient(45deg, #d9dce3 25%, transparent 25%, transparent 75%, #d9dce3 75%), linear-gradient(45deg, #d9dce3 25%, transparent 25%, transparent 75%, #d9dce3 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, .55); pointer-events: none; }
.ph-canvas, .ph-ants { position: absolute; left: 0; top: 0; pointer-events: none; }
.ph-canvas { width: 100%; height: 100%; }
.overlay .ph-sel-draft { fill: #3b82f61a; stroke: #fff; stroke-width: 1; stroke-dasharray: 4 3; }
.overlay .ph-poly-start { fill: #fff; stroke: var(--accent); stroke-width: 2; }
.overlay .ph-layer-box { fill: none; stroke: #3b82f6; stroke-width: 1; stroke-dasharray: 3 3; }
.overlay .ph-crop-shade { fill: #000; fill-opacity: .55; }
.overlay .ph-crop-box { fill: none; stroke: #fff; stroke-width: 1.5; }
.overlay .ph-img-edge { fill: none; stroke: #ffffff55; stroke-width: 1; stroke-dasharray: 3 4; }
.overlay .ph-thirds { stroke: #ffffff66; stroke-width: 1; }
.overlay .ph-crop-label { fill: #fff; font: 11px var(--font); paint-order: stroke; stroke: #000; stroke-width: 3px; }
.overlay .ph-grad-line { stroke: #fff; stroke-width: 1.5; stroke-dasharray: 5 3; }
.overlay .ph-clone-src { stroke: #fff; stroke-width: 2; filter: drop-shadow(0 0 1px #000); }
.overlay .ph-brush-cursor { fill: none; stroke: #fff; stroke-width: 1; filter: drop-shadow(0 0 1px #000); }
.ph-layers .ph-layer { gap: 6px; padding: 4px 4px 4px 6px; }
.ph-thumb { position: relative; width: 40px; height: 40px; flex-shrink: 0; border-radius: 5px; overflow: hidden; display: grid; place-items: center; color: var(--text);
  background-color: #fff; background-image: linear-gradient(45deg, #d9dce3 25%, transparent 25%, transparent 75%, #d9dce3 75%), linear-gradient(45deg, #d9dce3 25%, transparent 25%, transparent 75%, #d9dce3 75%);
  background-size: 8px 8px; background-position: 0 0, 4px 4px; border: 2px solid transparent; cursor: pointer; }
.ph-thumb canvas { width: 100%; height: 100%; }
.ph-thumb .ic { color: #1b1f2a; }
.ph-thumb.target { border-color: var(--accent); }
.ph-thumb.mask { background: #000; }
.ph-thumb.mask.off { opacity: .4; }
.ph-thumb-t { position: absolute; right: 2px; bottom: 1px; font-style: normal; font-weight: 800; font-size: 11px; color: #1b1f2a; background: #fffc; border-radius: 3px; padding: 0 2px; }
.ph-layer-btns { display: flex; gap: 2px; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
.ph-mask-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.ph-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ph-history { display: flex; flex-direction: column; gap: 2px; }
.ph-hist { display: flex; justify-content: space-between; align-items: center; background: transparent; border: 1px solid transparent; border-radius: 7px; padding: 7px 10px; text-align: left; color: var(--text); }
.ph-hist:hover { background: var(--bg-3); }
.ph-hist.on { background: #213050; border-color: #3b5a92; }
.ph-hist.future { color: var(--faint); }
.ph-hist em { font-style: normal; font-size: 10.5px; color: var(--accent); }
.ph-choices { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.ph-choice { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.ph-choice:hover { border-color: var(--accent); }
.ph-choice b { display: block; font-size: 14px; }
.ph-choice small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; line-height: 1.4; }
.ph-choice .ic { color: var(--accent); }
.ph-layout-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.ph-layout-pick { display: flex; flex-direction: column; gap: 2px; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px; text-align: left; }
.ph-layout-pick:hover { border-color: var(--accent); }
.ph-layout-pick .thumb { height: 84px; margin-bottom: 4px; }
.ph-layout-pick b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; }
.ph-layout-pick span { color: var(--muted); font-size: 11px; }
.ph-shape-list { display: flex; flex-direction: column; gap: 6px; }
.ph-shape-pick { justify-content: flex-start; }
.ph-anchor { display: grid; grid-template-columns: repeat(3, 28px); gap: 4px; }
.ph-anchor-btn { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--bg-3); padding: 0; }
.ph-anchor-btn.on { background: var(--accent); border-color: var(--accent); }
.photo-editor .statusbar { gap: 8px; }

/* phone layout of the photo editor: top bar / photo / tool options / bottom navigation */
html.is-phone .photo-editor { grid-template-rows: calc(52px + var(--safe-t)) minmax(0, 1fr) auto calc(var(--nav-h) + var(--safe-b)); grid-template-areas: "top" "work" "opts" "nav"; }
html.is-phone .photo-editor > .topbar { grid-area: top; }
html.is-phone .photo-editor > .workspace { grid-area: work; grid-template-columns: minmax(0, 1fr); }
html.is-phone .photo-editor > .ph-options { grid-area: opts; display: flex; height: 52px; border-top: 1px solid var(--line); border-bottom: 0; padding: 0 10px; }
html.is-phone .photo-editor > .mobile-nav { grid-area: nav; }
html.is-phone .photo-editor .ph-opt input[type=range] { width: 120px; height: 28px; }
html.is-phone .photo-editor .ph-opt { font-size: 13px; }
html.is-phone .photo-editor .ph-opt .btn, html.is-phone .photo-editor .ph-options .btn { padding: 8px 12px; }
html.is-phone .photo-editor .ph-chip-stack { width: 42px; height: 42px; }
html.is-phone .photo-editor .ph-chip { width: 27px; height: 27px; }
html.is-phone .photo-editor .ph-tool-name { display: none; }
html.is-phone .photo-editor .ph-done span, html.is-phone .photo-editor .ph-place span { display: inline; }
html.is-phone .photo-editor .topbar .ph-title { flex: 1; font-size: 13px; }
html.is-phone .photo-editor #phTools.sheet-active .ph-chips { display: none; }
html.is-phone .photo-editor #phTools.sheet-active .icon-btn { width: calc(25% - 6px); height: 70px; }
html:not(.is-phone) .photo-editor .ph-more { display: inline-grid; }
@media (max-height: 520px) { html.is-phone .photo-editor > .ph-options { height: 44px; } }
@media (max-width: 380px) { html.is-phone .photo-editor .ph-place span { display: none; } }
/* phone Tools panel of the photo editor: a grid of named tools */
html.is-phone .photo-editor #phTools.sheet-active { flex-direction: row; flex-wrap: wrap; align-content: flex-start; justify-content: flex-start; padding: 56px 12px 18px; gap: 8px; overflow: auto; }
html.is-phone .photo-editor #phTools.sheet-active::before { content: "Tools"; position: absolute; top: 18px; left: 16px; font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
html.is-phone .photo-editor #phTools.sheet-active .icon-btn { width: calc(25% - 6px); height: 74px; display: flex; flex-direction: column; gap: 6px; background: var(--bg-3); border: 1px solid var(--line-2); border-radius: 12px; }
html.is-phone .photo-editor #phTools.sheet-active .icon-btn.on { border-color: var(--accent); }
html.is-phone .photo-editor #phTools.sheet-active .tool-label { display: block; font-size: 10.5px; color: var(--muted); text-align: center; line-height: 1.2; padding: 0 2px; }
html.is-phone .photo-editor .ph-place .ph-place-long { display: none; }
html:not(.is-phone) .photo-editor .ph-place .ph-place-short { display: none; }

/* ---------- host mode (another app opened DesignStudio with instructions) ---------- */
.host-screen { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.host-card { width: min(560px, 100%); background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 26px; box-shadow: var(--shadow); text-align: center; }
.host-card h2 { margin: 0 0 8px; font-size: 20px; }
.host-card p { margin: 6px 0 14px; }
.host-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.host-btns a.btn { text-decoration: none; }
.host-spin { width: 34px; height: 34px; margin: 6px auto 14px; border: 3px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: host-spin .8s linear infinite; }
@keyframes host-spin { to { transform: rotate(360deg); } }
.host-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 14px; text-align: left; }
.host-tpl { display: flex; flex-direction: column; gap: 4px; padding: 8px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--bg-3); }
.host-tpl:hover { border-color: var(--accent); }
.host-tpl-img { aspect-ratio: 4 / 3; display: grid; place-items: center; background: var(--bg-4); border-radius: 7px; overflow: hidden; color: var(--muted); }
.host-tpl-img img { width: 100%; height: 100%; object-fit: cover; }
.host-tpl span { color: var(--muted); font-size: 11.5px; }
.host-brand { display: inline-flex; align-items: center; gap: 8px; padding: 0 6px; font-weight: 600; white-space: nowrap; }
.host-brand img { height: 22px; max-width: 110px; object-fit: contain; }
.host-mode .btn.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.12); }
.host-files { display: grid; gap: 8px; margin-top: 10px; }
.host-file { display: grid; gap: 4px; font-size: 12px; }
