/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --paper: #f3eee4;
  --paper-deep: #e9e1d3;
  --panel: rgba(255, 253, 247, 0.84);
  --panel-solid: #fcfaf5;
  --ink: #292720;
  --ink-soft: #706a5e;
  --ink-muted: #918978;
  --ink-faint: #b3aa98;
  --line: rgba(65, 55, 40, 0.12);
  --line-strong: rgba(65, 55, 40, 0.2);
  --accent: #b14634;
  --accent-deep: #8f3325;
  --accent-wash: rgba(177, 70, 52, 0.075);
  --moss: #6c7b67;
  --white: #fffdf8;
  --serif: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
  --sans: "Aptos", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", "Cascadia Mono", "Consolas", "Liberation Mono", monospace;
  --radius: 21px;
  --shadow: 0 24px 60px rgba(62, 49, 32, 0.08), 0 2px 7px rgba(62, 49, 32, 0.04);
  --cell-width: 32px;
  --cell-height: 38px;
  --cell-gap: 4px;
  --cell-font-size: 16px;
  --rhyme-space: 18px;
}

/* ── Reset ──────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(1100px 700px at 9% -8%, rgba(177, 70, 52, 0.085), transparent 55%),
    radial-gradient(900px 620px at 96% 13%, rgba(108, 123, 103, 0.09), transparent 58%),
    linear-gradient(146deg, #f7f3eb 0%, #f2ece1 48%, #ede5d7 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.36;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.10'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

button,
textarea,
input {
  font: inherit;
}

button {
  color: inherit;
}

button,
[tabindex] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
textarea:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid rgba(177, 70, 52, 0.58);
  outline-offset: 2px;
}

::selection {
  color: var(--ink);
  background: rgba(177, 70, 52, 0.18);
}

.ambient {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  border-radius: 999px;
  filter: blur(4px);
}

.ambient-a {
  width: 430px;
  height: 430px;
  left: -250px;
  bottom: -240px;
  border: 1px solid rgba(177, 70, 52, 0.13);
  box-shadow: inset 0 0 0 22px rgba(177, 70, 52, 0.018), inset 0 0 0 23px rgba(177, 70, 52, 0.08);
}

.ambient-b {
  width: 300px;
  height: 300px;
  right: -150px;
  top: 25%;
  border: 1px solid rgba(108, 123, 103, 0.16);
  box-shadow: inset 0 0 0 34px rgba(108, 123, 103, 0.02), inset 0 0 0 35px rgba(108, 123, 103, 0.09);
}

/* ── Shell ──────────────────────────────────────────────── */
.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(100%, 1880px);
  height: 100dvh;
  margin: 0 auto;
  padding: 22px 26px 10px;
}

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 66px;
  padding: 0 2px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
}

.brand-seal {
  position: relative;
  display: grid;
  width: 49px;
  height: 49px;
  place-items: center;
  border-radius: 14px 14px 14px 6px;
  color: #f8f1e6;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.1), transparent 45%),
    linear-gradient(145deg, #3a372e, #22211c);
  box-shadow: 0 9px 20px rgba(48, 41, 31, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  transform: rotate(-2deg);
}

.brand-seal span {
  position: relative;
  z-index: 1;
  font-family: var(--serif);
  font-size: 25px;
  line-height: 1;
  transform: translateY(-1px);
}

.brand-seal i {
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 9px 9px 9px 3px;
}

.brand-seal::after {
  content: "";
  position: absolute;
  right: 8px;
  bottom: 7px;
  width: 5px;
  height: 5px;
  border-radius: 1px;
  background: var(--accent);
}

.brand-copy {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  column-gap: 10px;
}

.brand-kicker {
  grid-column: 1 / -1;
  margin: 0 0 1px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.3em;
}

.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 700;
  letter-spacing: 0.09em;
  line-height: 1.25;
}

.brand-motto {
  margin: 0;
  color: var(--ink-muted);
  font-family: var(--serif);
  font-size: 10px;
  letter-spacing: 0.14em;
}

.topbar-rule {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(350px, 30vw);
  margin-left: 8px;
  color: var(--ink-faint);
}

.topbar-rule span {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-strong));
}

.topbar-rule span:last-child {
  background: linear-gradient(90deg, var(--line-strong), transparent);
}

.topbar-rule i {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-family: var(--serif);
  font-size: 10px;
  font-style: normal;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-left: auto;
}

