/* ============================================================
   PhotoNotes by Storitellah — Liquid Glass design system
   Local-first. No external fonts or assets are fetched.
   ============================================================ */

/* ---------- Font stacks (use locally installed Google fonts when
   present, otherwise fall back to high-quality system fonts) ---------- */
:root {
  --font-ui: "Lato", "Segoe UI", "Helvetica Neue", system-ui, -apple-system, sans-serif;
  --font-serif: "Merriweather", "Lora", Georgia, "Times New Roman", serif;

  /* Liquid Glass — light */
  --bg-app: linear-gradient(135deg, #dfe3f2 0%, #ece5f0 38%, #f2e8de 100%);
  --glass-bg: rgba(255, 255, 255, 0.58);
  --glass-bg-strong: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(255, 255, 255, 0.65);
  --glass-inset: rgba(46, 48, 96, 0.06);
  --glass-shadow: 0 8px 32px rgba(31, 32, 64, 0.14);
  --glass-blur: 18px;

  --ink: #22233a;
  --ink-soft: #5a5c78;
  --ink-faint: #8b8da6;
  --accent: #4a4e9e;
  --accent-strong: #383c8a;
  --accent-warm: #c26d4c;
  --accent-warm-soft: rgba(194, 109, 76, 0.14);
  --ok: #2c7a4b;
  --danger: #b3423f;
  --focus-ring: #2b4fd8;

  --radius-lg: 20px;
  --radius-md: 13px;
  --radius-sm: 9px;
  --ui-scale: 1;

  --toolbar-h: 56px;
  --footer-h: 34px;
  --sidebar-w: 248px;
  --props-w: 292px;
  --dur: 0.22s;
}

[data-resolved-theme="dark"] {
  --bg-app: linear-gradient(135deg, #16172a 0%, #1f1b30 45%, #2a2032 100%);
  --glass-bg: rgba(34, 35, 58, 0.55);
  --glass-bg-strong: rgba(34, 35, 58, 0.85);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-inset: rgba(255, 255, 255, 0.05);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --ink: #ecedf6;
  --ink-soft: #b9bad0;
  --ink-faint: #83849c;
  --accent: #8f94e8;
  --accent-strong: #a8acfe;
  --accent-warm: #e0906c;
  --accent-warm-soft: rgba(224, 144, 108, 0.16);
  --ok: #6fce97;
  --danger: #e2837f;
  --focus-ring: #9db2ff;
}

/* Reduced transparency mode */
[data-reduced-transparency="true"] {
  --glass-bg: var(--glass-bg-strong);
  --glass-blur: 0px;
}

/* High contrast mode */
[data-high-contrast="true"] {
  --glass-bg: #ffffff;
  --glass-bg-strong: #ffffff;
  --glass-border: #22233a;
  --ink: #000000;
  --ink-soft: #24252e;
  --ink-faint: #40414d;
  --glass-blur: 0px;
  --glass-shadow: none;
}
[data-high-contrast="true"][data-resolved-theme="dark"] {
  --glass-bg: #101018;
  --glass-bg-strong: #101018;
  --glass-border: #e8e8f4;
  --ink: #ffffff;
  --ink-soft: #e2e2ee;
  --ink-faint: #c9c9da;
}

/* ---------- Reset & base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font-ui);
  font-size: calc(15px * var(--ui-scale));
  color: var(--ink);
  background: var(--bg-app);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  padding-top: env(safe-area-inset-top);
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
a { color: var(--accent); }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 300;
  background: var(--glass-bg-strong); padding: 8px 14px; border-radius: var(--radius-sm);
  transition: top var(--dur);
}
.skip-link:focus { top: 8px; }

/* ---------- Glass surfaces ---------- */
.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.4);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}
.glass-inset {
  background: var(--glass-inset);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
}

