:root {
  color-scheme: light;
  --color-bg: #ffffff;
  --color-bg-secondary: #f8f7f4;
  --color-bg-panel: #faf9f6;
  --color-ink-black: #1a1a2e;
  --color-ink-blue: #2b5ea6;
  --color-border-black: #1a1a2e;
  --color-border-blue: #2b5ea6;
  --color-text: #1a1a2e;
  --color-text-dim: #4a4a5a;
  --color-text-muted: #8a8a9a;
  --color-success: #2a6a3a;
  --color-failure: #8b3a3a;
  --ink-gradient: linear-gradient(to right, var(--color-ink-black) 0%, var(--color-ink-black) 66%, var(--color-ink-blue) 100%);
  --font-body: "HuiwenMinchoBase", "HuiwenMinchoCommon", "Noto Serif SC", "Songti SC", "SimSun", serif;
  --font-heading: "HuiwenMinchoBase", "HuiwenMinchoCommon", "Noto Serif SC", "Songti SC", "SimSun", serif;
  --radius: 2px;
  --panel-padding: 12px;
  --bg: var(--color-bg);
  --panel: var(--color-bg-panel);
  --panel-2: var(--color-bg-secondary);
  --paper: var(--color-bg);
  --paper-ink: var(--color-ink-black);
  --line: rgba(26, 26, 46, .15);
  --line-strong: rgba(43, 94, 166, .2);
  --text: var(--color-text);
  --muted: var(--color-text-muted);
  --red: var(--color-failure);
  --pink: #f6edf1;
  --blue: var(--color-ink-blue);
  --yellow: var(--color-bg-secondary);
  --violet: #6e6e8a;
  --green: var(--color-success);
  --ink-black: var(--color-ink-black);
  --ink-blue: var(--color-ink-blue);
  --border-etched: 1px dashed rgba(26, 26, 46, .15);
  --border-etched-blue: rgba(43, 94, 166, .2);
  --shadow-soft:
    0 2px 8px rgba(26, 26, 46, .08),
    0 8px 24px rgba(26, 26, 46, .06),
    0 1px 3px rgba(43, 94, 166, .04);
  --shadow-light: 0 1px 4px rgba(26, 26, 46, .04);
  --paper-noise:
    radial-gradient(circle at 16% 18%, rgba(26, 26, 46, .022) 0 .35px, transparent .8px),
    radial-gradient(circle at 78% 34%, rgba(43, 94, 166, .018) 0 .38px, transparent .85px);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
}

body {
  color: var(--text);
  font-family: var(--font-body);
  letter-spacing: 0;
  line-height: 1.6;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  color: inherit;
  border: 0;
  background: transparent;
}

[hidden] {
  display: none !important;
}

::selection {
  color: var(--ink-black);
  background: rgba(43, 94, 166, .14);
}

::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  border-radius: 2px;
  background: rgba(116, 116, 130, .42);
}

.app-shell {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  height: 100vh;
  display: grid;
  grid-template-columns: 324px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "toolbar toolbar"
    "tray workspace";
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(248, 247, 244, .98) 46%, #f1efe9),
    var(--paper-noise);
  background-size: auto, 19px 23px, 31px 37px, 43px 47px;
}

.app-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .78;
  background-image:
    var(--paper-noise),
    linear-gradient(90deg, rgba(43, 94, 166, .035), transparent 28%, rgba(26, 26, 46, .025) 78%, transparent);
  background-size: 19px 23px, 31px 37px, 43px 47px, 100% 100%;
}

.app-shell.is-performance {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "workspace";
}

.app-shell.is-performance .editor-toolbar,
.app-shell.is-performance .editor-tray {
  display: none;
}

.editor-toolbar {
  grid-area: toolbar;
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 64px;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 26px;
  padding: 12px 18px 10px;
  border-bottom: var(--border-etched);
  border-bottom-color: rgba(43, 94, 166, .18);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .92), rgba(250, 249, 246, .88)),
    var(--paper-noise);
  background-size: auto, 19px 23px, 31px 37px, 43px 47px;
  box-shadow: var(--shadow-light);
  backdrop-filter: blur(10px);
}

.toolbar-brand h1 {
  margin: 0;
  color: var(--ink-black);
  font-family: Georgia, "Times New Roman", "Songti SC", serif;
  font-size: 21px;
  line-height: 1;
  white-space: nowrap;
  background: var(--ink-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.mode-tabs {
  display: flex;
  align-items: center;
  gap: 18px;
}

.mode-tab {
  position: relative;
  min-height: 32px;
  padding: 0 2px;
  color: rgba(26, 26, 46, .48);
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  transition: color .18s ease, opacity .18s ease, transform .18s ease;
}

.mode-tab > span {
  position: relative;
  z-index: 1;
}

.mode-tab::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 3px;
  height: 7px;
  opacity: .22;
  background-image: url("data:image/svg+xml,%3Csvg width='120' height='8' viewBox='0 0 120 8' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='5' cy='5.2' r='.8' fill='%231a1a2e' opacity='.55'/%3E%3Cpath d='M9 5.2C27 2.1 42 6.4 60 3.8c20-3 38 1.8 56-1.2' fill='none' stroke='%232b5ea6' stroke-width='1.2' stroke-linecap='round' stroke-dasharray='7 5 2 6' opacity='.74'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

.mode-tab.is-active,
.mode-tab:hover {
  color: var(--ink-black);
}

.mode-tab.is-active::after {
  opacity: 1;
}

.mode-tab.is-active > .ink-label {
  background: var(--ink-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-actions-slot {
  min-width: 0;
  display: none;
}

.side-actions-slot {
  min-width: 0;
  display: block;
}

.toolbar-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
}

.side-actions-slot .toolbar-actions {
  width: 100%;
}

.tool-button {
  width: 56px;
  min-height: 42px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  border: var(--border-etched);
  border-right-color: rgba(43, 94, 166, .2);
  border-bottom-color: rgba(43, 94, 166, .16);
  border-radius: 3px;
  background: rgba(255, 255, 255, .46);
  color: rgba(26, 26, 46, .72);
  font-size: 11px;
  font-weight: 560;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(26, 26, 46, .03);
  transition: transform .18s ease, color .18s ease, background-color .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.tool-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool-button:hover,
.tool-button:focus-visible {
  color: var(--text);
  border-color: rgba(43, 94, 166, .32);
  background: rgba(248, 247, 244, .9);
  box-shadow: 0 4px 12px rgba(26, 26, 46, .08);
  transform: translateY(-2px);
  outline: none;
}

.tool-button.is-recording {
  color: var(--red);
  background: rgba(139, 58, 58, .08);
}

.editor-tray {
  grid-area: tray;
  z-index: 10;
  overflow: auto;
  padding: 18px 0 18px 18px;
  border-top: 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, .55), transparent 72%);
  box-shadow: none;
}

.tray-strip {
  width: 100%;
  max-width: none;
  min-height: 100%;
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 22px;
  padding: 18px;
  border: var(--border-etched);
  border-right-color: rgba(43, 94, 166, .2);
  border-bottom-color: rgba(43, 94, 166, .16);
  border-radius: 3px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .88), rgba(250, 249, 246, .92)),
    var(--paper-noise);
  background-size: auto, 19px 23px, 31px 37px, 43px 47px;
  box-shadow:
    0 2px 8px rgba(26, 26, 46, .07),
    0 12px 28px rgba(26, 26, 46, .06),
    0 1px 3px rgba(43, 94, 166, .04);
  backdrop-filter: blur(8px);
}

.tray-group {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.tray-group + .tray-group {
  padding-top: 18px;
  border-top: 1px dashed rgba(26, 26, 46, .12);
}

.tray-group-layout {
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  column-gap: 0;
}

.tray-group-layout .section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tray-group-cells {
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  column-gap: 0;
}

.tray-group-cells h2 {
  grid-column: auto;
  grid-row: auto;
}

.tray-group-cells .cell-picker {
  grid-column: auto;
  grid-row: auto;
}

.tray-group h2 {
  margin: 0;
  color: var(--ink-black);
  font-size: 12px;
  font-weight: 620;
  letter-spacing: .08em;
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.field + .field {
  margin-top: 12px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: var(--border-etched);
  border-right-color: rgba(43, 94, 166, .18);
  border-bottom-color: rgba(43, 94, 166, .14);
  border-radius: 3px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, .66);
  color: var(--text);
  outline: none;
}

.field select {
  min-height: 36px;
  cursor: pointer;
}

.field textarea {
  resize: vertical;
  min-height: 60px;
  line-height: 1.45;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(43, 94, 166, .1);
}

.upload-card {
  min-height: 36px;
  display: grid;
  place-items: center;
  border: var(--border-etched);
  border-right-color: rgba(43, 94, 166, .18);
  border-bottom-color: rgba(43, 94, 166, .14);
  border-radius: 3px;
  background: rgba(255, 255, 255, .58);
  color: rgba(26, 26, 46, .8);
  font-size: 13px;
  font-weight: 560;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background-color .18s ease, box-shadow .18s ease;
}

.upload-card:hover {
  border-color: var(--blue);
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 4px 12px rgba(26, 26, 46, .07);
  transform: translateY(-2px);
}

.cell-tool-list {
  grid-column: auto;
  grid-row: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: end;
}

.upload-card input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.layout-picker,
.cell-picker {
  display: grid;
}

.layout-picker {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.paper-effect-field {
  margin-top: 12px;
}

.cell-picker {
  grid-template-columns: repeat(9, minmax(0, 1fr));
  justify-content: start;
  gap: 5px;
}

.layout-picker button,
.cell-picker button,
.quiet-button,
.action-button {
  border: var(--border-etched);
  border-right-color: rgba(43, 94, 166, .18);
  border-bottom-color: rgba(43, 94, 166, .14);
  border-radius: 3px;
  background: rgba(255, 255, 255, .5);
  color: var(--text);
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background-color .18s ease, color .18s ease, box-shadow .18s ease;
}

.layout-picker button {
  width: auto;
  min-height: 48px;
  display: grid;
  justify-items: center;
  align-content: center;
  padding: 0;
  font-weight: 750;
}

.cell-picker button {
  width: auto;
  aspect-ratio: 1;
  min-width: 0;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 11px;
  font-weight: 620;
}

.layout-picker button[aria-checked="true"],
.cell-picker button[aria-selected="true"] {
  background: var(--paper);
  color: var(--paper-ink);
  border-color: rgba(43, 94, 166, .36);
  box-shadow: inset 0 -2px 0 rgba(43, 94, 166, .18), 0 2px 8px rgba(26, 26, 46, .06);
}

.layout-thumb {
  width: 34px;
  height: 25px;
  display: grid;
  gap: 2px;
}

.layout-thumb i {
  display: block;
  border: 1px dashed currentColor;
  opacity: .66;
}

.layout-thumb[data-count="1"] {
  grid-template-columns: 1fr;
}

.layout-thumb[data-count="2"] {
  grid-template-columns: repeat(2, 1fr);
}

.layout-thumb[data-count="6"],
.layout-thumb[data-count="9"] {
  grid-template-columns: repeat(3, 1fr);
}

.layout-thumb[data-count="6"] {
  grid-template-rows: repeat(2, 1fr);
}

.layout-thumb[data-count="9"] {
  grid-template-rows: repeat(3, 1fr);
}

.quiet-button {
  height: 26px;
  padding: 0 6px;
  color: var(--muted);
  font-size: 12px;
  background: transparent;
}

.layout-picker button:hover,
.cell-picker button:hover,
.quiet-button:hover,
.action-button:hover {
  border-color: rgba(43, 94, 166, .3);
  background: rgba(255, 255, 255, .84);
  box-shadow: 0 4px 12px rgba(26, 26, 46, .07);
  transform: translateY(-2px);
}

.action-button {
  min-height: 38px;
  padding: 0 12px;
}

.action-button.primary {
  border-color: rgba(43, 94, 166, .32);
  background: var(--ink-gradient);
  color: #fff;
  font-weight: 780;
}

.share-dialog {
  width: min(520px, calc(100vw - 32px));
  border: 1px solid var(--line-strong);
  border-style: dashed;
  border-radius: 3px;
  padding: 0;
  background: transparent;
  color: var(--text);
}

.share-dialog::backdrop {
  background: rgba(26, 26, 46, .22);
  backdrop-filter: blur(2px);
}

.share-card {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .92), rgba(250, 249, 246, .94)),
    var(--paper-noise);
  background-size: auto, 19px 23px, 31px 37px, 43px 47px;
  box-shadow: 0 4px 20px rgba(26, 26, 46, .12);
}

.share-card h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  color: var(--ink-black);
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border: var(--border-etched);
  border-radius: 3px;
  background: rgba(255, 255, 255, .56);
  color: var(--muted);
  cursor: pointer;
}