.topbar-tip {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: var(--ink-muted);
  font-size: 10px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.live-dot {
  position: relative;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--moss);
}

.live-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border: 1px solid rgba(108, 123, 103, 0.35);
  border-radius: 50%;
  animation: breathe 2.6s ease-out infinite;
}

/* ── Workspace and panels ───────────────────────────────── */
.workspace {
  display: grid;
  grid-template-columns: minmax(210px, 0.64fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
}

.workspace.is-source-collapsed {
  grid-template-columns: 44px minmax(0, 1fr) minmax(0, 1fr);
}

.workspace.is-source-collapsed .panel-source {
  display: none;
}

.source-head-tools {
  display: flex;
  align-items: center;
  gap: 3px;
}

.source-collapse-button {
  width: 26px;
  height: 26px;
}

.source-collapse-button svg {
  width: 14px;
  height: 14px;
}

.source-rail {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 11px;
  min-width: 0;
  min-height: 0;
  padding: 16px 0;
  border: 1px solid rgba(65, 55, 40, 0.115);
  border-radius: var(--radius);
  color: var(--ink-soft);
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.88), rgba(248, 244, 235, 0.78));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.workspace.is-source-collapsed .source-rail {
  display: flex;
}

.source-rail svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.source-rail-label {
  color: var(--ink);
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.16em;
  line-height: 1;
  writing-mode: vertical-rl;
}

.source-rail-note {
  color: var(--ink-faint);
  font-size: 8px;
  letter-spacing: 0.14em;
  line-height: 1;
  writing-mode: vertical-rl;
}

.source-rail:hover {
  color: var(--accent-deep);
  border-color: rgba(177, 70, 52, 0.24);
  background: linear-gradient(180deg, rgba(255, 253, 247, 0.96), rgba(248, 244, 235, 0.86));
}

.source-rail:focus-visible {
  outline: 2px solid rgba(177, 70, 52, 0.42);
  outline-offset: -4px;
}

.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(65, 55, 40, 0.115);
  border-radius: var(--radius);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.52), transparent 42%),
    linear-gradient(180deg, rgba(255, 253, 247, 0.9), rgba(248, 244, 235, 0.8));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  animation: panel-in 620ms cubic-bezier(0.22, 0.82, 0.25, 1) both;
}

.panel-preview {
  animation-delay: 55ms;
}

.panel-fill {
  animation-delay: 110ms;
}

.panel::after {
  content: "";
  position: absolute;
  top: 0;
  left: 22px;
  right: 22px;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.9), transparent);
}

.panel-fill::before {
  content: "";
  position: absolute;
  z-index: 2;
  top: 0;
  left: 50%;
  width: 56px;
  height: 2px;
  border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  transform: translateX(-50%);
  opacity: 0.7;
  pointer-events: none;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 72px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 253, 247, 0.34), transparent);
}

.panel-heading {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.panel-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 27px;
  height: 27px;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink-muted);
  background: rgba(255, 253, 248, 0.35);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.panel-fill .panel-index {
  color: var(--accent-deep);
  border-color: rgba(177, 70, 52, 0.24);
  background: var(--accent-wash);
}

.panel-kicker {
  margin: 0 0 3px;
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.22em;
}

.panel-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.1;
}

.panel-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--ink-muted);
  font-size: 10px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.panel-stat strong {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
}

.panel-stat i {
  width: 1px;
  height: 9px;
  background: var(--line-strong);
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 23px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-muted);
  background: rgba(255, 253, 248, 0.36);
  font-size: 9px;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.mode-editable {
  color: var(--accent-deep);
  border-color: rgba(177, 70, 52, 0.18);
  background: rgba(177, 70, 52, 0.055);
}

.mode-editable span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

.fill-head-tools {
  display: flex;
  align-items: center;
  gap: 7px;
}