/* ---------- Toolbar ---------- */
.toolbar {
  height: var(--toolbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px;
  border-left: none; border-right: none; border-top: none;
  z-index: 60;
  flex: none;
}
.toolbar-brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-icon { border-radius: 7px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 0.95em; letter-spacing: 0.01em; }
.brand-by { font-size: 0.72em; color: var(--ink-soft); }
.brand-by a { color: inherit; }

.toolbar-project { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 0 1 auto; }
.project-title-input {
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 5px 9px; font-weight: 600; max-width: 240px; min-width: 90px;
  text-overflow: ellipsis;
}
.project-title-input:hover, .project-title-input:focus { border-color: var(--glass-border); background: var(--glass-inset); }
.save-status { font-size: 0.78em; color: var(--ink-faint); white-space: nowrap; }
.save-status.saving { color: var(--accent-warm); }

.toolbar-actions { display: flex; align-items: center; gap: 3px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.toolbar-actions::-webkit-scrollbar { display: none; }
.tsep { width: 1px; height: 22px; background: var(--glass-border); margin: 0 4px; flex: none; }

.tbtn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--ink-soft); white-space: nowrap;
  transition: background var(--dur), color var(--dur), transform 0.1s;
  min-height: 36px;
}
.tbtn:hover { background: var(--glass-inset); color: var(--ink); }
.tbtn:active { transform: scale(0.96); }
.tbtn.accent { background: var(--accent); color: #fff; font-weight: 600; }
.tbtn.accent:hover { background: var(--accent-strong); }
.tbtn.icon-only span { display: none; }
.tbtn span { font-size: 0.88em; }

/* ---------- Offline / update banners ---------- */
.offline-banner {
  position: fixed; top: calc(var(--toolbar-h) + 10px); left: 50%; transform: translateX(-50%);
  z-index: 120; padding: 8px 18px; border-radius: 999px; font-size: 0.86em;
}
.update-banner { top: calc(var(--toolbar-h) + 52px); }

/* ---------- App body ---------- */
.app-body { flex: 1; display: flex; min-height: 0; gap: 10px; padding: 10px; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w); flex: none;
  border-radius: var(--radius-lg);
  display: flex; flex-direction: column; min-height: 0;
  overflow: hidden;
}
.sidebar-tabs { display: flex; flex-wrap: wrap; padding: 8px 8px 0; gap: 2px; }
.side-tab {
  flex: 1 1 30%; padding: 7px 4px; font-size: 0.8em; border-radius: var(--radius-sm);
  color: var(--ink-soft); min-height: 34px;
}
.side-tab:hover { background: var(--glass-inset); }
.side-tab.active { background: var(--glass-bg-strong); color: var(--ink); font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }

.side-panel { display: none; flex: 1; overflow-y: auto; padding: 12px; min-height: 0; }
.side-panel.active { display: block; }
.side-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.side-panel-head h2 { font-size: 0.92em; }
.side-hint { font-size: 0.76em; color: var(--ink-faint); margin-top: 12px; line-height: 1.5; }
.side-hint-row { margin-top: 10px; font-size: 0.8em; }
.side-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }

