:root {
  color-scheme: dark;
  --bg: #05070d;
  --surface: rgba(10, 18, 31, 0.82);
  --surface-strong: rgba(18, 31, 50, 0.92);
  --ink: #edf7ff;
  --muted: #8da7b8;
  --line: rgba(88, 242, 255, 0.24);
  --cyan: #58f2ff;
  --cyan-strong: #9dfbff;
  --magenta: #ff3df2;
  --lime: #b8ff45;
  --amber: #ffd166;
  --red: #ff5c7c;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.38), 0 0 34px rgba(88, 242, 255, 0.12);
  --radius: 6px;
  --reader-size: 24px;
  --reader-line: 1.85;
  --panel-glow: linear-gradient(90deg, var(--cyan), var(--magenta), var(--lime), var(--cyan));
  --grid-a: rgba(88, 242, 255, 0.05);
  --grid-b: rgba(255, 61, 242, 0.04);
  --halo-a: rgba(88, 242, 255, 0.15);
  --bg-mid: #0a1020;
  --bg-deep: #12071c;
  --scan-a: rgba(88, 242, 255, 0.16);
  --scan-b: rgba(255, 61, 242, 0.2);
  --rail-a: rgba(88, 242, 255, 0.05);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(var(--grid-a) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-b) 1px, transparent 1px),
    radial-gradient(circle at 20% 0%, var(--halo-a), transparent 32%),
    linear-gradient(135deg, var(--bg) 0%, var(--bg-mid) 46%, var(--bg-deep) 100%);
  background-size: 42px 42px, 42px 42px, auto, auto;
  animation: gridDrift 18s linear infinite;
  font-family:
    "Noto Serif SC", "Songti SC", "STSong", "SimSun", "PingFang SC",
    "Microsoft YaHei", serif;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.035) 0,
      rgba(255, 255, 255, 0.035) 1px,
      transparent 1px,
      transparent 5px
    );
  mix-blend-mode: screen;
  opacity: 0.22;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, transparent 0%, var(--scan-a) 47%, var(--scan-b) 50%, transparent 54%),
    repeating-linear-gradient(90deg, transparent 0 44px, var(--rail-a) 44px 45px);
  background-size: 100% 180px, 90px 100%;
  mix-blend-mode: screen;
  opacity: 0.42;
  animation: scanSweep 7s linear infinite;
}

body[data-palette="ember"] {
  --bg: #080605;
  --surface: rgba(24, 12, 10, 0.84);
  --surface-strong: rgba(38, 18, 14, 0.94);
  --ink: #fff8ef;
  --muted: #c7a99b;
  --line: rgba(255, 106, 61, 0.28);
  --cyan: #ff6a3d;
  --cyan-strong: #ffd2bd;
  --magenta: #ff2f7d;
  --lime: #ffe66b;
  --amber: #6df7ff;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.4), 0 0 34px rgba(255, 106, 61, 0.14);
  --grid-a: rgba(255, 106, 61, 0.055);
  --grid-b: rgba(255, 230, 107, 0.04);
  --halo-a: rgba(255, 47, 125, 0.14);
  --bg-mid: #1b0b11;
  --bg-deep: #181205;
  --scan-a: rgba(255, 106, 61, 0.2);
  --scan-b: rgba(255, 230, 107, 0.2);
  --rail-a: rgba(255, 106, 61, 0.06);
}

body[data-palette="matrix"] {
  --bg: #020806;
  --surface: rgba(5, 22, 18, 0.84);
  --surface-strong: rgba(8, 34, 27, 0.94);
  --ink: #effff7;
  --muted: #8fb9a9;
  --line: rgba(67, 255, 161, 0.25);
  --cyan: #43ffa1;
  --cyan-strong: #c3ffe0;
  --magenta: #39d7ff;
  --lime: #f0ff59;
  --amber: #ff5cc8;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.42), 0 0 34px rgba(67, 255, 161, 0.13);
  --grid-a: rgba(67, 255, 161, 0.05);
  --grid-b: rgba(57, 215, 255, 0.04);
  --halo-a: rgba(67, 255, 161, 0.13);
  --bg-mid: #071711;
  --bg-deep: #061325;
  --scan-a: rgba(67, 255, 161, 0.18);
  --scan-b: rgba(57, 215, 255, 0.2);
  --rail-a: rgba(67, 255, 161, 0.055);
}