.add-cell-button {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 29px;
  padding: 0 8px;
  border: 1px solid rgba(108, 123, 103, 0.22);
  border-radius: 8px;
  color: var(--moss);
  background: rgba(108, 123, 103, 0.055);
  font-size: 9px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.add-cell-button span:first-child {
  font-size: 13px;
  line-height: 1;
  transform: translateY(-0.5px);
}

.add-cell-button:hover:not(:disabled) {
  color: #526550;
  border-color: rgba(108, 123, 103, 0.45);
  background: rgba(108, 123, 103, 0.11);
}

.add-cell-button:disabled {
  opacity: 0.35;
  cursor: default;
}

.add-cell-button.is-active {
  color: var(--white);
  border-color: var(--accent);
  background: var(--accent);
}

.add-cell-button.is-active:hover:not(:disabled) {
  color: var(--white);
  border-color: var(--accent-deep);
  background: var(--accent-deep);
}

.delete-cell-button {
  color: var(--accent-deep);
  border-color: rgba(177, 70, 52, 0.24);
  background: rgba(177, 70, 52, 0.05);
}

.delete-cell-button:hover:not(:disabled) {
  color: var(--accent-deep);
  border-color: rgba(177, 70, 52, 0.46);
  background: rgba(177, 70, 52, 0.11);
}

.delete-cell-button.is-active {
  color: var(--white);
  border-color: var(--accent);
  background: var(--accent);
}

.delete-cell-button.is-active:hover:not(:disabled) {
  color: var(--white);
  border-color: var(--accent-deep);
  background: var(--accent-deep);
}

.panel-fill.is-adding {
  border-color: rgba(177, 70, 52, 0.26);
  box-shadow:
    0 0 0 2px rgba(177, 70, 52, 0.055),
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.panel-fill.is-deleting {
  border-color: rgba(177, 70, 52, 0.3);
  box-shadow:
    0 0 0 2px rgba(177, 70, 52, 0.06),
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.panel-fill.is-adding .scroll-shell::after,
.panel-fill.is-deleting .scroll-shell::after {
  position: absolute;
  z-index: 8;
  top: 9px;
  left: 50%;
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  color: var(--white);
  background: rgba(41, 39, 32, 0.84);
  box-shadow: 0 5px 14px rgba(62, 49, 32, 0.14);
  font-size: 9px;
  letter-spacing: 0.04em;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  transform: translateX(-50%);
}

.panel-fill.is-adding .scroll-shell::after {
  content: "点击格子之间的 + 插入新格";
}

.panel-fill.is-deleting .scroll-shell::after {
  content: "点击要删除的格子";
}

.panel-fill.is-adding .editor-cell input,
.panel-fill.is-deleting .editor-cell input {
  pointer-events: none;
}

.panel-fill.is-adding .editor-cell,
.panel-fill.is-deleting .editor-cell {
  cursor: default;
}

.delete-handle {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: none;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
  cursor: pointer;
}

.delete-handle::after {
  content: "−";
  position: absolute;
  top: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  border: 1px solid rgba(177, 70, 52, 0.4);
  border-radius: 50%;
  color: var(--accent);
  background: var(--panel-solid);
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 700;
  line-height: 8px;
  text-align: center;
  opacity: 0.75;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.delete-handle:hover {
  background: rgba(177, 70, 52, 0.075);
}

.delete-handle:hover::after,
.delete-handle:focus-visible::after {
  color: var(--white);
  border-color: var(--accent);
  background: var(--accent);
  opacity: 1;
  transform: scale(1.12);
}

.delete-handle:focus-visible {
  outline: 2px solid rgba(177, 70, 52, 0.42);
  outline-offset: -2px;
  border-radius: 7px;
}

.panel-fill.is-deleting .delete-handle {
  display: block;
}

.insert-handle {
  position: absolute;
  z-index: 7;
  top: 1px;
  bottom: 1px;
  left: -10px;
  display: none;
  width: 20px;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  cursor: pointer;
}

.insert-handle::before {
  content: "";
  position: absolute;
  top: 1px;
  bottom: 1px;
  left: 50%;
  border-left: 1px dashed rgba(177, 70, 52, 0.3);
}

.insert-handle::after {
  content: "+";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  border: 1px solid rgba(177, 70, 52, 0.45);
  border-radius: 50%;
  color: var(--accent);
  background: var(--panel-solid);
  box-shadow: 0 1px 2px rgba(62, 49, 32, 0.1);
  font-family: var(--sans);
  font-size: 8px;
  font-weight: 700;
  line-height: 8px;
  text-align: center;
  opacity: 0.82;
  transform: translate(-50%, -50%);
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.insert-handle.is-end {
  left: auto;
  right: -10px;
}

.insert-handle:hover::after,
.insert-handle:focus-visible::after {
  color: var(--white);
  border-color: var(--accent);
  background: var(--accent);
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.18);
}

.panel-fill.is-adding .lyric-row:hover {
  background: rgba(177, 70, 52, 0.06);
}

.insert-handle:focus-visible {
  outline: 2px solid rgba(177, 70, 52, 0.42);
  outline-offset: 2px;
  border-radius: 4px;
}

.panel-fill.is-adding .insert-handle {
  display: block;
}

.icon-button {
  display: grid;
  width: 29px;
  height: 29px;
  padding: 0;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--ink-muted);
  background: transparent;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.icon-button:not(:disabled) {
  color: var(--ink-soft);
}

.icon-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.icon-button:hover:not(:disabled) {
  color: var(--accent-deep);
  border-color: rgba(177, 70, 52, 0.16);
  background: var(--accent-wash);
}

.icon-button:disabled {
  opacity: 0.32;
  cursor: default;
}

.icon-button.is-confirming {
  color: var(--accent-deep);
  border-color: rgba(177, 70, 52, 0.26);
  background: rgba(177, 70, 52, 0.1);
  animation: confirm-pulse 1.4s ease-in-out infinite;
}

.reset-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 29px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--ink-muted);
  background: transparent;
  font-size: 9px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.reset-button:hover:not(:disabled) {
  color: var(--accent-deep);
  border-color: rgba(177, 70, 52, 0.18);
  background: var(--accent-wash);
}

.reset-button:disabled {
  opacity: 0.32;
  cursor: default;
}

.reset-button.is-confirming {
  color: var(--accent-deep);
  border-color: rgba(177, 70, 52, 0.26);
  background: rgba(177, 70, 52, 0.08);
  font-weight: 600;
}

/* ── Source column ──────────────────────────────────────── */
.source-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  padding: 13px 15px 11px;
}

.source-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 2px 6px;
  padding: 0 4px 8px;
  color: var(--ink-soft);
  font-size: 9.5px;
  letter-spacing: 0.04em;
}

.source-caption-hint {
  color: var(--ink-faint);
  font-size: 8.5px;
}

.textarea-wrap {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(65, 55, 40, 0.11);
  border-radius: 13px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.45), rgba(255, 253, 247, 0.16)),
    repeating-linear-gradient(180deg, transparent 0, transparent 26px, rgba(74, 63, 47, 0.048) 26px, rgba(74, 63, 47, 0.048) 27px);
  box-shadow: inset 0 1px 2px rgba(62, 49, 32, 0.025);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.textarea-wrap:focus-within {
  border-color: rgba(177, 70, 52, 0.3);
  box-shadow: inset 0 1px 2px rgba(62, 49, 32, 0.025), 0 0 0 3px rgba(177, 70, 52, 0.055);
}