.share-hint,
.share-error {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
}

.share-hint {
  color: var(--muted);
}

.share-error {
  color: var(--green);
}

.share-error.is-error {
  color: var(--red);
}

.share-dialog textarea {
  min-height: 128px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  line-height: 1.4;
}

.share-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.share-actions .action-button:only-child {
  grid-column: 2;
}

.share-actions:has(.action-button[hidden]) .action-button:not([hidden]) {
  grid-column: 1 / -1;
}

.usage-notice-button {
  display: block;
  position: static;
  margin: 7px auto 12px;
  padding: 2px 8px;
  color: var(--color-text-muted);
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.usage-notice-button:hover,
.usage-notice-button:focus-visible {
  color: var(--color-text);
  outline: 1px dashed var(--line-strong);
  outline-offset: 2px;
}

.usage-dialog {
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  border: 2px dashed var(--line);
  border-right-color: var(--line-strong);
  border-bottom-color: var(--line-strong);
  border-radius: 0;
  padding: 0;
  overflow: auto;
  background: transparent;
  color: var(--color-text);
}

.usage-dialog::backdrop {
  background: rgba(255, 255, 255, 0.85);
}

.usage-card {
  position: relative;
  padding: 28px 32px 30px;
  background: var(--color-bg);
  box-shadow: 0 4px 20px rgba(26, 26, 46, 0.08);
}

.usage-card h2 {
  width: fit-content;
  margin: 0 0 20px;
  color: var(--color-text);
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: normal;
  letter-spacing: 0.08em;
}

.usage-copy {
  display: grid;
  gap: 14px;
  color: var(--color-text-dim);
  font-size: 13px;
  line-height: 1.75;
}

.usage-copy p {
  margin: 0;
}

.usage-copy strong {
  color: var(--color-text);
  font-weight: 700;
}

.workspace {
  grid-area: workspace;
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 22px 26px;
}

.app-shell.is-performance .workspace {
  padding: 0;
  place-items: stretch;
  min-height: 100vh;
}

.poster-stage {
  width: min(100%, calc(100vh - 220px), 800px);
  min-width: 0;
}

.poster {
  container-type: inline-size;
  position: relative;
  width: 100%;
  aspect-ratio: 10 / 11;
  overflow: hidden;
  border: var(--border-etched);
  border-right-color: rgba(43, 94, 166, .22);
  border-bottom-color: rgba(43, 94, 166, .16);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(248, 247, 244, .96)),
    var(--paper-noise);
  background-size: auto, 19px 23px, 31px 37px, 43px 47px;
  box-shadow:
    0 2px 8px rgba(26, 26, 46, .08),
    0 18px 42px rgba(26, 26, 46, .1),
    0 1px 3px rgba(43, 94, 166, .04);
  user-select: none;
}

.poster::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .78;
  background-image:
    linear-gradient(90deg, rgba(26, 26, 46, .06), transparent 10%, transparent 90%, rgba(43, 94, 166, .05)),
    linear-gradient(180deg, rgba(26, 26, 46, .04), transparent 16%, transparent 84%, rgba(43, 94, 166, .045));
}

.poster-kicker {
  position: absolute;
  right: 4.7%;
  bottom: 2.8%;
  z-index: 3;
  color: rgba(43, 94, 166, .76);
  text-align: right;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(10px, 1.65cqw, 18px);
  font-weight: 760;
  max-width: 46%;
  pointer-events: none;
}

.poster-title {
  position: absolute;
  left: 5%;
  right: 5%;
  top: 5.4%;
  z-index: 3;
  margin: 0;
  color: var(--ink-black);
  text-align: center;
  font-family: Georgia, "Times New Roman", "Songti SC", serif;
  font-size: clamp(25px, 5.35cqw, 54px);
  line-height: 1.05;
  max-height: 2.1em;
  overflow: hidden;
  white-space: pre-line;
  overflow-wrap: anywhere;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, .82),
    1.5px .8px 0 rgba(43, 94, 166, .14);
}

.poster-title[contenteditable],
.cell-title[contenteditable] {
  cursor: text;
  outline: none;
  border-radius: 2px;
  user-select: text;
}

.poster-title[contenteditable]:focus,
.cell-title[contenteditable]:focus {
  background-color: rgba(43, 94, 166, .06);
  box-shadow: 0 0 0 1px rgba(43, 94, 166, .22);
}

.cell-grid {
  position: absolute;
  left: 6.4%;
  right: 6.4%;
  top: 18.2%;
  bottom: 8.2%;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(var(--grid-cols, 3), minmax(0, 1fr));
  grid-template-rows: repeat(var(--grid-rows, 3), minmax(0, 1fr));
  column-gap: 6.6%;
  row-gap: 4.8%;
}

.poster[data-cell-count="1"] .cell-grid {
  left: 13%;
  right: 13%;
  top: 22%;
  bottom: 13%;
  column-gap: 0;
  row-gap: 0;
}

.poster[data-cell-count="2"] .cell-grid {
  left: 8%;
  right: 8%;
  top: 27%;
  bottom: 18%;
  column-gap: 8%;
  row-gap: 0;
}

.poster[data-cell-count="6"] .cell-grid {
  top: 20%;
  bottom: 10%;
  row-gap: 8%;
}

.poster[data-cell-count="9"] .cell-grid {
  top: 18.8%;
  bottom: 8.8%;
  row-gap: 5.6%;
}

.story-cell {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  align-items: start;
  text-align: center;
  cursor: pointer;
  overflow: visible;
}

.story-cell.is-active .image-frame {
  outline: none;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, .95),
    0 0 0 2px rgba(43, 94, 166, .42),
    0 6px 14px rgba(26, 26, 46, .12);
}

.image-frame {
  position: relative;
  width: min(66%, clamp(48px, 14.2cqw, 128px));
  aspect-ratio: 1;
  justify-self: center;
  overflow: visible;
  border: 1px dashed rgba(26, 26, 46, .18);
  border-right-color: rgba(43, 94, 166, .26);
  border-bottom-color: rgba(43, 94, 166, .2);
  background: #fff;
  box-shadow:
    0 2px 8px rgba(26, 26, 46, .09),
    0 1px 2px rgba(43, 94, 166, .05);
  isolation: isolate;
}