body[data-palette="violet"] {
  --bg: #050612;
  --surface: rgba(12, 13, 34, 0.84);
  --surface-strong: rgba(20, 22, 56, 0.94);
  --ink: #f3f1ff;
  --muted: #a8a4ca;
  --line: rgba(122, 147, 255, 0.28);
  --cyan: #7a93ff;
  --cyan-strong: #d5dcff;
  --magenta: #ff4fd8;
  --lime: #ffd76d;
  --amber: #52ffe1;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.42), 0 0 34px rgba(122, 147, 255, 0.15);
  --grid-a: rgba(122, 147, 255, 0.055);
  --grid-b: rgba(255, 79, 216, 0.045);
  --halo-a: rgba(255, 79, 216, 0.13);
  --bg-mid: #0c1230;
  --bg-deep: #190b25;
  --scan-a: rgba(122, 147, 255, 0.2);
  --scan-b: rgba(255, 79, 216, 0.2);
  --rail-a: rgba(122, 147, 255, 0.06);
}

button,
input,
select {
  font: inherit;
  min-width: 0;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(88, 242, 255, 0.38);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1660px, calc(100% - 32px));
  margin: 0 auto;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 74px;
  padding: 12px 0;
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  color: #061018;
  background:
    linear-gradient(135deg, var(--cyan), var(--lime) 54%, var(--magenta));
  box-shadow: 0 0 22px rgba(88, 242, 255, 0.55), inset 0 0 14px rgba(255, 255, 255, 0.4);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-weight: 900;
  animation: markPulse 3.2s ease-in-out infinite;
}

.brand strong,
.brand span span {
  display: block;
  line-height: 1.1;
}

.brand strong {
  color: var(--cyan-strong);
  font-family: ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0;
  text-shadow: 0 0 18px rgba(88, 242, 255, 0.65);
  animation: textFlicker 5.5s steps(1, end) infinite;
}

.brand span span {
  margin-top: 3px;
  color: var(--magenta);
  font-size: 13px;
}

.top-actions,
.reader-actions,
.search-row,
.section-head,
.results-head,
.detail-tabs,
.mini-tabs {
  display: flex;
  align-items: center;
}

.top-actions,
.reader-actions,
.detail-tabs,
.mini-tabs {
  gap: 8px;
}

.icon-button,
.text-button,
.plain-button,
.primary-button,
.tab,
.mini-tab,
.chip,
.author-pill {
  min-height: 40px;
  border-radius: var(--radius);
  transition:
    transform 150ms ease,
    background-color 150ms ease,
    color 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.icon-button,
.text-button,
.tab,
.mini-tab,
.chip,
.author-pill,
.search-row input,
.results-head select {
  color: var(--ink);
  background: rgba(6, 14, 26, 0.76);
  border: 1px solid var(--line);
  box-shadow: inset 0 0 18px rgba(88, 242, 255, 0.04);
}

.icon-button {
  width: 44px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 20px;
}

.text-button {
  padding: 0 14px;
}

.plain-button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
}

.primary-button {
  padding: 0 16px;
  color: #061018;
  background: var(--cyan);
  box-shadow: 0 0 24px rgba(88, 242, 255, 0.38);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-weight: 800;
}

.icon-button:hover,
.text-button:hover,
.plain-button:hover,
.primary-button:hover,
.tab:hover,
.mini-tab:hover,
.chip:hover,
.author-pill:hover,
.poem-card:hover {
  transform: translateY(-1px);
}

.primary-button:hover {
  background: var(--lime);
  box-shadow: 0 0 28px rgba(184, 255, 69, 0.44);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  grid-template-areas:
    "reader controls"
    "results controls";
  gap: 18px;
  padding-bottom: 32px;
}

.reader-pane,
.control-pane,
.results-pane {
  position: relative;
  min-width: 0;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.reader-pane {
  grid-area: reader;
  overflow: hidden;
  padding: clamp(18px, 2vw, 30px);
}

.reader-pane::before,
.results-pane::before,
.control-pane::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--panel-glow);
  background-size: 280% 100%;
  box-shadow: 0 0 18px rgba(88, 242, 255, 0.55);
  animation: borderFlow 3.6s linear infinite;
}

.reader-pane::after,
.results-pane::after,
.control-pane::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  border-radius: inherit;
  background:
    linear-gradient(135deg, rgba(88, 242, 255, 0.16), transparent 30%),
    linear-gradient(315deg, rgba(255, 61, 242, 0.14), transparent 34%);
  filter: blur(16px);
  opacity: 0.55;
}