#lyricsInput {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 8px 30px 16px 48px;
  border: 0;
  outline: none;
  color: var(--ink-soft);
  background: transparent;
  font-family: var(--serif);
  font-size: 14.5px;
  font-weight: 400;
  line-height: 27px;
  letter-spacing: 0.02em;
  white-space: pre;
  resize: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(65, 55, 40, 0.18) transparent;
}

#lyricsInput::placeholder {
  color: var(--ink-faint);
  opacity: 0.82;
  font-size: 12px;
  letter-spacing: 0.01em;
}

#lyricsInput::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

#lyricsInput::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: rgba(65, 55, 40, 0.16);
}

.source-line-numbers {
  position: absolute;
  z-index: 2;
  top: 0;
  bottom: 0;
  left: 0;
  width: 40px;
  overflow: hidden;
  border-right: 1px solid rgba(65, 55, 40, 0.07);
  border-radius: 12px 0 0 12px;
  background:
    linear-gradient(90deg, #faf6ee, #f7f2e8),
    repeating-linear-gradient(180deg, transparent 0, transparent 26px, rgba(74, 63, 47, 0.035) 26px, rgba(74, 63, 47, 0.035) 27px);
  box-shadow: 4px 0 10px rgba(62, 49, 32, 0.025);
  pointer-events: none;
}

.source-line-number-list {
  padding-top: 8px;
  will-change: transform;
}

.source-line-number {
  height: 27px;
  padding-right: 7px;
  color: rgba(112, 106, 94, 0.66);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 500;
  line-height: 27px;
  text-align: right;
  user-select: none;
}

.source-line-number.is-current {
  color: var(--accent);
}

.editor-mark {
  position: absolute;
  top: 19px;
  right: 11px;
  bottom: 19px;
  display: flex;
  width: 11px;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.editor-mark span {
  width: 1px;
  flex: 1;
  background: linear-gradient(180deg, transparent, rgba(177, 70, 52, 0.18) 20%, rgba(177, 70, 52, 0.18) 80%, transparent);
}

.editor-mark small {
  color: rgba(177, 70, 52, 0.52);
  font-family: var(--serif);
  font-size: 9px;
  letter-spacing: 0.16em;
  writing-mode: vertical-rl;
}

.source-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  gap: 10px;
  padding: 11px 3px 0;
}

.source-foot p {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--ink-muted);
  font-size: 9px;
  letter-spacing: 0.02em;
}