.poster[data-cell-count="1"] .story-cell {
  align-content: center;
}

.poster[data-cell-count="1"] .image-frame {
  width: min(64%, clamp(166px, 38cqw, 360px));
}

.poster[data-cell-count="2"] .image-frame {
  width: min(78%, clamp(118px, 27cqw, 264px));
}

.poster[data-cell-count="6"] .image-frame {
  width: min(74%, clamp(68px, 18cqw, 170px));
}

.base-image,
.hold-image,
.rain-image,
.fade-image,
.breakout-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(var(--image-scale, 1));
}

.cell-title {
  margin-top: clamp(8px, 1.15cqw, 13px);
  color: var(--ink-black);
  font-family: Georgia, "Times New Roman", "Songti SC", serif;
  font-size: clamp(11px, 2.2cqw, 21px);
  font-weight: 800;
  line-height: 1.08;
  max-height: 2.16em;
  overflow: hidden;
  overflow-wrap: anywhere;
  white-space: pre-line;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .72);
}

.poster[data-cell-count="9"] .cell-title {
  margin-top: clamp(8px, 1cqw, 12px);
  font-size: clamp(11px, 2.05cqw, 19px);
}

.poster[data-cell-count="1"] .cell-title {
  margin-top: clamp(8px, 1.2cqw, 14px);
  font-size: clamp(28px, 5.2cqw, 52px);
  max-height: 4.32em;
}

.poster[data-cell-count="2"] .cell-title {
  margin-top: clamp(6px, 1cqw, 10px);
  font-size: clamp(20px, 3.6cqw, 38px);
  max-height: 4.32em;
}

.poster[data-cell-count="6"] .cell-title {
  font-size: clamp(14px, 2.75cqw, 27px);
}

.performance-stage {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 56px 64px 84px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .98), rgba(248, 247, 244, .98)),
    var(--paper-noise);
  background-size: auto, 19px 23px, 31px 37px, 43px 47px;
}

.performance-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .64;
  pointer-events: none;
  background-image:
    linear-gradient(90deg, rgba(26, 26, 46, .04), transparent 18%, transparent 82%, rgba(43, 94, 166, .04)),
    linear-gradient(180deg, rgba(26, 26, 46, .04), transparent 18%, transparent 82%, rgba(43, 94, 166, .04));
}

.performance-scene {
  position: relative;
  z-index: 1;
  width: min(100%, 980px);
  min-height: min(72vh, 760px);
  display: grid;
  place-items: center;
}

.performance-intro {
  width: min(100%, 900px);
  display: grid;
  justify-items: center;
  gap: 24px;
  text-align: center;
}

.performance-title {
  color: var(--ink-black);
  font-family: Georgia, "Times New Roman", "Songti SC", serif;
  font-size: clamp(42px, 8vw, 96px);
  font-weight: 800;
  line-height: 1.02;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, .82),
    2px 1px 0 rgba(43, 94, 166, .14);
}

.performance-filler {
  color: rgba(43, 94, 166, .76);
  font-family: Georgia, "Times New Roman", "Songti SC", serif;
  font-size: clamp(18px, 3vw, 34px);
  font-weight: 760;
}

.performance-cell {
  width: min(100%, 860px);
  display: grid;
  grid-template-rows: auto auto auto;
  align-items: center;
  justify-items: center;
  text-align: center;
  cursor: default;
}

.performance-cell .image-frame {
  width: min(48vmin, 440px);
}

.performance-cell .cell-title {
  margin-top: clamp(14px, 2vmin, 24px);
  font-size: clamp(34px, 6vmin, 70px);
}

.performance-edit-button,
.performance-next {
  position: absolute;
  z-index: 4;
  min-height: 42px;
  border: var(--border-etched);
  border-right-color: rgba(43, 94, 166, .2);
  border-bottom-color: rgba(43, 94, 166, .16);
  border-radius: 3px;
  padding: 0 18px;
  color: var(--text);
  font-weight: 680;
  cursor: pointer;
  background: rgba(255, 255, 255, .64);
  box-shadow: 0 2px 8px rgba(26, 26, 46, .08);
}

.performance-edit-button {
  top: 18px;
  right: 18px;
  min-height: 32px;
  padding: 0 2px;
  background: transparent;
  border-radius: 0;
  border: 0;
  box-shadow: none;
}

.performance-next {
  right: 24px;
  bottom: 24px;
  border-color: rgba(43, 94, 166, .32);
  background: var(--ink-gradient);
  color: #fff;
}

.scratch-canvas,
.pixel-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.scratch-canvas {
  z-index: 4;
  touch-action: none;
  cursor: crosshair;
}

.scratch-hint,
.hold-hint,
.pixel-hint {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 8%;
  z-index: 5;
  color: rgba(255, 255, 255, .82);
  font-size: 11px;
  letter-spacing: 0;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
  pointer-events: none;
}

.story-cell.has-scratched .scratch-hint {
  opacity: 0;
}

.template-hold .image-frame {
  overflow: hidden;
  background: #030304;
}

.hold-image {
  opacity: var(--hold-opacity, 0);
  filter: blur(var(--hold-blur, 6px)) grayscale(var(--hold-gray, 1)) brightness(var(--hold-brightness, .45));
  transition: opacity .12s linear, filter .12s linear;
}

.hold-veil {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: var(--hold-veil-opacity, 1);
  background: #000;
  mix-blend-mode: normal;
  pointer-events: none;
}

.hold-progress {
  position: absolute;
  left: 9%;
  right: 9%;
  bottom: 9%;
  z-index: 4;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, .22);
}

.hold-progress i {
  display: block;
  width: calc(var(--hold-progress, 0) * 100%);
  height: 100%;
  background: rgba(255, 255, 255, .72);
}

.hold-hit {
  position: absolute;
  inset: 0;
  z-index: 6;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}

.template-pixel .image-frame,
.template-pixelPen .image-frame,
.template-pixelTone .image-frame,
.template-tadc .image-frame,
.template-rain .image-frame,
.template-fade .image-frame,
.template-wireTerminal .image-frame {
  overflow: hidden;
}

.pixel-canvas {
  image-rendering: pixelated;
}

.template-pixelPen .pixel-scan {
  background:
    repeating-linear-gradient(92deg, rgba(255, 255, 255, .08) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .25) 0 1px, transparent 1px 5px),
    linear-gradient(120deg, rgba(24, 44, 86, .22), rgba(240, 238, 226, .08));
  mix-blend-mode: hard-light;
}

.template-pixelTone .pixel-scan {
  background:
    radial-gradient(circle at 22% 16%, rgba(255, 242, 84, .28), transparent 32%),
    radial-gradient(circle at 74% 72%, rgba(255, 70, 122, .22), transparent 30%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .16) 0 1px, transparent 1px 8px);
  mix-blend-mode: screen;
}

.template-tadc .pixel-scan {
  background:
    repeating-linear-gradient(90deg, rgba(8, 7, 15, .2) 0 1px, transparent 1px 7px),
    radial-gradient(circle at 18% 18%, rgba(255, 210, 10, .32), transparent 28%),
    radial-gradient(circle at 76% 28%, rgba(69, 220, 236, .26), transparent 30%),
    radial-gradient(circle at 52% 78%, rgba(255, 44, 125, .3), transparent 34%),
    linear-gradient(135deg, rgba(115, 87, 244, .2), rgba(27, 215, 145, .14));
  mix-blend-mode: screen;
}

.pixel-scan {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: var(--pixel-progress, 1);
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .18) 0 1px, transparent 1px 4px),
    linear-gradient(90deg, rgba(255, 45, 45, .08), transparent 27%, rgba(72, 216, 255, .08));
  mix-blend-mode: hard-light;
}

.template-wireTerminal .image-frame {
  background: #001e9a;
  border: 2px solid rgba(248, 252, 255, .92);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, .35),
    inset 0 0 24px rgba(0, 0, 0, .3);
  font-family: "Courier New", Courier, monospace;
}

.wire-code {
  position: absolute;
  inset: 7px 6px;
  z-index: 3;
  margin: 0;
  overflow: hidden;
  color: rgba(248, 252, 255, .94);
  font-family: inherit;
  font-size: 6.8px;
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: 0;
  white-space: pre;
  text-align: left;
  text-shadow: 0 0 5px rgba(255, 255, 255, .28);
}

.wire-terminal-glow {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .08) 0 1px, transparent 1px 4px),
    radial-gradient(circle at 50% 48%, rgba(255, 255, 255, .18), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, .08), transparent 26%, rgba(0, 0, 0, .18));
  mix-blend-mode: screen;
}

.wire-image {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  width: 92%;
  height: 92%;
  object-fit: cover;
  transform: translate(-50%, -50%) scale(var(--image-scale, 1));
  border: 1px solid rgba(255, 255, 255, .9);
  animation: wire-image-reveal var(--wire-reveal-duration, 8s) ease-out .7s both;
  box-shadow:
    0 0 0 1px rgba(0, 26, 148, .85),
    0 0 18px rgba(255, 255, 255, .24);
}

.wire-image::selection {
  background: transparent;
}

@keyframes wire-image-reveal {
  0% {
    opacity: 0;
    filter: saturate(.25) brightness(.28) contrast(1.35);
  }
  100% {
    opacity: .84;
    filter: saturate(.9) brightness(.82) contrast(1.08);
  }
}

.performance-cell .wire-code {
  inset: 4%;
  font-size: clamp(10px, 1.45vmin, 14px);
  line-height: 1.24;
}