/* Page list (sidebar) */
.page-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.page-item {
  display: flex; align-items: center; gap: 9px; padding: 7px;
  border-radius: var(--radius-md); border: 1px solid transparent; cursor: pointer;
  background: var(--glass-inset);
}
.page-item:hover { border-color: var(--glass-border); }
.page-item.active { border-color: var(--accent); background: var(--glass-bg-strong); }
.page-item .thumb {
  width: 52px; height: 40px; border-radius: 6px; object-fit: cover; background: var(--glass-inset);
  flex: none; border: 1px solid var(--glass-border);
}
.page-item .thumb.empty { display: grid; place-items: center; color: var(--ink-faint); font-size: 0.7em; }
.page-item .meta { min-width: 0; flex: 1; }
.page-item .meta .name { font-size: 0.82em; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-item .meta .sub { font-size: 0.72em; color: var(--ink-faint); }
.page-item .row-actions { display: flex; gap: 2px; }
.page-item.dragging { opacity: 0.4; }

/* Block list */
.block-list { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.block-item {
  padding: 8px 9px; border-radius: var(--radius-md); cursor: pointer;
  background: var(--glass-inset); border: 1px solid transparent;
}
.block-item:hover { border-color: var(--glass-border); }
.block-item.active { border-color: var(--accent); background: var(--glass-bg-strong); }
.block-item .b-type { font-size: 0.7em; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent-warm); font-weight: 700; }
.block-item .b-preview { font-size: 0.8em; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.block-item .b-actions { display: flex; gap: 2px; margin-top: 5px; flex-wrap: wrap; }
.block-item.hidden-block { opacity: 0.55; }

/* Template / layout grids */
.template-grid, .layout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.template-card, .layout-card {
  border-radius: var(--radius-md); padding: 8px 6px; text-align: center; cursor: pointer;
  background: var(--glass-inset); border: 1px solid transparent; font-size: 0.74em;
  display: flex; flex-direction: column; gap: 6px; align-items: center; min-height: 44px;
}
.template-card:hover, .layout-card:hover { border-color: var(--glass-border); }
.template-card.active, .layout-card.active { border-color: var(--accent); background: var(--glass-bg-strong); font-weight: 600; }
.template-swatch { width: 100%; height: 42px; border-radius: 7px; border: 1px solid var(--glass-border); position: relative; overflow: hidden; }
.layout-thumb { width: 100%; height: 38px; border-radius: 6px; border: 1px solid var(--glass-border); position: relative; background: var(--glass-bg-strong); }
.layout-thumb .lt-img { position: absolute; background: var(--accent); opacity: 0.55; border-radius: 2px; }
.layout-thumb .lt-txt { position: absolute; background: var(--ink-faint); opacity: 0.6; border-radius: 2px; }

/* Project list */
.project-list { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.project-item { padding: 9px; border-radius: var(--radius-md); background: var(--glass-inset); border: 1px solid transparent; cursor: pointer; }
.project-item:hover { border-color: var(--glass-border); }
.project-item.active { border-color: var(--accent); }
.project-item .p-name { font-size: 0.85em; font-weight: 600; }
.project-item .p-sub { font-size: 0.72em; color: var(--ink-faint); margin-top: 2px; }
.project-item .p-actions { display: flex; gap: 3px; margin-top: 6px; flex-wrap: wrap; }

/* ---------- Workspace ---------- */
.workspace { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; gap: 10px; position: relative; }
.stage {
  flex: 1; min-height: 0; position: relative; overflow: auto;
  border-radius: var(--radius-lg);
  display: grid; place-items: center;
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,0.12), transparent 60%),
    rgba(0, 0, 0, 0.045);
  padding: 26px;
}
[data-resolved-theme="dark"] .stage { background: rgba(0, 0, 0, 0.25); }

.page-shell { transition: transform var(--dur); }
.page {
  position: relative;
  background: #f6f1e7;
  box-shadow: 0 12px 48px rgba(20, 20, 40, 0.28);
  overflow: hidden;
  display: flex;
}

/* --- page layout variants (flex/grid composition of frame + text) --- */
.page[data-layout="image-left"], .page[data-layout="image-right"],
.page[data-layout="equal-columns"], .page[data-layout="large-image"],
.page[data-layout="small-image"], .page[data-layout="magazine"] { flex-direction: row; }
.page[data-layout="image-right"] { flex-direction: row-reverse; }
.page[data-layout="image-top"] { flex-direction: column; }
.page[data-layout="image-bottom"] { flex-direction: column-reverse; }

.image-frame {
  position: relative; overflow: hidden; background: rgba(127,127,127,0.12);
  flex: none; touch-action: none;
}
.image-frame img {
  position: absolute; left: 50%; top: 50%;
  transform-origin: center center;
  max-width: none; user-select: none; -webkit-user-drag: none;
  cursor: grab;
}
.image-frame img:active { cursor: grabbing; }
.image-frame .frame-empty {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  color: var(--ink-faint); cursor: pointer; padding: 14px; font-size: 0.9em;
}
.frame-empty .fe-inner { max-width: 260px; line-height: 1.5; }
.frame-empty svg { width: 34px; height: 34px; margin: 0 auto 8px; display: block; opacity: 0.6; }

.text-area {
  flex: 1; min-width: 0; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin;
  display: flex; flex-direction: column; gap: 0.9em;
  position: relative;
  padding: 4px;
}

/* overlay layouts */
.page[data-layout="overlay"] .image-frame,
.page[data-layout="float-card"] .image-frame { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.page[data-layout="overlay"] .text-area,
.page[data-layout="float-card"] .text-area { position: absolute; inset: 0; overflow: visible; z-index: 2; }
.page[data-layout="overlay"] .text-block,
.page[data-layout="float-card"] .text-block { position: absolute; cursor: grab; }

/* text blocks */
.text-block { position: relative; }
.text-block.selected { outline: 1.5px dashed var(--accent); outline-offset: 2px; }
.text-block.locked-block { pointer-events: none; opacity: 0.92; }
.text-block .block-label {
  font-size: 0.62em; letter-spacing: 0.14em; text-transform: uppercase;
  font-weight: 700; margin-bottom: 0.5em; opacity: 0.75;
}
.text-block .block-copy {
  position: absolute; top: -0.4em; right: -0.2em; z-index: 5;
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: var(--glass-bg-strong); border: 1px solid var(--glass-border);
  opacity: 0; transition: opacity var(--dur); color: var(--ink-soft);
}
.text-block:hover .block-copy, .text-block.selected .block-copy,
.block-copy:focus-visible { opacity: 1; }
.text-block .block-text {
  outline: none; white-space: pre-wrap; overflow-wrap: break-word; min-height: 1.4em;
}
.text-block .block-text:empty::before { content: attr(data-placeholder); color: inherit; opacity: 0.45; font-style: italic; }
.text-block .block-speaker { margin-top: 0.6em; font-size: 0.82em; opacity: 0.75; font-style: normal; }
.text-block.fmt-quote .block-text { font-style: italic; padding-left: 0.9em; border-left: 3px solid currentColor; }
.text-block.fmt-dropcap .block-text::first-letter {
  float: left; font-size: 3.1em; line-height: 0.85; padding-right: 0.08em; font-weight: 700;
}

/* stage zoom */
.stage-zoom {
  position: absolute; right: 14px; bottom: 14px; z-index: 20;
  display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 999px;
  font-size: 0.8em;
}
.stage-zoom span { min-width: 40px; text-align: center; }

.drop-hint {
  position: absolute; inset: 18px; z-index: 40; display: grid; place-items: center;
  border-radius: var(--radius-lg); border: 2.5px dashed var(--accent);
  font-size: 1.1em; font-weight: 600; color: var(--accent);
  pointer-events: none;
}

/* filmstrip */
.filmstrip {
  flex: none; height: 76px; border-radius: var(--radius-lg);
  display: flex; gap: 8px; align-items: center; padding: 8px 10px; overflow-x: auto;
}
.film-thumb {
  height: 56px; aspect-ratio: 4 / 3; border-radius: var(--radius-sm); flex: none;
  border: 2px solid transparent; overflow: hidden; cursor: pointer; position: relative;
  background: var(--glass-inset); padding: 0;
}
.film-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.film-thumb.active { border-color: var(--accent); }
.film-thumb .fnum {
  position: absolute; left: 4px; bottom: 3px; font-size: 0.65em; background: rgba(0,0,0,0.55);
  color: #fff; padding: 1px 5px; border-radius: 6px;
}
.film-thumb.empty { display: grid; place-items: center; color: var(--ink-faint); font-size: 0.7em; }
.film-add {
  height: 56px; width: 44px; flex: none; border-radius: var(--radius-sm);
  border: 1.5px dashed var(--glass-border); color: var(--ink-faint); font-size: 1.3em;
}
.film-add:hover { color: var(--accent); border-color: var(--accent); }

/* mobile tabs */
.mobile-tabs { display: none; }

/* ---------- Properties panel ---------- */
.props {
  width: var(--props-w); flex: none; border-radius: var(--radius-lg);
  min-height: 0; overflow: hidden; display: flex;
}
.props-scroll { flex: 1; overflow-y: auto; padding: 14px; }
.prop-section { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--glass-border); }
.prop-section:last-child { border-bottom: none; }
.prop-section h3 { font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-faint); margin-bottom: 10px; }
.prop-row { margin-bottom: 10px; }
.prop-row label { display: block; font-size: 0.78em; color: var(--ink-soft); margin-bottom: 4px; }
.prop-row select, .prop-row input[type="text"] {
  width: 100%; padding: 7px 9px; border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border); background: var(--glass-bg-strong); color: var(--ink);
  min-height: 36px;
}
.prop-row input[type="range"] { width: 100%; accent-color: var(--accent); min-height: 28px; }
.prop-row input[type="color"] {
  width: 100%; height: 34px; border-radius: var(--radius-sm); border: 1px solid var(--glass-border);
  background: var(--glass-bg-strong); padding: 2px; cursor: pointer;
}
.prop-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.color-with-clear { display: flex; gap: 6px; align-items: center; }
.color-with-clear input { flex: 1; }
.prop-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.btn-strip { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }

.mini-btn {
  padding: 6px 10px; border-radius: var(--radius-sm); font-size: 0.8em;
  background: var(--glass-inset); border: 1px solid var(--glass-border); color: var(--ink-soft);
  transition: background var(--dur), color var(--dur);
  min-height: 32px;
}
.mini-btn:hover { background: var(--glass-bg-strong); color: var(--ink); }
.mini-btn.icon { min-width: 32px; text-align: center; padding: 6px 8px; }
.mini-btn.ghost { background: transparent; border-color: transparent; }
.mini-btn.danger { color: var(--danger); }
.mini-btn.toggle[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.link-btn { color: var(--accent); text-decoration: underline; font-size: inherit; padding: 2px 4px; border-radius: 4px; }

.check-row { display: flex; align-items: center; gap: 8px; font-size: 0.84em; color: var(--ink-soft); cursor: pointer; padding: 4px 0; }
.check-row input { width: 17px; height: 17px; accent-color: var(--accent); }

/* prompt box + encouragement */
.prompt-box { padding: 11px 12px; margin: 10px 0; }
.prompt-text { font-size: 0.86em; font-style: italic; color: var(--ink-soft); line-height: 1.5; }
.prompt-actions { display: flex; gap: 6px; margin-top: 9px; }
.encourage { font-size: 0.8em; color: var(--accent-warm); margin: 8px 0; min-height: 1.2em; }
.write-stats { display: flex; gap: 10px; flex-wrap: wrap; font-size: 0.74em; color: var(--ink-faint); margin-bottom: 8px; }
.milestones { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 10px; }
.milestone {
  font-size: 0.7em; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--glass-border); color: var(--ink-faint);
}
.milestone.done { background: var(--accent-warm-soft); color: var(--accent-warm); border-color: transparent; font-weight: 600; }
.milestone.done::before { content: "✓ "; }