.foot-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.65;
}

.text-button {
  padding: 0;
  border: 0;
  color: var(--ink-muted);
  background: transparent;
  font-size: 10px;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: color 160ms ease, opacity 160ms ease;
}

.text-button:hover:not(:disabled) {
  color: var(--accent-deep);
}

.text-button:disabled {
  opacity: 0.32;
  cursor: default;
}

.text-button.is-confirming {
  color: var(--accent-deep);
  font-weight: 600;
}

.copy-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.copy-button:not(:disabled),
.source-foot .text-button:not(:disabled) {
  color: var(--ink-soft);
}

.copy-button svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

/* ── Scroll areas ───────────────────────────────────────── */
.scroll-shell {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
}

.scroll-shell::before {
  content: "";
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  right: 0;
  height: 10px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(250, 247, 239, 0.9), transparent);
}

.scroll-area {
  width: 100%;
  height: 100%;
  overflow: auto;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: rgba(65, 55, 40, 0.17) transparent;
  overscroll-behavior: contain;
}

.scroll-area::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

.scroll-area::-webkit-scrollbar-track {
  background: transparent;
}

.scroll-area::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 99px;
  background: rgba(65, 55, 40, 0.17);
  background-clip: padding-box;
}

.scroll-area:focus-visible {
  outline-offset: -3px;
}

.lyrics-content {
  display: flex;
  width: max-content;
  min-width: 100%;
  min-height: 100%;
  flex-direction: column;
  padding: 11px 10px 20px;
}

/* ── Lyric rows and character cells ─────────────────────── */
.lyric-row {
  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: start;
  gap: 7px;
  width: 100%;
  padding: 4px 7px;
  border-radius: 12px;
  transition: background 160ms ease;
}

.lyric-row + .lyric-row {
  margin-top: 2px;
}

.lyric-row:not(.is-blank):hover {
  background: rgba(177, 70, 52, 0.026);
}

.line-number {
  padding-top: calc(15px + var(--rhyme-space));
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.03em;
  line-height: 1;
  text-align: right;
  user-select: none;
  transition: color 200ms ease;
}

.lyric-row.is-complete .line-number {
  color: rgba(108, 123, 103, 0.8);
}

.lyric-row.is-active {
  background: rgba(177, 70, 52, 0.035);
}

.lyric-row.is-active .line-number {
  color: var(--accent);
}

.cells {
  display: flex;
  width: max-content;
  min-width: 0;
  align-items: flex-end;
  gap: var(--cell-gap);
  height: calc(var(--cell-height) + 7px + var(--rhyme-space));
  padding-top: var(--rhyme-space);
}