.control-pane {
  grid-area: controls;
  position: sticky;
  top: 84px;
  align-self: start;
  display: grid;
  gap: 14px;
  width: 100%;
  max-height: calc(100vh - 98px);
  overflow: auto;
  overflow-x: hidden;
  padding: 16px;
}

.results-pane {
  grid-area: results;
  padding: 20px;
  overflow: hidden;
}

.reader-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  min-width: 0;
}

.reader-toolbar > div {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--lime);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(184, 255, 69, 0.5);
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(34px, 4.2vw, 64px);
  line-height: 1.08;
  letter-spacing: 0;
  text-shadow: 0 0 26px rgba(255, 61, 242, 0.24);
}

h2 {
  margin: 0;
  color: var(--cyan-strong);
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

.poem-byline {
  margin: 10px 0 0;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.reader-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.poem-reader {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  min-height: 370px;
  padding: clamp(22px, 4vw, 58px);
  overflow: hidden;
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(88, 242, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 61, 242, 0.07) 1px, transparent 1px),
    rgba(1, 8, 16, 0.72);
  background-size: 28px 28px;
  border: 1px solid rgba(88, 242, 255, 0.36);
  box-shadow: inset 0 0 40px rgba(88, 242, 255, 0.08), 0 0 34px rgba(255, 61, 242, 0.09);
}

.poem-reader::before {
  content: "";
  position: absolute;
  inset: -30%;
  pointer-events: none;
  background: conic-gradient(from 90deg, transparent 0 18%, rgba(88, 242, 255, 0.16) 22%, transparent 30% 52%, rgba(255, 61, 242, 0.16) 58%, transparent 64%);
  animation: readerOrbit 12s linear infinite;
}

.poem-reader::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(100deg, transparent 0 36%, rgba(184, 255, 69, 0.14) 46%, transparent 56% 100%);
  transform: translateX(-120%);
  animation: readerSheen 4.8s ease-in-out infinite;
}

.poem-reader.is-vertical {
  justify-content: flex-start;
  overflow-x: auto;
}

.poem-lines {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 760px;
  min-width: 0;
  color: #f8fdff;
  font-size: var(--reader-size);
  line-height: var(--reader-line);
  text-align: center;
  text-shadow: 0 0 18px rgba(88, 242, 255, 0.2);
}

.poem-lines p {
  margin: 0;
}

.poem-lines p + p {
  margin-top: 8px;
}

.poem-reader.is-vertical .poem-lines {
  width: auto;
  max-width: none;
  min-height: 300px;
  writing-mode: vertical-rl;
  text-align: left;
}

.poem-reader.is-vertical .poem-lines p + p {
  margin-top: 0;
  margin-right: 14px;
}

.detail-tabs {
  margin-top: 16px;
  overflow-x: auto;
}

.tab,
.mini-tab {
  padding: 0 14px;
  color: var(--muted);
}

.tab.is-active,
.mini-tab.is-active {
  color: #061018;
  background: var(--magenta);
  border-color: var(--magenta);
  box-shadow: 0 0 22px rgba(255, 61, 242, 0.38);
}

.detail-panel {
  max-width: 100%;
  overflow: hidden;
  min-height: 92px;
  margin-top: 12px;
  padding: 16px;
  color: #d4ebf6;
  background: rgba(2, 10, 18, 0.76);
  border: 1px solid rgba(255, 61, 242, 0.22);
  border-radius: var(--radius);
  line-height: 1.8;
}

.detail-panel p,
.detail-panel ul {
  margin: 0;
}

.detail-panel li + li {
  margin-top: 6px;
}

.detail-stack,
.detail-block {
  display: grid;
  gap: 12px;
}

.detail-stack {
  gap: 14px;
}

.detail-kicker,
.detail-note {
  margin: 0;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
}

.detail-kicker {
  color: var(--lime);
  font-weight: 900;
  text-transform: uppercase;
}

.detail-block h3 {
  margin: 0;
  color: var(--cyan-strong);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.3;
}

.detail-block p {
  margin: 0;
}

.insight-grid,
.appreciation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
  gap: 10px;
}

.insight-card {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 12px;
  background:
    linear-gradient(135deg, rgba(88, 242, 255, 0.08), rgba(255, 61, 242, 0.05)),
    rgba(6, 14, 26, 0.68);
  border: 1px solid rgba(88, 242, 255, 0.18);
  border-radius: var(--radius);
}