.template-rain .image-frame {
  background: #061015;
  cursor: crosshair;
  touch-action: none;
}

.rain-image {
  filter: saturate(.9) contrast(.96) brightness(.92) blur(.15px);
}

.rain-blue-wash,
.rain-reflection,
.rain-canvas,
.rain-vignette,
.fade-wash,
.fade-grain,
.breakout-border,
.breakout-diamond {
  position: absolute;
  inset: 0;
}

.rain-blue-wash {
  z-index: 2;
  opacity: .72;
  mix-blend-mode: color;
  background:
    radial-gradient(ellipse at 24% 16%, rgba(232, 255, 255, .4), transparent 32%),
    radial-gradient(ellipse at 76% 24%, rgba(106, 205, 232, .24), transparent 36%),
    linear-gradient(180deg, rgba(225, 251, 255, .14), rgba(48, 151, 188, .24));
}

.rain-reflection {
  z-index: 3;
  opacity: .72;
  filter: blur(9px);
  mix-blend-mode: screen;
  background:
    radial-gradient(ellipse at 24% 20%, rgba(255, 255, 255, .28), transparent 24%),
    linear-gradient(104deg, transparent 0 18%, rgba(224, 250, 255, .25) 25%, transparent 38%),
    linear-gradient(82deg, transparent 0 54%, rgba(130, 230, 240, .22) 61%, transparent 72%);
}

.rain-canvas {
  z-index: 4;
  width: 100%;
  height: 100%;
  display: block;
  opacity: .9;
  filter: saturate(1.2) contrast(1.1);
}

.rain-vignette {
  z-index: 5;
  pointer-events: none;
  box-shadow:
    inset 0 0 35px rgba(3, 28, 40, .34),
    inset 0 -60px 72px rgba(9, 53, 72, .25),
    inset 0 54px 70px rgba(234, 255, 255, .14);
}

.template-fade .image-frame {
  background: #000;
}

.fade-image {
  animation: fade-away 12s ease-in-out 1 forwards;
}

.fade-wash {
  z-index: 2;
  opacity: .75;
  background:
    radial-gradient(circle at 28% 19%, rgba(255, 255, 255, .16), transparent 28%),
    linear-gradient(135deg, rgba(255, 255, 255, .08), rgba(0, 0, 0, .42) 55%, rgba(0, 0, 0, .86));
  animation: fade-overlay-away 12s ease-in-out 1 forwards;
}

.fade-grain {
  z-index: 3;
  opacity: .35;
  mix-blend-mode: screen;
  background:
    radial-gradient(circle at 12% 24%, rgba(255, 255, 255, .55) 0 .8px, transparent 1.4px),
    radial-gradient(circle at 66% 72%, rgba(255, 255, 255, .42) 0 .7px, transparent 1.3px);
  background-size: 13px 17px, 19px 23px;
  animation: fade-grain 12s linear 1 forwards;
}

@keyframes fade-away {
  0% {
    opacity: .96;
    filter: blur(0) saturate(1) brightness(1);
    transform: scale(var(--image-scale, 1));
  }
  68% {
    opacity: .22;
    filter: blur(2px) saturate(.55) brightness(.68);
    transform: scale(calc(var(--image-scale, 1) * 1.03));
  }
  100% {
    opacity: 0;
    filter: blur(5px) saturate(.15) brightness(.34);
    transform: scale(calc(var(--image-scale, 1) * 1.055));
  }
}

@keyframes fade-overlay-away {
  0%, 68% { opacity: .75; }
  100% { opacity: 0; }
}

@keyframes fade-grain {
  0% { opacity: .16; }
  70% { opacity: .34; }
  100% { opacity: 0; }
}

.template-breakout .image-frame {
  overflow: visible;
  background: transparent;
}

.breakout-border {
  inset: 9%;
  z-index: 1;
  border: 2px solid rgba(238, 238, 232, .82);
  background: rgba(8, 8, 10, .34);
  box-shadow: inset 0 0 28px rgba(0, 0, 0, .45);
}

.breakout-diamond {
  inset: -6%;
  z-index: 2;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  filter: drop-shadow(0 12px 12px rgba(0, 0, 0, .6));
}

.breakout-diamond::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid rgba(255, 255, 255, .9);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  pointer-events: none;
}

.breakout-image {
  transform: scale(calc(var(--image-scale, 1) * 1.08));
}

.template-torn .image-frame {
  background: transparent;
}

.torn-base-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(var(--image-scale, 1));
  animation: torn-base-release 3.2s ease-in-out 1 forwards;
}

.torn-svg {
  position: absolute;
  inset: -12%;
  width: 124%;
  height: 124%;
  overflow: visible;
}

.torn-main {
  animation: torn-main-settle 3.2s ease-in-out 1 forwards;
}

.torn-piece {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: 80% 80%;
  animation: torn-piece-split 3.2s ease-in-out 1 forwards;
  filter: drop-shadow(4px 8px 5px rgba(0, 0, 0, .72));
}

.torn-main .tear-line,
.torn-main .tear-shadow,
.torn-main .tear-crease,
.torn-main .paper-fiber,
.torn-main .paper-dust,
.torn-main .paper-edge-texture,
.torn-main .photo-outline,
.torn-piece .tear-line,
.torn-piece .tear-shadow,
.torn-piece .tear-crease,
.torn-piece .paper-fiber,
.torn-piece .paper-dust,
.torn-piece .paper-edge-texture,
.torn-piece .photo-outline {
  animation: tear-edge-reveal 3.2s ease-in-out 1 forwards;
}

.tear-line {
  fill: none;
  stroke: rgba(226, 219, 204, .62);
  stroke-width: .42;
  stroke-linecap: butt;
  stroke-linejoin: miter;
}

.tear-shadow {
  fill: none;
  stroke: rgba(0, 0, 0, .8);
  stroke-width: 1.7;
  stroke-linecap: butt;
  stroke-linejoin: miter;
}

.tear-crease {
  fill: none;
  stroke: rgba(70, 57, 45, .42);
  stroke-width: .28;
  stroke-linecap: butt;
  stroke-linejoin: miter;
}

.paper-fiber {
  stroke: rgba(244, 236, 218, .72);
  stroke-width: .36;
  stroke-linecap: round;
}

.paper-dust {
  fill: rgba(242, 236, 222, .78);
}

.paper-edge-texture {
  fill: none;
  stroke: rgba(246, 241, 228, .92);
  stroke-width: 18;
  stroke-linecap: butt;
  stroke-linejoin: miter;
  opacity: .98;
  pointer-events: none;
}

.photo-paper {
  fill: #f2eadc;
}

.photo-outline {
  fill: none;
  stroke: rgba(248, 244, 232, .86);
  stroke-width: 1.15;
  stroke-linejoin: miter;
}

.torn-main {
  filter: drop-shadow(-2px 4px 4px rgba(0, 0, 0, .46));
}

@keyframes torn-base-release {
  0%, 42% {
    opacity: 1;
  }
  66%, 100% {
    opacity: 0;
  }
}

@keyframes tear-edge-reveal {
  0%, 24% {
    opacity: 0;
  }
  48%, 100% {
    opacity: 1;
  }
}

@keyframes torn-main-settle {
  0%, 58% {
    transform: translate(0, 0);
  }
  100% {
    transform: translate(-1.5%, -1%);
  }
}

@keyframes torn-piece-split {
  0%, 44% {
    opacity: 0;
    transform: translate(0, 0) rotate(0deg);
  }
  58% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg);
  }
  100% {
    opacity: 1;
    transform: translate(14%, 12%) rotate(8deg);
  }
}

@media (max-width: 700px) {
  .app-shell {
    min-height: 100dvh;
    height: auto;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "toolbar"
      "workspace"
      "tray";
    overflow: visible;
  }

  .editor-toolbar {
    min-height: auto;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 9px 14px;
    padding: 14px 18px 11px;
  }

  .toolbar-brand h1 {
    font-size: 23px;
    line-height: 1.1;
  }

  .mode-tabs {
    justify-self: end;
    gap: 13px;
  }

  .mode-tab {
    min-height: 30px;
    font-size: 13px;
  }

  .toolbar-actions {
    grid-column: 1 / -1;
    width: 100%;
    display: flex;
    justify-content: space-evenly;
    gap: 6px;
    overflow: visible;
    padding-bottom: 0;
  }

  .header-actions-slot {
    grid-column: 1 / -1;
    width: 100%;
    display: block;
  }

  .side-actions-slot {
    display: none;
  }

  .tool-button {
    width: 50px;
    min-height: 38px;
    gap: 1px;
    font-size: 10.5px;
  }

  .workspace {
    min-height: auto;
    place-items: start center;
    padding: 18px 14px 34px;
  }

  .poster-stage {
    width: min(100%, 560px);
  }

  .poster[data-cell-count="9"] .cell-grid {
    top: 17.6%;
    bottom: 6.4%;
    row-gap: 3.8%;
  }

  .poster[data-cell-count="9"] .image-frame {
    width: min(62%, clamp(44px, 13cqw, 88px));
  }

  .poster[data-cell-count="9"] .cell-title {
    margin-top: clamp(6px, 1.7cqw, 8px);
    font-size: clamp(10px, 2.9cqw, 13px);
    line-height: 1.04;
  }

  .editor-tray {
    max-height: none;
    overflow: visible;
    padding: 2px 12px calc(12px + env(safe-area-inset-bottom));
  }

  .tray-strip {
    width: min(100%, 350px);
    max-width: 350px;
    min-height: 0;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  .tray-group {
    padding: 0;
  }

  .tray-group-layout,
  .tray-group-cells {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .tray-group-layout .section-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .tray-group-cells h2,
  .tray-group-cells .cell-picker,
  .tray-group-cells .cell-tool-list {
    grid-column: 1;
    grid-row: auto;
  }

  .layout-picker {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    justify-content: center;
    gap: 8px;
  }

  .layout-picker button {
    width: auto;
    min-height: 46px;
  }

  .layout-thumb {
    width: 38px;
    height: 28px;
  }

  .cell-picker {
    grid-template-columns: repeat(9, minmax(0, 1fr));
    justify-content: center;
    gap: 4px;
  }

  .cell-picker button {
    width: auto;
    font-size: 12px;
  }

  .field textarea {
    min-height: 86px;
  }

  .cell-tool-list {
    grid-template-columns: minmax(108px, .52fr) minmax(0, 1fr);
    gap: 8px;
  }

  .upload-card {
    min-height: 40px;
  }

  .performance-stage {
    min-height: 100dvh;
    padding: 56px 18px calc(92px + env(safe-area-inset-bottom));
  }

  .performance-scene {
    min-height: calc(100dvh - 170px);
    width: 100%;
  }

  .performance-title {
    font-size: clamp(32px, 10.8vw, 46px);
  }

  .performance-filler {
    font-size: clamp(17px, 5vw, 24px);
  }

  .performance-cell {
    width: 100%;
  }

  .performance-cell .image-frame {
    width: min(78vw, 390px);
  }

  .performance-cell .cell-title {
    margin-top: 18px;
    font-size: clamp(34px, 10vw, 54px);
  }

  .performance-edit-button {
    top: calc(12px + env(safe-area-inset-top));
    right: 14px;
  }

  .performance-next {
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom));
  }
}