.char-cell {
  position: relative;
  display: flex;
  flex: 0 0 var(--cell-width);
  align-items: center;
  justify-content: center;
  width: var(--cell-width);
  min-width: var(--cell-width);
  max-width: var(--cell-width);
  height: var(--cell-height);
  overflow: visible;
  border: 1px solid rgba(65, 55, 40, 0.13);
  border-radius: 7px;
  color: var(--ink);
  background: rgba(255, 253, 247, 0.4);
  font-family: var(--serif);
  font-size: var(--cell-font-size);
  font-weight: 600;
  line-height: 1;
  text-align: center;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.rhyme-note {
  position: absolute;
  top: -16px;
  left: 50%;
  z-index: 3;
  display: block;
  color: var(--moss);
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity 140ms ease, color 140ms ease;
}

.rhyme-note::after {
  content: "";
  position: absolute;
  top: calc(100% + 2px);
  left: 50%;
  width: 1px;
  height: 3px;
  background: currentColor;
  opacity: 0.35;
}

.rhyme-note.is-empty {
  opacity: 0;
}

.reference-cell .rhyme-note {
  color: rgba(108, 123, 103, 0.9);
}

.editor-cell .rhyme-note {
  color: var(--accent);
}

.char-cell::before {
  content: "";
  position: absolute;
  inset: 5px;
  z-index: 0;
  pointer-events: none;
  opacity: 0.44;
  background:
    linear-gradient(to right, transparent calc(50% - 0.5px), rgba(90, 78, 60, 0.13) calc(50% - 0.5px), rgba(90, 78, 60, 0.13) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
    linear-gradient(to bottom, transparent calc(50% - 0.5px), rgba(90, 78, 60, 0.13) calc(50% - 0.5px), rgba(90, 78, 60, 0.13) calc(50% + 0.5px), transparent calc(50% + 0.5px));
}

.char-cell.is-filled::before,
.char-cell.is-punct::before {
  opacity: 0;
}

.char-cell .glyph {
  position: relative;
  z-index: 1;
}

.reference-cell {
  color: rgba(41, 39, 32, 0.78);
  border-color: rgba(65, 55, 40, 0.14);
  background: rgba(255, 253, 247, 0.58);
}

.reference-cell .glyph {
  transform: translateY(-0.5px);
}

.editor-cell {
  background: rgba(255, 253, 248, 0.88);
  border-color: rgba(65, 55, 40, 0.17);
  box-shadow: 0 1px 2px rgba(62, 49, 32, 0.035);
}

.editor-cell:hover {
  border-color: rgba(177, 70, 52, 0.3);
  background: var(--white);
}

.editor-cell.is-focused {
  z-index: 2;
  border-color: rgba(177, 70, 52, 0.7);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(177, 70, 52, 0.085), 0 3px 9px rgba(62, 49, 32, 0.06);
}

.editor-cell input {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  outline: none;
  color: var(--ink);
  background: transparent;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: 1;
  text-align: center;
  caret-color: var(--accent);
}

.char-cell.is-punct {
  color: var(--accent-deep);
  border-color: rgba(177, 70, 52, 0.16);
  background: rgba(177, 70, 52, 0.065);
  font-weight: 500;
}

.editor-cell.is-punct input {
  color: var(--accent-deep);
  font-weight: 500;
}

.editor-cell.is-punct:not(.is-focused) {
  box-shadow: none;
}

.editor-cell.is-extra {
  border-style: dashed;
  border-color: rgba(108, 123, 103, 0.32);
}

.editor-cell.is-extra::after {
  content: "+";
  position: absolute;
  z-index: 1;
  top: 2px;
  right: 3px;
  color: var(--moss);
  font-family: var(--sans);
  font-size: 7px;
  font-weight: 600;
  line-height: 1;
  opacity: 0.5;
  pointer-events: none;
}

.editor-cell.is-extra.is-filled::after {
  opacity: 0.22;
}

.is-blank {
  min-height: 26px;
}

.is-blank .line-number {
  padding-top: 0;
  color: transparent;
}

.is-blank .blank-rule {
  height: 26px;
  background:
    linear-gradient(90deg, transparent, rgba(65, 55, 40, 0.13) 18%, rgba(65, 55, 40, 0.13) 82%, transparent) center / 100% 1px no-repeat;
  opacity: 0.38;
}

.blank-rule::before {
  content: "";
  display: block;
  width: 3px;
  height: 3px;
  margin: 11px auto 0;
  border-radius: 50%;
  background: var(--ink-faint);
}

/* ── Empty states ───────────────────────────────────────── */
.empty-state {
  display: flex;
  min-height: 100%;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 22px 54px;
  text-align: center;
  animation: fade-in 400ms ease both;
}

.empty-illustration {
  position: relative;
  display: grid;
  width: 86px;
  height: 86px;
  margin-bottom: 20px;
  padding: 12px;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 247, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.empty-illustration::after {
  content: "";
  position: absolute;
  top: -5px;
  right: -5px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 3px solid var(--paper);
  background: var(--accent);
  opacity: 0.6;
}

.grid-glyph {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.grid-glyph i {
  border: 1px solid rgba(65, 55, 40, 0.14);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.34);
}

.grid-glyph i:nth-child(2),
.grid-glyph i:nth-child(6) {
  border-color: rgba(177, 70, 52, 0.17);
  background: rgba(177, 70, 52, 0.08);
}

.empty-illustration.lines-glyph {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 9px;
  padding: 19px 15px;
}

.lines-glyph span {
  display: block;
  height: 2px;
  border-radius: 99px;
  background: rgba(65, 55, 40, 0.15);
}

.lines-glyph span:nth-child(1) {
  width: 84%;
}

.lines-glyph span:nth-child(2) {
  width: 100%;
}

.lines-glyph span:nth-child(3) {
  width: 58%;
  background: rgba(177, 70, 52, 0.25);
}

.empty-state h3 {
  margin: 0 0 7px;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.empty-state p {
  max-width: 245px;
  margin: 0;
  color: var(--ink-muted);
  font-size: 10.5px;
  line-height: 1.85;
  letter-spacing: 0.02em;
}

.empty-state .empty-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 15px;
  color: var(--ink-faint);
  font-size: 9px;
  letter-spacing: 0.08em;
}

.empty-hint::before,
.empty-hint::after {
  content: "";
  width: 16px;
  height: 1px;
  background: var(--line);
}

/* ── Panel footers ──────────────────────────────────────── */
.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
  min-height: 44px;
  padding: 10px 18px;
  border-top: 1px solid var(--line);
  background: linear-gradient(0deg, rgba(255, 253, 247, 0.33), transparent);
}

.sync-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--ink-muted);
  font-size: 9px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.sync-note svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: var(--moss);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.4;
  opacity: 0.8;
}