.ethics-note { font-size: 0.72em; color: var(--ink-faint); margin-top: 6px; line-height: 1.45; font-style: italic; }

/* image info */
.img-info summary { font-size: 0.8em; color: var(--ink-soft); cursor: pointer; padding: 4px 0; }
.img-info-list { font-size: 0.76em; display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin-top: 6px; }
.img-info-list dt { color: var(--ink-faint); }
.img-info-list dd { color: var(--ink-soft); overflow-wrap: anywhere; }

/* ---------- Footer ---------- */
.app-footer {
  flex: none; min-height: var(--footer-h); display: flex; align-items: center; gap: 8px;
  font-size: 0.76em; color: var(--ink-soft); padding: 4px 16px;
  border-left: none; border-right: none; border-bottom: none;
  padding-bottom: max(4px, env(safe-area-inset-bottom));
  flex-wrap: wrap;
}
.footer-sep { color: var(--ink-faint); }
.footer-spacer { flex: 1; }
.app-footer a { color: inherit; font-weight: 600; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200; background: rgba(15, 16, 32, 0.45);
  display: grid; place-items: center; padding: 18px;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.modal {
  width: min(680px, 100%); max-height: min(84dvh, 760px); border-radius: var(--radius-lg);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--glass-bg-strong);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 10px; }