@font-face {
  font-family: "HuiwenMinchoBase";
  src: url("assets/fonts/HuiwenMincho-base-v2.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "HuiwenMinchoCommon";
  src: url("assets/fonts/HuiwenMincho-common-v2.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --color-bg: #ffffff;
  --color-bg-secondary: #f8f7f4;
  --color-bg-panel: #faf9f6;
  --color-ink-black: #1a1a2e;
  --color-ink-blue: #2b5ea6;
  --color-border-black: #1a1a2e;
  --color-border-blue: #2b5ea6;
  --color-text: #1a1a2e;
  --color-text-dim: #4a4a5a;
  --color-text-muted: #8a8a9a;
  --color-success: #2a6a3a;
  --color-failure: #8b3a3a;
  --ink-gradient: linear-gradient(to right, var(--color-ink-black) 0%, var(--color-ink-black) 66%, var(--color-ink-blue) 100%);
  --font-body: "HuiwenMinchoBase", "HuiwenMinchoCommon", "Noto Serif SC", "Songti SC", "SimSun", serif;
  --font-heading: "HuiwenMinchoBase", "HuiwenMinchoCommon", "Noto Serif SC", "Songti SC", "SimSun", serif;
  --radius: 2px;
  --panel-padding: 12px;
  --bg: var(--color-bg);
  --panel: var(--color-bg-panel);
  --panel-2: var(--color-bg-secondary);
  --paper: var(--color-bg);
  --paper-ink: var(--color-ink-black);
  --line: rgba(26, 26, 46, 0.15);
  --line-strong: rgba(43, 94, 166, 0.2);
  --text: var(--color-text);
  --muted: var(--color-text-muted);
  --red: var(--color-failure);
  --pink: #f6edf1;
  --blue: var(--color-ink-blue);
  --yellow: var(--color-bg-secondary);
  --violet: #6e6e8a;
  --green: var(--color-success);
  --ink-black: var(--color-ink-black);
  --ink-blue: var(--color-ink-blue);
  --border-etched: 1px dashed rgba(26, 26, 46, 0.15);
  --border-etched-blue: rgba(43, 94, 166, 0.2);
  --shadow-soft:
    0 2px 8px rgba(26, 26, 46, 0.08),
    0 8px 24px rgba(26, 26, 46, 0.06),
    0 1px 3px rgba(43, 94, 166, 0.04);
  --shadow-light: 0 1px 4px rgba(26, 26, 46, 0.04);
}

html,
body {
  height: 100%;
  width: 100%;
  background-color: var(--color-bg);
}

body {
  font-family: var(--font-body);
  color: var(--color-text);
  line-height: 1.6;
  overflow: hidden;
}

button,
input,
textarea,
select {
  font-family: var(--font-body);
}

button {
  cursor: pointer;
  border: none;
  background: transparent;
  padding: 8px 16px;
  font-size: 0.95rem;
  position: relative;
}

button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #c0c0cc;
  border-radius: 2px;
}

.app-shell {
  background: var(--color-bg);
}

.app-shell::before {
  display: none;
}

.editor-toolbar {
  min-height: 58px;
  border-bottom: 1px dashed rgba(26, 26, 46, 0.1);
  background: var(--color-bg);
  box-shadow: none;
  backdrop-filter: none;
}

.toolbar-brand h1,
.mode-tab.is-active > .ink-label,
.poster-title,
.performance-title,
.action-button.primary {
  background: var(--ink-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.toolbar-brand h1 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  line-height: 1;
  letter-spacing: 0.15em;
}

.mode-tabs {
  gap: 26px;
}

.mode-tab,
.quiet-button,
.performance-edit-button {
  height: auto;
  min-height: auto;
  border: none;
  border-radius: 0;
  padding: 10px 0;
  background: transparent;
  box-shadow: none;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-weight: normal;
  letter-spacing: 0.15em;
  line-height: 1.6;
  transition: color 0.2s;
}

.mode-tab:hover,
.mode-tab.is-active,
.quiet-button:hover,
.performance-edit-button:hover {
  color: var(--color-text);
  background: transparent;
  box-shadow: none;
  transform: none;
}

.mode-tab::after,
.performance-edit-button::after {
  content: none;
  display: none;
}

.mode-tab.is-active::after,
.performance-edit-button.is-active::after {
  opacity: 1;
}

.ink-underline {
  display: block;
  position: absolute;
  left: 50%;
  top: calc(100% + 2px);
  height: 8px;
  transform: translateX(-50%);
  -webkit-background-clip: border-box;
  background-clip: border-box;
  -webkit-text-fill-color: initial;
  background-repeat: no-repeat;
  background-position: center;
  pointer-events: none;
}

.ink-label {
  position: relative;
  display: block;
  width: max-content;
}

.mode-tab .ink-underline,
.performance-edit-button .ink-underline,
.tool-button .ink-underline,
.quiet-button .ink-underline,
.action-button.primary .ink-underline {
  position: absolute;
  opacity: 0;
  transition: opacity 0.2s;
}

.mode-tab.is-active .ink-underline,
.performance-edit-button.is-active .ink-underline,
.tool-button:hover .ink-underline,
.tool-button:focus .ink-underline,
.tool-button:active .ink-underline,
.tool-button.is-selected .ink-underline,
.tool-button.is-recording .ink-underline,
.quiet-button .ink-underline,
.action-button.primary .ink-underline {
  opacity: 1;
}

.tool-button {
  width: 46px;
  min-height: 42px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--color-text-dim);
  font-size: 0.72rem;
  font-weight: normal;
  letter-spacing: 0.05em;
  box-shadow: none;
  transition: color 0.2s, background-color 0.2s;
}

.tool-button > span {
  white-space: nowrap;
}

.tool-button .ink-underline {
  top: calc(100% + 1px);
}

.tool-button:hover,
.tool-button:focus-visible {
  color: var(--color-text);
  background: var(--color-bg-secondary);
  box-shadow: none;
  transform: none;
  outline: none;
}

.tool-button.is-recording {
  color: var(--color-failure);
  background: transparent;
}

.editor-tray {
  padding: var(--panel-padding);
  border-right: 1px dashed rgba(26, 26, 46, 0.1);
  background: var(--color-bg);
}

.tray-strip {
  min-height: 100%;
  gap: 16px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: var(--color-bg);
  box-shadow: none;
  backdrop-filter: none;
}

.tray-group {
  gap: 10px;
}

.tray-group + .tray-group {
  padding-top: 14px;
  border-top: 1px dashed rgba(26, 26, 46, 0.1);
}

.tray-group h2 {
  color: var(--color-text);
  font-size: 0.85rem;
  font-weight: normal;
  letter-spacing: 0.05em;
}

.field {
  color: var(--color-text-dim);
  font-size: 0.78rem;
}

.field input,
.field textarea,
.field select {
  border: 1px dashed rgba(26, 26, 46, 0.15);
  border-right-color: rgba(43, 94, 166, 0.2);
  border-bottom-color: rgba(43, 94, 166, 0.15);
  border-radius: 0;
  background: var(--color-bg);
  color: var(--color-text);
  box-shadow: none;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: rgba(43, 94, 166, 0.35);
  box-shadow: 0 2px 8px rgba(26, 26, 46, 0.06);
}

.upload-card,
.layout-picker button,
.cell-picker button,
.action-button {
  border: 1px dashed rgba(26, 26, 46, 0.15);
  border-right-color: rgba(43, 94, 166, 0.2);
  border-bottom-color: rgba(43, 94, 166, 0.15);
  border-radius: 0;
  background: var(--color-bg);
  color: var(--color-text);
  box-shadow: 0 1px 4px rgba(26, 26, 46, 0.04);
  transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.upload-card:hover,
.layout-picker button:hover,
.cell-picker button:hover,
.action-button:hover {
  border-color: rgba(26, 26, 46, 0.15);
  border-right-color: rgba(43, 94, 166, 0.2);
  border-bottom-color: rgba(43, 94, 166, 0.15);
  background: var(--color-bg);
  transform: translateY(-4px);
  box-shadow:
    0 4px 16px rgba(26, 26, 46, 0.08),
    0 1px 4px rgba(43, 94, 166, 0.04);
}

.layout-picker button[aria-checked="true"],
.cell-picker button[aria-selected="true"] {
  background: var(--color-bg-secondary);
  color: var(--color-text);
  border: 1px dashed rgba(26, 26, 46, 0.15);
  border-right-color: rgba(43, 94, 166, 0.2);
  border-bottom-color: rgba(43, 94, 166, 0.15);
  box-shadow: 0 1px 4px rgba(26, 26, 46, 0.04);
}

.layout-thumb i {
  border: 1px dashed currentColor;
  opacity: 0.72;
}

.action-button.primary {
  border: none;
  box-shadow: none;
  letter-spacing: 0.15em;
}

.action-button.primary:hover {
  background: transparent;
  box-shadow: none;
  transform: none;
}

.share-dialog {
  border: 2px dashed rgba(26, 26, 46, 0.15);
  border-right-color: rgba(43, 94, 166, 0.2);
  border-bottom-color: rgba(43, 94, 166, 0.15);
  border-radius: 0;
  background: transparent;
  color: var(--color-text);
}

.share-dialog::backdrop {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: none;
}

.share-card {
  background: var(--color-bg);
  box-shadow: 0 4px 20px rgba(26, 26, 46, 0.06);
}

.share-card h2 {
  color: var(--color-text);
  font-size: 1.1rem;
  letter-spacing: 0.05em;
}

.dialog-close {
  border: none;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: var(--color-text-muted);
  box-shadow: none;
  line-height: 1;
  display: grid;
  place-items: center;
}

.workspace {
  background: var(--color-bg);
}

.poster {
  border: none;
  background: var(--color-bg);
  box-shadow:
    0 2px 8px rgba(26, 26, 46, 0.08),
    0 8px 24px rgba(26, 26, 46, 0.06),
    0 1px 3px rgba(43, 94, 166, 0.04);
}

.poster::before {
  display: none;
}

.poster::after,
.performance-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  display: none;
  pointer-events: none;
  mix-blend-mode: multiply;
}

.performance-stage::after {
  z-index: 0;
}

.poster[data-paper-effect="halftone"]::after,
.performance-stage[data-paper-effect="halftone"]::after {
  display: block;
  opacity: .82;
  background-image:
    radial-gradient(circle, rgba(26, 26, 46, .16) 0 1.15px, transparent 1.35px),
    radial-gradient(circle, rgba(43, 94, 166, .1) 0 .8px, transparent 1px);
  background-size: 8px 8px, 16px 16px;
  background-position: 0 0, 4px 4px;
}

.poster[data-paper-effect="printGrain"]::after,
.performance-stage[data-paper-effect="printGrain"]::after {
  display: block;
  opacity: .68;
  background-image:
    radial-gradient(circle, rgba(26, 26, 46, .14) 0 .45px, transparent .75px),
    radial-gradient(circle, rgba(43, 94, 166, .1) 0 .4px, transparent .7px),
    radial-gradient(circle, rgba(26, 26, 46, .08) 0 .35px, transparent .65px);
  background-size: 7px 11px, 13px 9px, 17px 15px;
  background-position: 1px 2px, 6px 4px, 3px 9px;
}

html[data-theme="dark"] .poster[data-paper-effect="halftone"]::after,
html[data-theme="dark"] .performance-stage[data-paper-effect="halftone"]::after {
  background-image:
    radial-gradient(circle, rgba(236, 236, 242, .18) 0 1.15px, transparent 1.35px),
    radial-gradient(circle, rgba(120, 167, 232, .13) 0 .8px, transparent 1px);
}

html[data-theme="dark"] .poster[data-paper-effect="printGrain"]::after,
html[data-theme="dark"] .performance-stage[data-paper-effect="printGrain"]::after {
  background-image:
    radial-gradient(circle, rgba(236, 236, 242, .15) 0 .45px, transparent .75px),
    radial-gradient(circle, rgba(120, 167, 232, .11) 0 .4px, transparent .7px),
    radial-gradient(circle, rgba(236, 236, 242, .08) 0 .35px, transparent .65px);
}

.poster[data-paper-effect="fiber"]::after,
.performance-stage[data-paper-effect="fiber"]::after {
  display: block;
  opacity: 1;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='112' viewBox='0 0 150 112'%3E%3Cg fill='none' stroke-linecap='round'%3E%3Cpath d='M5 14c18-4 30 3 52-1' stroke='%231a1a2e' stroke-opacity='.22' stroke-width='.9'/%3E%3Cpath d='M74 9c14 3 27-2 43 1' stroke='%232b5ea6' stroke-opacity='.18' stroke-width='.8'/%3E%3Cpath d='M103 35c17 3 29-2 44 2' stroke='%231a1a2e' stroke-opacity='.2' stroke-width='.85'/%3E%3Cpath d='M12 57c15-3 29 4 45 0' stroke='%232b5ea6' stroke-opacity='.17' stroke-width='.8'/%3E%3Cpath d='M57 86c21-2 36 4 58-1' stroke='%231a1a2e' stroke-opacity='.21' stroke-width='.9'/%3E%3Cpath d='M111 73c9-4 21-2 35-5' stroke='%232b5ea6' stroke-opacity='.17' stroke-width='.8'/%3E%3Cpath d='M34 30c3 11-2 20 1 31' stroke='%231a1a2e' stroke-opacity='.16' stroke-width='.75'/%3E%3Cpath d='M91 51c-2 9 3 19 0 29' stroke='%232b5ea6' stroke-opacity='.15' stroke-width='.75'/%3E%3Cpath d='M8 101c25 2 39-3 66 0' stroke='%231a1a2e' stroke-opacity='.17' stroke-width='.8'/%3E%3C/g%3E%3C/svg%3E"),
    repeating-linear-gradient(2deg, transparent 0 22px, rgba(26, 26, 46, 0.035) 22px 23px, transparent 23px 44px);
  background-size: 150px 112px, 100% 100%;
}

.poster[data-paper-effect="wash"]::after,
.performance-stage[data-paper-effect="wash"]::after {
  display: block;
  opacity: 1;
  background:
    radial-gradient(ellipse at 2% 8%, rgba(26, 26, 46, 0.23), transparent 35%),
    radial-gradient(ellipse at 94% 88%, rgba(43, 94, 166, 0.21), transparent 39%),
    radial-gradient(ellipse at 78% 6%, rgba(26, 26, 46, 0.12), transparent 31%),
    radial-gradient(ellipse at 17% 98%, rgba(43, 94, 166, 0.1), transparent 27%);
}

.poster[data-paper-effect="dryBrush"]::after,
.performance-stage[data-paper-effect="dryBrush"]::after {
  display: block;
  opacity: 1;
  background-image:
    repeating-linear-gradient(3deg, transparent 0 7px, rgba(26, 26, 46, 0.17) 7px 9px, transparent 9px 17px),
    repeating-linear-gradient(-4deg, transparent 0 10px, rgba(43, 94, 166, 0.13) 10px 11px, transparent 11px 21px),
    linear-gradient(90deg, rgba(26, 26, 46, 0.19), transparent 31%),
    linear-gradient(270deg, rgba(43, 94, 166, 0.16), transparent 29%);
  background-size: 43% 18%, 37% 16%, 100% 100%, 100% 100%;
  background-position: 2% 82%, 97% 18%, 0 0, 0 0;
  background-repeat: no-repeat, no-repeat, no-repeat, no-repeat;
}

.poster[data-paper-effect="blueMarks"]::after,
.performance-stage[data-paper-effect="blueMarks"]::after {
  display: block;
  opacity: 1;
  background:
    linear-gradient(7deg, transparent 45%, rgba(43, 94, 166, 0.34) 46% 50%, transparent 52%) 86% 13% / 23% 7% no-repeat,
    linear-gradient(-4deg, transparent 44%, rgba(43, 94, 166, 0.3) 46% 50%, transparent 52%) 5% 76% / 27% 7% no-repeat,
    linear-gradient(3deg, transparent 45%, rgba(43, 94, 166, 0.23) 47% 49%, transparent 52%) 94% 56% / 17% 5% no-repeat,
    radial-gradient(circle at 91% 15%, rgba(43, 94, 166, 0.32) 0 2px, transparent 2.8px),
    radial-gradient(circle at 9% 79%, rgba(43, 94, 166, 0.28) 0 2px, transparent 2.8px),
    radial-gradient(circle at 96% 58%, rgba(43, 94, 166, 0.22) 0 1.6px, transparent 2.4px);
}

.poster[data-paper-effect="crease"]::after,
.performance-stage[data-paper-effect="crease"]::after {
  display: block;
  opacity: 1;
  background:
    linear-gradient(92deg, transparent 34.6%, rgba(26, 26, 46, 0.18) 35%, rgba(255, 255, 255, 0.8) 35.35%, rgba(43, 94, 166, 0.11) 35.7%, transparent 36.2%),
    linear-gradient(178deg, transparent 67.5%, rgba(43, 94, 166, 0.14) 68%, rgba(255, 255, 255, 0.78) 68.35%, rgba(26, 26, 46, 0.13) 68.7%, transparent 69.2%);
}

.poster[data-paper-effect="letterpress"]::after,
.performance-stage[data-paper-effect="letterpress"]::after {
  display: block;
  opacity: 1;
  background:
    repeating-linear-gradient(0deg, transparent 0 28px, rgba(26, 26, 46, 0.09) 28px 29px),
    repeating-linear-gradient(90deg, transparent 0 34px, rgba(43, 94, 166, 0.075) 34px 35px);
}

.poster[data-paper-effect="letterpress"] .poster-title,
.poster[data-paper-effect="letterpress"] .cell-title,
.performance-stage[data-paper-effect="letterpress"] .performance-title,
.performance-stage[data-paper-effect="letterpress"] .cell-title {
  text-shadow: 1.5px 1px 0 rgba(43, 94, 166, 0.48);
}

.poster[data-paper-effect="watermark"]::after,
.performance-stage[data-paper-effect="watermark"]::after {
  content: "EX LIBRIS  ·  XC";
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0 5% 4%;
  color: rgba(43, 94, 166, 0.18);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 5.8cqw, 58px);
  letter-spacing: 0.18em;
}