.fill-foot {
  align-items: center;
}

.fill-foot-actions {
  display: flex;
  align-items: center;
  gap: 13px;
  flex: 0 0 auto;
}

.match-note {
  margin: 0;
  color: var(--ink-faint);
  font-size: 8px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.progress-block {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.progress-label {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin: 0;
  white-space: nowrap;
}

.progress-label strong {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.progress-label span {
  color: var(--ink-muted);
  font-size: 9px;
}

.progress-track {
  position: relative;
  width: 100%;
  max-width: 122px;
  height: 3px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(65, 55, 40, 0.1);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(177, 70, 52, 0.65), var(--accent));
  transition: width 280ms cubic-bezier(0.25, 0.8, 0.25, 1), background 240ms ease;
}

.progress-track.is-complete span {
  background: linear-gradient(90deg, rgba(108, 123, 103, 0.62), var(--moss));
}

.keyboard-tip {
  margin: 0;
  color: var(--ink-faint);
  font-size: 8px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

kbd {
  display: inline-block;
  min-width: 17px;
  padding: 2px 4px;
  border: 1px solid var(--line);
  border-bottom-color: var(--line-strong);
  border-radius: 4px;
  color: var(--ink-muted);
  background: rgba(255, 253, 248, 0.55);
  font-family: var(--mono);
  font-size: 7px;
  text-align: center;
  box-shadow: 0 1px 0 rgba(65, 55, 40, 0.05);
}

/* ── Page footer ────────────────────────────────────────── */
.app-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 28px;
  padding: 8px 4px 0;
  color: var(--ink-faint);
  font-size: 8.5px;
  letter-spacing: 0.07em;
}

.app-foot p {
  margin: 0;
}

.app-foot-mark {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: 0.2em;
}

.app-foot-mark span {
  width: 22px;
  height: 1px;
  background: var(--line-strong);
}

/* ── Toast ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 28px;
  padding: 10px 16px;
  border: 1px solid rgba(65, 55, 40, 0.13);
  border-radius: 999px;
  color: var(--ink-soft);
  background: rgba(255, 253, 247, 0.94);
  box-shadow: 0 12px 30px rgba(62, 49, 32, 0.13);
  font-size: 11px;
  letter-spacing: 0.03em;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 220ms ease, transform 220ms ease;
  backdrop-filter: blur(10px);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-error {
  color: var(--accent-deep);
  border-color: rgba(177, 70, 52, 0.2);
}

.noscript {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 30px;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 15px;
}

/* ── Motion ─────────────────────────────────────────────── */
@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes breathe {
  0% {
    opacity: 0.7;
    transform: scale(0.7);
  }
  70%,
  100% {
    opacity: 0;
    transform: scale(1.8);
  }
}

@keyframes confirm-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(177, 70, 52, 0);
  }
  50% {
    box-shadow: 0 0 0 3px rgba(177, 70, 52, 0.08);
  }
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1240px) {
  .app-shell {
    padding: 18px 18px 8px;
  }

  .workspace {
    gap: 12px;
  }

  .topbar-rule {
    width: 180px;
  }

  .panel-head {
    padding: 13px 15px;
    min-height: 68px;
  }

  .panel-stat {
    font-size: 9px;
  }

  .lyrics-content {
    padding-left: 7px;
    padding-right: 7px;
  }

  .lyric-row {
    grid-template-columns: 19px minmax(0, 1fr);
    gap: 5px;
    padding: 4px 5px;
  }

  .fill-foot {
    padding-left: 15px;
    padding-right: 15px;
  }

  .keyboard-tip {
    display: none;
  }
}