.insight-card strong {
  color: var(--lime);
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.insight-card span {
  color: #d4ebf6;
}

.fact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.fact-row span {
  min-height: 30px;
  padding: 5px 9px;
  color: var(--cyan-strong);
  background: rgba(88, 242, 255, 0.08);
  border: 1px solid rgba(88, 242, 255, 0.18);
  border-radius: var(--radius);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
}

.translation-list {
  display: grid;
  gap: 9px;
}

.translation-line {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 4px 10px;
  width: 100%;
  min-width: 0;
  padding: 11px;
  color: var(--ink);
  text-align: left;
  background:
    linear-gradient(120deg, rgba(88, 242, 255, 0.08), rgba(255, 61, 242, 0.04)),
    rgba(6, 14, 26, 0.68);
  border: 1px solid rgba(88, 242, 255, 0.18);
  border-radius: var(--radius);
}

.translation-line:hover {
  border-color: var(--cyan);
  box-shadow: 0 0 22px rgba(88, 242, 255, 0.16);
}

.line-no {
  grid-row: span 2;
  color: var(--lime);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-weight: 900;
}

.translation-line strong,
.translation-line em {
  min-width: 0;
  overflow-wrap: anywhere;
}

.translation-line strong {
  color: var(--cyan-strong);
  font-style: normal;
}

.translation-line em {
  color: #d4ebf6;
  font-style: normal;
}

.poem-lines p {
  border-radius: var(--radius);
  transition:
    background-color 180ms ease,
    color 180ms ease,
    text-shadow 180ms ease,
    box-shadow 180ms ease;
}

.poem-lines p.is-highlight {
  color: #061018;
  background: var(--lime);
  box-shadow: 0 0 24px rgba(184, 255, 69, 0.42);
  text-shadow: none;
}

.search-box {
  display: grid;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.search-box label,
.setting-row label,
.toggle-row {
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.search-row input {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  height: 44px;
  padding: 0 12px;
}

.search-row input::placeholder {
  color: rgba(141, 167, 184, 0.78);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.metric {
  min-width: 0;
  overflow: hidden;
  padding: 12px;
  background: rgba(6, 14, 26, 0.76);
  border: 1px solid rgba(88, 242, 255, 0.18);
  border-radius: var(--radius);
}

.metric strong {
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: var(--lime);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(15px, 1.2vw, 22px);
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-shadow: 0 0 14px rgba(184, 255, 69, 0.34);
}

.metric span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.filter-section {
  display: grid;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

.section-head,
.results-head {
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.section-head h2,
.results-head h2 {
  min-width: 0;
  overflow-wrap: anywhere;
}

.chip-grid,
.author-cloud,
.timeline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip,
.author-pill {
  min-width: 0;
  max-width: 100%;
  padding: 0 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip.is-active,
.author-pill.is-active,
.timeline button.is-active {
  color: #061018;
  background: var(--cyan);
  border-color: var(--cyan);
  box-shadow: 0 0 18px rgba(88, 242, 255, 0.36);
}

.author-pill {
  min-height: 34px;
  font-size: 14px;
}

.setting-row {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 10px;
}

.setting-row input {
  width: 100%;
  accent-color: var(--cyan);
}

.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--magenta);
}

.mini-tab {
  min-height: 34px;
  flex: 1;
}

.mini-list {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.mini-item {
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: 52px;
  padding: 9px 10px;
  color: var(--ink);
  text-align: left;
  background: rgba(6, 14, 26, 0.76);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.mini-item strong,
.mini-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-item span {
  color: var(--muted);
  font-size: 12px;
}

.results-head {
  margin-bottom: 14px;
}

.results-head select {
  min-width: 116px;
  max-width: 100%;
  height: 40px;
  padding: 0 10px;
}

.timeline {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(88, 242, 255, 0.16);
}

.timeline button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--muted);
  background: rgba(6, 14, 26, 0.5);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.poem-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr));
  gap: 12px;
  min-width: 0;
}

.poem-card {
  position: relative;
  display: grid;
  gap: 10px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 184px;
  padding: 15px;
  overflow: hidden;
  color: var(--ink);
  text-align: left;
  background:
    linear-gradient(135deg, rgba(88, 242, 255, 0.08), rgba(255, 61, 242, 0.04)),
    rgba(6, 14, 26, 0.8);
  border: 1px solid rgba(88, 242, 255, 0.2);
  border-radius: var(--radius);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    border-color 150ms ease;
}

.poem-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(110deg, transparent 0 36%, rgba(88, 242, 255, 0.16) 47%, rgba(255, 61, 242, 0.13) 54%, transparent 66%);
  transform: translateX(-130%);
  transition: transform 520ms ease;
}

.poem-card:hover::before,
.poem-card.is-active::before {
  transform: translateX(130%);
}

.poem-card.is-active {
  border-color: var(--magenta);
  box-shadow: 0 0 30px rgba(255, 61, 242, 0.22), inset 0 0 22px rgba(255, 61, 242, 0.04);
}

.poem-card h3 {
  position: relative;
  margin: 0;
  color: var(--cyan-strong);
  font-size: 20px;
  line-height: 1.28;
  overflow-wrap: anywhere;
}

.poem-card .meta {
  position: relative;
  min-width: 0;
  overflow: hidden;
  color: var(--lime);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.poem-card .excerpt {
  position: relative;
  margin: 0;
  color: #d4ebf6;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.tags {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  min-width: 0;
}

.tag {
  max-width: 100%;
  padding: 4px 7px;
  overflow: hidden;
  color: var(--cyan-strong);
  background: rgba(88, 242, 255, 0.1);
  border: 1px solid rgba(88, 242, 255, 0.2);
  border-radius: 999px;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  padding: 22px;
  color: var(--muted);
  background: rgba(6, 14, 26, 0.78);
  border: 1px dashed rgba(88, 242, 255, 0.26);
  border-radius: var(--radius);
}

body.dark {
  color-scheme: dark;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-areas:
      "reader"
      "controls"
      "results";
  }

  .control-pane {
    position: static;
    max-height: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search-box,
  .metrics,
  .filter-section {
    min-width: 0;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 18px, 1660px);
  }

  .topbar {
    min-height: 64px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .workspace {
    gap: 12px;
  }

  .reader-pane,
  .control-pane,
  .results-pane {
    padding: 14px;
  }

  .reader-toolbar {
    display: grid;
  }

  .reader-actions {
    justify-content: flex-start;
  }

  .poem-reader {
    min-height: 300px;
    padding: 20px 14px;
  }

  .poem-lines {
    font-size: calc(var(--reader-size) - 2px);
  }

  .control-pane {
    grid-template-columns: 1fr;
  }

  .metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .search-row {
    grid-template-columns: 1fr auto;
  }

  .poem-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 440px) {
  .top-actions {
    gap: 6px;
  }

  .brand strong {
    font-size: 15px;
  }

  .reader-actions,
  .detail-tabs,
  .results-head {
    align-items: stretch;
  }

  .reader-actions,
  .results-head {
    flex-direction: column;
  }

  .reader-actions .text-button,
  .reader-actions .primary-button,
  .search-row .primary-button,
  .results-head select {
    width: 100%;
  }

  .search-row {
    grid-template-columns: 1fr;
  }

  .metrics {
    grid-template-columns: 1fr;
  }
}

@keyframes gridDrift {
  0% {
    background-position: 0 0, 0 0, center, center;
  }
  100% {
    background-position: 84px 84px, -84px 42px, center, center;
  }
}

@keyframes scanSweep {
  0% {
    background-position: 0 -220px, 0 0;
  }
  100% {
    background-position: 0 100vh, 90px 0;
  }
}

@keyframes borderFlow {
  0% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 280% 50%;
  }
}

@keyframes markPulse {
  0%,
  100% {
    box-shadow: 0 0 22px rgba(88, 242, 255, 0.55), inset 0 0 14px rgba(255, 255, 255, 0.4);
  }
  50% {
    box-shadow: 0 0 38px rgba(255, 61, 242, 0.55), 0 0 10px rgba(184, 255, 69, 0.35), inset 0 0 18px rgba(255, 255, 255, 0.48);
  }
}

@keyframes textFlicker {
  0%,
  92%,
  100% {
    opacity: 1;
    transform: translateX(0);
  }
  93% {
    opacity: 0.72;
    transform: translateX(1px);
  }
  94% {
    opacity: 1;
    transform: translateX(-1px);
  }
}

@keyframes readerOrbit {
  to {
    transform: rotate(360deg);
  }
}

@keyframes readerSheen {
  0%,
  42% {
    transform: translateX(-120%);
  }
  66%,
  100% {
    transform: translateX(120%);
  }
}

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