.poster[data-paper-effect="deckle"]::after,
.performance-stage[data-paper-effect="deckle"]::after {
  display: block;
  opacity: 1;
  box-shadow:
    inset 12px 0 14px -9px rgba(26, 26, 46, 0.48),
    inset -13px 0 15px -10px rgba(43, 94, 166, 0.44),
    inset 0 13px 15px -10px rgba(26, 26, 46, 0.4),
    inset 0 -13px 15px -10px rgba(43, 94, 166, 0.38);
  background:
    repeating-linear-gradient(90deg, rgba(26, 26, 46, 0.16) 0 2px, transparent 2px 10px) top / 100% 6px no-repeat,
    repeating-linear-gradient(87deg, rgba(43, 94, 166, 0.14) 0 2px, transparent 2px 12px) bottom / 100% 6px no-repeat,
    repeating-linear-gradient(0deg, rgba(26, 26, 46, 0.12) 0 2px, transparent 2px 11px) left / 6px 100% no-repeat,
    repeating-linear-gradient(2deg, rgba(43, 94, 166, 0.12) 0 2px, transparent 2px 13px) right / 6px 100% no-repeat;
}

.poster-kicker {
  color: var(--color-text-muted);
}

.poster-title {
  font-family: var(--font-heading);
  font-weight: normal;
  letter-spacing: 0.15em;
  text-shadow: none;
}