.modal-head h2 { font-size: 1.05em; }
.modal-body { padding: 6px 18px 20px; overflow-y: auto; line-height: 1.55; font-size: 0.92em; }
.modal-body h3 { margin: 16px 0 6px; font-size: 0.95em; }
.modal-body p { margin-bottom: 8px; color: var(--ink-soft); }
.modal-body ul, .modal-body ol { margin: 6px 0 10px 20px; color: var(--ink-soft); }
.modal-body li { margin-bottom: 4px; }
.modal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 10px 0; }
.modal-choice {
  padding: 12px; border-radius: var(--radius-md); border: 1px solid var(--glass-border);
  background: var(--glass-inset); cursor: pointer; text-align: left; font-size: 0.9em;
}
.modal-choice:hover { border-color: var(--accent); }
.modal-choice.selected { border-color: var(--accent); background: var(--glass-bg-strong); font-weight: 600; }
.modal-choice small { display: block; color: var(--ink-faint); font-weight: 400; margin-top: 3px; font-size: 0.82em; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.modal-actions .primary {
  background: var(--accent); color: #fff; font-weight: 600; padding: 9px 18px;
  border-radius: var(--radius-sm); min-height: 40px;
}
.modal-actions .primary:hover { background: var(--accent-strong); }
.modal-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.modal-row label { font-size: 0.86em; color: var(--ink-soft); min-width: 120px; }
.modal-row select, .modal-row input[type="text"], .modal-row input[type="number"] {
  padding: 7px 9px; border-radius: var(--radius-sm); border: 1px solid var(--glass-border);
  background: var(--glass-bg-strong); color: var(--ink); flex: 1; min-width: 120px; min-height: 36px;
}
.modal-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.export-preview-wrap { text-align: center; margin: 10px 0; }
.export-preview-wrap canvas, .export-preview-wrap img {
  max-width: 100%; max-height: 300px; border: 1px solid var(--glass-border); border-radius: var(--radius-sm);
  box-shadow: var(--glass-shadow);
}
.workshop-timer { font-size: 2.4em; font-weight: 700; text-align: center; margin: 12px 0; font-variant-numeric: tabular-nums; }
.exercise-card { padding: 12px 14px; border-radius: var(--radius-md); background: var(--glass-inset); border: 1px solid var(--glass-border); margin-bottom: 10px; }
.exercise-card h4 { font-size: 0.95em; margin-bottom: 4px; }
.exercise-card p { font-size: 0.86em; }

/* ---------- Toasts ---------- */
.toast-region { position: fixed; bottom: calc(var(--footer-h) + 16px); left: 50%; transform: translateX(-50%); z-index: 250; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  padding: 9px 18px; border-radius: 999px; font-size: 0.86em;
  background: var(--glass-bg-strong); border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow); color: var(--ink);
  animation: toast-in 0.25s ease-out;
}
.toast.ok { border-color: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Focus writing mode ---------- */
body.focus-writing .sidebar, body.focus-writing .filmstrip,
body.focus-writing #sec-image, body.focus-writing #sec-page, body.focus-writing #sec-layers { display: none; }
body.focus-writing .stage { padding: 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .tbtn span { display: none; }
  :root { --sidebar-w: 210px; --props-w: 250px; }
}

@media (max-width: 860px) {
  .app-body { flex-direction: column; padding: 8px; gap: 8px; }
  .sidebar, .props { width: 100%; max-height: 42dvh; }
  .sidebar { order: 3; display: none; }
  .props { order: 2; display: none; }
  .workspace { order: 1; flex: 1; }
  .mobile-tabs {
    display: flex; flex: none; border-radius: var(--radius-lg); padding: 5px;
    gap: 3px; margin-bottom: max(0px, env(safe-area-inset-bottom));
  }
  .m-tab { flex: 1; padding: 9px 4px; border-radius: var(--radius-sm); font-size: 0.8em; color: var(--ink-soft); min-height: 42px; }
  .m-tab.active { background: var(--accent); color: #fff; font-weight: 600; }
  body[data-mview="design"] .sidebar { display: flex; }
  body[data-mview="write"] .props { display: flex; }
  body[data-mview="write"] #sec-image, body[data-mview="write"] #sec-page, body[data-mview="write"] #sec-layers { display: none; }
  .filmstrip { height: 64px; }
  .toolbar-project { display: none; }
  .stage { padding: 12px; }
  .toast-region { bottom: 110px; }
}

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
[data-reduced-motion="true"] * { transition: none !important; animation: none !important; }

/* ---------- Print (worksheets) ---------- */
@media print {
  body > * { display: none !important; }
  body { overflow: visible; height: auto; background: #fff; }
  #print-area { display: block !important; color: #000; font-family: Georgia, serif; padding: 20mm; }
  #print-area h1 { font-size: 18pt; margin-bottom: 8pt; }
  #print-area h2 { font-size: 13pt; margin: 14pt 0 4pt; }
  #print-area p { font-size: 11pt; margin-bottom: 6pt; }
  #print-area .write-lines { border-bottom: 1px solid #999; height: 22pt; }
}