@media (max-width: 1020px) {
  .brand-motto,
  .topbar-rule {
    display: none;
  }

  .topbar-tip {
    display: none;
  }

  .workspace {
    grid-template-columns: minmax(200px, 0.64fr) minmax(0, 1fr) minmax(0, 1fr);
  }

  .panel-index {
    display: none;
  }

  .panel-heading {
    gap: 0;
  }

  .panel-heading h2 {
    font-size: 18px;
  }

  .panel-kicker {
    font-size: 7px;
  }
}

@media (max-width: 960px) {
  html,
  body {
    height: auto;
    overflow: auto;
  }

  body {
    min-height: 100%;
  }

  .app-shell {
    display: block;
    height: auto;
    min-height: 100dvh;
    padding: 15px 14px 12px;
  }

  .topbar {
    min-height: 54px;
    padding-bottom: 14px;
  }

  .brand-seal {
    width: 43px;
    height: 43px;
    border-radius: 12px 12px 12px 5px;
  }

  .brand-seal span {
    font-size: 22px;
  }

  .brand h1 {
    font-size: 22px;
  }

  .workspace {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .workspace.is-source-collapsed {
    grid-template-columns: 1fr;
  }

  .workspace.is-source-collapsed .source-rail {
    flex-direction: row;
    justify-content: center;
    height: 42px;
    min-height: 42px;
    padding: 0 14px;
    gap: 8px;
    border-radius: 14px;
  }

  .source-rail-label,
  .source-rail-note {
    writing-mode: horizontal-tb;
  }

  .panel-source {
    height: 46vh;
    min-height: 380px;
  }

  .panel-preview,
  .panel-fill {
    height: 58vh;
    min-height: 460px;
  }

  .panel-source,
  .panel-preview,
  .panel-fill {
    animation-delay: 0ms;
  }

  .panel-head {
    min-height: 64px;
  }

  .panel-index {
    display: inline-flex;
  }

  .panel-heading {
    gap: 10px;
  }

  .app-foot {
    padding-top: 12px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 12px 10px 10px;
  }

  .brand-copy {
    grid-template-columns: auto;
  }

  .brand-motto {
    display: block;
    margin-top: 2px;
    font-size: 9px;
  }

  .panel {
    border-radius: 17px;
  }

  .panel-head {
    padding: 12px 14px;
    min-height: 60px;
  }

  .panel-heading h2 {
    font-size: 17px;
  }

  .panel-stat {
    font-size: 8px;
  }

  .mode-pill {
    height: 21px;
    padding: 0 7px;
    font-size: 8px;
  }

  .panel-fill .mode-pill {
    display: none;
  }

  .source-body {
    padding: 10px 11px 9px;
  }

  .lyrics-content {
    padding: 8px 4px 16px;
  }

  .lyric-row {
    grid-template-columns: 17px minmax(0, 1fr);
    gap: 4px;
    padding: 4px 4px;
  }

  .empty-illustration {
    width: 72px;
    height: 72px;
    margin-bottom: 16px;
  }

  .empty-state {
    padding: 28px 18px 40px;
  }

  .panel-foot {
    padding: 9px 14px;
    min-height: 42px;
  }

  .sync-note {
    font-size: 8px;
  }

  .copy-button {
    font-size: 9px;
  }

  .keyboard-tip {
    display: none;
  }

  .panel-source {
    min-height: 360px;
  }

  .panel-preview,
  .panel-fill {
    min-height: 430px;
  }

  .app-foot {
    font-size: 8px;
  }

  .app-foot-mark {
    display: none;
  }
}

@media (max-height: 720px) and (min-width: 961px) {
  .app-shell {
    padding-top: 14px;
  }

  .topbar {
    min-height: 54px;
    padding-bottom: 11px;
  }

  .brand-seal {
    width: 43px;
    height: 43px;
  }

  .brand h1 {
    font-size: 22px;
  }

  .brand-motto {
    display: none;
  }

  .app-foot {
    display: none;
  }

  .panel-head {
    min-height: 62px;
  }
}

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