.poster-title[contenteditable],
.cell-title[contenteditable] {
  border-radius: 0;
}

.poster-title[contenteditable]:focus,
.cell-title[contenteditable]:focus {
  background-color: var(--color-bg-secondary);
  box-shadow: 0 0 0 1px rgba(26, 26, 46, 0.12);
}

.story-cell.is-active .image-frame {
  outline: none;
  box-shadow:
    0 4px 16px rgba(26, 26, 46, 0.08),
    0 1px 4px rgba(43, 94, 166, 0.04);
}

.image-frame {
  border: 1px dashed rgba(26, 26, 46, 0.15);
  border-right-color: rgba(43, 94, 166, 0.2);
  border-bottom-color: rgba(43, 94, 166, 0.15);
  background: var(--color-bg);
  box-shadow: 0 1px 4px rgba(26, 26, 46, 0.04);
}

.cell-title {
  color: var(--color-text);
  font-family: var(--font-heading);
  font-weight: normal;
  letter-spacing: 0.05em;
  text-shadow: none;
  background: var(--ink-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.performance-stage {
  background: var(--color-bg);
}

.performance-stage::before {
  display: none;
}

.performance-title {
  font-family: var(--font-heading);
  font-weight: normal;
  letter-spacing: 0.15em;
  text-shadow: none;
}

.performance-filler {
  color: var(--color-text-muted);
}

.performance-edit-button,
.performance-next {
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--color-text);
}

.performance-next {
  background: var(--color-bg);
  border: 1px dashed rgba(26, 26, 46, 0.15);
  border-right-color: rgba(43, 94, 166, 0.2);
  border-bottom-color: rgba(43, 94, 166, 0.15);
  box-shadow: 0 1px 4px rgba(26, 26, 46, 0.04);
}

.performance-actions {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 4;
  display: flex;
  align-items: flex-start;
  gap: 20px;
}

.performance-actions .performance-edit-button {
  position: relative;
  top: auto;
  right: auto;
  color: var(--color-text-muted);
}

.performance-actions .performance-edit-button:hover,
.performance-actions .performance-edit-button:focus-visible {
  color: var(--color-text);
}

.performance-mode-indicator {
  pointer-events: none;
}

.performance-action-button {
  width: 46px;
  min-height: 42px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  padding: 0;
  color: var(--color-text-dim);
  font-size: 0.72rem;
  line-height: 1.2;
}

.performance-action-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.performance-action-button > span {
  white-space: nowrap;
}

.performance-action-button:hover,
.performance-action-button:focus-visible,
.performance-action-button.is-recording {
  color: var(--color-text);
  outline: none;
}

.performance-action-button.is-recording {
  color: var(--color-failure);
}

.performance-action-button .ink-underline {
  top: calc(100% + 1px);
}

.share-dialog textarea {
  color: var(--color-text);
  -webkit-text-fill-color: var(--color-text) !important;
  caret-color: var(--color-text);
  opacity: 1;
}

.share-dialog h2 {
  width: fit-content;
  max-width: 100%;
  background: var(--ink-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.share-hint-text {
  background: var(--ink-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.share-dialog .action-button.primary {
  background: transparent;
  background-clip: border-box;
  -webkit-background-clip: border-box;
  -webkit-text-fill-color: var(--color-text);
  color: var(--color-text);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #101117;
  --color-bg-secondary: #181b24;
  --color-bg-panel: #14161e;
  --color-ink-black: #ececf2;
  --color-ink-blue: #78a7e8;
  --color-border-black: #ececf2;
  --color-border-blue: #78a7e8;
  --color-text: #ececf2;
  --color-text-dim: #c4c5ce;
  --color-text-muted: #9095a5;
  --color-success: #73b784;
  --color-failure: #d68484;
  --ink-gradient: linear-gradient(to right, #ececf2 0%, #ececf2 66%, #78a7e8 100%);
  --line: rgba(236, 236, 242, 0.2);
  --line-strong: rgba(120, 167, 232, 0.34);
  --pink: #241d25;
  --violet: #aaaacf;
  --border-etched: 1px dashed rgba(236, 236, 242, 0.22);
  --border-etched-blue: rgba(120, 167, 232, 0.34);
  --shadow-soft:
    0 2px 8px rgba(0, 0, 0, 0.32),
    0 8px 24px rgba(0, 0, 0, 0.24),
    0 1px 3px rgba(120, 167, 232, 0.1);
  --shadow-light: 0 1px 5px rgba(0, 0, 0, 0.28);
  --paper-noise:
    radial-gradient(circle at 16% 18%, rgba(236, 236, 242, 0.035) 0 .35px, transparent .8px),
    radial-gradient(circle at 78% 34%, rgba(120, 167, 232, 0.03) 0 .38px, transparent .85px);
}

html[data-theme="dark"] .editor-toolbar,
html[data-theme="dark"] .editor-tray,
html[data-theme="dark"] .tray-strip,
html[data-theme="dark"] .workspace,
html[data-theme="dark"] .poster,
html[data-theme="dark"] .performance-stage,
html[data-theme="dark"] .share-card,
html[data-theme="dark"] .usage-card,
html[data-theme="dark"] .field input,
html[data-theme="dark"] .field textarea,
html[data-theme="dark"] .field select,
html[data-theme="dark"] .upload-card,
html[data-theme="dark"] .layout-picker button,
html[data-theme="dark"] .cell-picker button,
html[data-theme="dark"] .action-button,
html[data-theme="dark"] .performance-next {
  background-color: var(--color-bg);
}

html[data-theme="dark"] .editor-toolbar,
html[data-theme="dark"] .editor-tray,
html[data-theme="dark"] .tray-group + .tray-group,
html[data-theme="dark"] .field input,
html[data-theme="dark"] .field textarea,
html[data-theme="dark"] .field select,
html[data-theme="dark"] .upload-card,
html[data-theme="dark"] .layout-picker button,
html[data-theme="dark"] .cell-picker button,
html[data-theme="dark"] .action-button,
html[data-theme="dark"] .performance-next,
html[data-theme="dark"] .share-dialog {
  border-color: rgba(236, 236, 242, 0.22);
  border-right-color: rgba(120, 167, 232, 0.34);
  border-bottom-color: rgba(120, 167, 232, 0.28);
}

html[data-theme="dark"] .share-dialog::backdrop {
  background: rgba(7, 8, 12, 0.86);
}

html[data-theme="dark"] .usage-dialog::backdrop {
  background: rgba(7, 8, 12, 0.86);
}

html[data-theme="dark"] .cell-picker button[aria-selected="true"] {
  border-color: rgba(120, 167, 232, 0.86);
  background: rgba(120, 167, 232, 0.18);
  color: #fff;
  font-weight: 700;
  box-shadow:
    inset 0 -3px 0 rgba(120, 167, 232, 0.5),
    0 0 0 1px rgba(236, 236, 242, 0.08);
}

html[data-theme="dark"] .poster::after,
html[data-theme="dark"] .performance-stage::after {
  mix-blend-mode: screen;
}

html[data-theme="dark"] .template-fade .image-frame {
  background: #fff;
}

.editor-toolbar {
  grid-template-columns: auto auto minmax(0, 1fr) auto;
}

.theme-toggle-button {
  width: 32px;
  height: 43px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--color-text-dim);
  border: 0;
  background: transparent;
}

.theme-toggle-button:hover,
.theme-toggle-button:focus-visible {
  color: var(--color-text);
  outline: 1px dashed var(--line-strong);
  outline-offset: 2px;
}

.theme-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-icon-sun,
html[data-theme="dark"] .theme-icon-moon {
  display: none;
}

html[data-theme="dark"] .theme-icon-sun {
  display: block;
}

.editor-theme-toggle {
  align-self: start;
  justify-self: end;
}

.performance-theme-toggle {
  width: 34px;
  min-width: 34px;
  height: 42px;
}

.performance-action-button .ink-underline {
  position: absolute;
  top: calc(100% + 1px);
  opacity: 0;
  transition: opacity 0.2s;
}

.performance-action-button.is-selected .ink-underline,
.performance-action-button.is-recording .ink-underline {
  opacity: 1;
}

.performance-cell {
  grid-template-rows: auto auto auto;
}

.performance-cell .image-frame {
  border: 0;
  outline: 0;
  background: transparent;
  box-shadow: none;
}

.performance-cell.template-fade .image-frame {
  background: #000;
}

.performance-cell.template-wireTerminal .image-frame {
  background: #001e9a;
}

html[data-theme="dark"] .performance-cell.template-fade .image-frame {
  background: #fff;
}

.performance-cell .cell-title {
  margin-top: clamp(34px, 4.8vmin, 58px);
}

.performance-cell.template-torn .cell-title {
  margin-top: clamp(82px, 10vmin, 116px);
}

.poster[data-cell-count="1"] .cell-grid {
  left: 9%;
  right: 9%;
  top: 15.5%;
  bottom: 12%;
}

.poster[data-cell-count="1"] .image-frame {
  width: min(74%, clamp(180px, 46cqw, 430px));
  aspect-ratio: 4 / 5;
}

.poster[data-cell-count="1"] .cell-title {
  margin-top: clamp(14px, 2cqw, 20px);
}

.poster[data-cell-count="2"] .cell-grid {
  left: 3.5%;
  right: 3.5%;
  top: 18.5%;
  bottom: 14%;
  column-gap: 1.5%;
}

.poster[data-cell-count="2"] .image-frame {
  width: min(94%, clamp(140px, 38cqw, 360px));
  aspect-ratio: 4 / 5;
}

.poster[data-cell-count="2"] .cell-title {
  margin-top: clamp(12px, 1.7cqw, 18px);
}

.poster[data-cell-count="9"] .cell-grid {
  top: 17.5%;
  bottom: 15%;
  row-gap: 4.6%;
}

.performance-interaction-hint {
  margin-top: 12px;
  color: var(--color-text-muted);
  font-size: clamp(12px, 1.35vw, 16px);
  line-height: 1.4;
}

.performance-summary {
  width: min(76vmin, 760px);
  max-width: 100%;
  display: grid;
  gap: clamp(18px, 3vmin, 30px);
}

.performance-summary > h2 {
  margin: 0;
  color: var(--color-text);
  text-align: center;
  font-family: var(--font-heading);
  font-size: clamp(25px, 4.2vmin, 42px);
  font-weight: normal;
  letter-spacing: 0.1em;
  background: var(--ink-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.performance-summary-grid {
  display: grid;
  grid-template-columns: repeat(var(--summary-cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--summary-rows), minmax(0, 1fr));
  gap: clamp(14px, 2.4vmin, 26px);
}

.performance-summary-item {
  min-width: 0;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 8px;
  text-align: center;
}

.performance-summary-image {
  width: min(15vmin, 132px);
  aspect-ratio: 1;
  overflow: hidden;
}

.performance-summary-image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.story-cell .image-frame.is-placeholder,
.performance-summary-image.is-placeholder {
  background: #f3efe4;
  border: 1px dashed rgba(26, 26, 46, 0.15);
  box-shadow: none;
}

html[data-theme="dark"] .story-cell .image-frame.is-placeholder,
html[data-theme="dark"] .performance-summary-image.is-placeholder {
  background: #fff;
}

.performance-cell .image-frame.is-placeholder {
  border: 0;
}

.performance-summary-image.is-placeholder {
  border: 0;
}

.performance-summary-text {
  max-width: 100%;
  color: var(--color-text);
  font-family: var(--font-heading);
  font-size: clamp(11px, 1.45vmin, 16px);
  line-height: 1.2;
  overflow-wrap: anywhere;
  background: var(--ink-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.performance-summary-credit {
  justify-self: end;
  text-align: right;
  font-family: var(--font-heading);
  font-size: clamp(11px, 1.35vmin, 15px);
  line-height: 1.55;
  min-height: 3.1em;
}

.performance-summary-credit.is-empty {
  visibility: hidden;
}

.performance-stage.is-complete {
  background: var(--color-bg);
}

html[data-theme="dark"] .performance-stage.is-complete {
  background: var(--color-bg);
}

.performance-stage.is-complete::after {
  display: none !important;
}

.performance-stage.is-complete .performance-complete-overlay {
  background: rgba(255, 255, 255, 0.18);
}

html[data-theme="dark"] .performance-stage.is-complete .performance-complete-overlay {
  background: rgba(0, 0, 0, 0.18);
}

.performance-complete-overlay {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(255, 255, 255, 0.58);
}

.performance-complete-card {
  width: min(100%, 360px);
  padding: 30px 28px 26px;
  border: 1px dashed var(--line);
  border-right-color: var(--line-strong);
  border-bottom-color: var(--line-strong);
  background: var(--color-bg);
  color: var(--color-text);
  box-shadow: var(--shadow-soft);
}

.credit-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.credit-fields .field {
  min-width: 0;
}

.credit-fields input {
  width: 100%;
}

.poster-kicker {
  bottom: 1.8%;
  display: grid;
  grid-template-rows: repeat(2, 1.5em);
  min-height: 3em;
  color: var(--color-text-muted);
  font-family: var(--font-heading);
  font-weight: normal;
  line-height: 1.5;
}

.credit-line {
  min-height: 1.5em;
  white-space: nowrap;
}

.credit-line.is-empty {
  visibility: hidden;
}

.credit-label {
  color: var(--color-text-muted);
}

.credit-name {
  color: var(--color-text);
  background: var(--ink-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.performance-complete-card h2 {
  margin: 0 0 22px;
  text-align: center;
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: normal;
  letter-spacing: 0.1em;
}

.performance-complete-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.performance-complete-actions .action-button {
  min-height: 44px;
  padding: 8px 12px;
}

.performance-cell .cell-title {
  min-height: 2.4em;
  min-height: 2lh;
  display: grid;
  align-items: start;
}

.performance-next {
  position: relative;
  inset: auto;
  width: 34px;
  min-width: 34px;
  height: 28px;
  min-height: 28px;
  margin-top: clamp(12px, 2vmin, 20px);
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  color: var(--color-text-muted);
  cursor: pointer;
}

.performance-next::before {
  content: "";
  display: block;
  width: 0;
  height: 0;
  margin: auto;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid currentColor;
}

.performance-next:hover,
.performance-next:focus-visible {
  background: transparent;
  color: var(--color-text);
  box-shadow: none;
  transform: translateY(2px);
  outline: none;
  filter: drop-shadow(0 2px 2px rgba(43, 94, 166, 0.24));
}

html[data-theme="dark"] .performance-next {
  background: transparent;
}

.performance-complete-actions [data-performance-replay] {
  background: transparent;
  background-clip: border-box;
  -webkit-background-clip: border-box;
  color: var(--color-text);
  -webkit-text-fill-color: var(--color-text);
}

@media (max-width: 700px) {
  body {
    overflow: auto;
  }

  .editor-toolbar {
    border-bottom: 1px dashed rgba(26, 26, 46, 0.1);
    position: relative;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .editor-theme-toggle {
    position: absolute;
    top: 14px;
    right: 10px;
  }

  .mode-tabs {
    padding-right: 36px;
  }

  .toolbar-brand h1 {
    font-size: 1.2rem;
    letter-spacing: 0.15em;
  }

  .editor-tray {
    border-top: 1px dashed rgba(26, 26, 46, 0.1);
    border-right: none;
    background: var(--color-bg);
  }

  .usage-card {
    padding: 24px 20px 26px;
  }

  .usage-copy {
    font-size: 12px;
    line-height: 1.7;
  }

  .tray-strip {
    width: min(100%, 350px);
    max-width: 350px;
    border: none;
    background: var(--color-bg);
    box-shadow: none;
  }

  .cell-tool-list {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 10px;
  }

  .cell-tool-list .upload-card,
  .cell-tool-list .field select {
    width: 100%;
    min-height: 44px;
  }

  .cell-tool-list .field {
    gap: 6px;
    margin-top: 0;
  }

  .performance-actions {
    top: calc(12px + env(safe-area-inset-top));
    right: 14px;
    gap: 8px;
  }

  .performance-cell .cell-title {
    margin-top: 34px;
  }

  .performance-cell.template-torn .cell-title {
    margin-top: 78px;
  }

  .performance-summary {
    width: min(100%, 540px);
    gap: 18px;
  }

  .performance-summary-grid {
    gap: 12px 10px;
  }

  .performance-summary-image {
    width: min(24vw, 105px);
  }

  .performance-summary-text {
    font-size: clamp(10px, 2.8vw, 13px);
  }

  .performance-complete-card {
    width: min(100%, 330px);
  }
}
