:root {
  color-scheme: light;
  --bg: #efe7db;
  --bg-2: #f6eee2;
  --surface-rgb: 253, 247, 238;
  --surface-strong-rgb: 250, 242, 231;
  --panel: rgba(253, 247, 238, 0.72);
  --panel-border: rgba(53, 35, 18, 0.12);
  --text: #1f160f;
  --muted: #705f50;
  --accent: #8b4d2c;
  --accent-2: #315c66;
  --shadow: 0 24px 60px rgba(58, 37, 20, 0.12);
  --verse-font-size: 0.88rem;
  --verse-line-height: 1.3;
  --user-font-scale: 1;
  --poem-color: transparent;
}

@font-face {
  font-family: "OpenDyslexic";
  src: url("opendyslexic-0.92/OpenDyslexic-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
}

@font-face {
  font-family: "OpenDyslexic";
  src: url("opendyslexic-0.92/OpenDyslexic-Italic.otf") format("opentype");
  font-weight: 400;
  font-style: italic;
}

@font-face {
  font-family: "OpenDyslexic";
  src: url("opendyslexic-0.92/OpenDyslexic-Bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
}

@font-face {
  font-family: "OpenDyslexic";
  src: url("opendyslexic-0.92/OpenDyslexic-BoldItalic.otf") format("opentype");
  font-weight: 700;
  font-style: italic;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: "OpenDyslexic", "OpenDyslexicAlta", "Lexend", "Atkinson Hyperlegible", system-ui, sans-serif;
  letter-spacing: 0.01em;
  word-spacing: 0.04em;
  color: var(--text);
  background: var(--bg);
  background-attachment: fixed;
  transition: background 260ms ease;
}

body.has-poem-theme {
  --bg: color-mix(in srgb, var(--poem-color) 18%, #efe7db);
  --poem-glow-1: color-mix(in srgb, var(--poem-color) 40%, transparent);
  --poem-glow-2: color-mix(in srgb, var(--poem-color) 26%, transparent);
  --poem-surface: color-mix(in srgb, var(--poem-color) 14%, transparent);
  --poem-surface-strong: color-mix(in srgb, var(--poem-color) 22%, transparent);
  --poem-border: color-mix(in srgb, var(--poem-color) 42%, rgba(53, 35, 18, 0.12));
}

button,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1680px, calc(100% - 16px));
  max-width: 100%;
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.76rem;
  color: var(--accent-2);
  font-weight: 700;
}

h1,
h2 {
  font-family: inherit;
  margin: 0;
  line-height: 0.95;
}

h1 {
  font-size: clamp(2.8rem, 5vw, 5rem);
  letter-spacing: -0.03em;
}

.lede {
  max-width: 64ch;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.controls {
  margin-bottom: 16px;
  display: grid;
  gap: 10px;
}

.manager-shell .manager-body {
  margin-top: 10px;
  display: flex;
  justify-content: flex-start;
  min-width: 0;
}

.quick-controls {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--poem-border, rgba(53, 35, 18, 0.1));
  background:
    linear-gradient(var(--poem-surface-strong, transparent), var(--poem-surface-strong, transparent)),
    rgba(var(--surface-rgb), 0.8);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  transition: background 260ms ease, border-color 260ms ease;
}

.quick-control-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.quick-control-label {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.quick-control-group input[type="range"] {
  width: 150px;
}

.quick-control-group select {
  border: 1px solid rgba(53, 35, 18, 0.18);
  border-radius: 10px;
  padding: 0.32rem 0.5rem;
  background: rgb(var(--surface-rgb));
  color: var(--text);
}

.quick-control-value {
  font-size: 0.78rem;
  color: var(--accent-2);
  min-width: 42px;
  text-align: right;
}

.word-lookup-bar {
  flex-wrap: wrap;
  padding-top: 2px;
  width: 100%;
  margin-top: 10px;
}

.word-lookup-bar select {
  border: 1px solid rgba(53, 35, 18, 0.18);
  border-radius: 10px;
  padding: 0.3rem 0.5rem;
  background: rgb(var(--surface-rgb));
  color: var(--text);
}

.lookup-results {
  width: 100%;
  display: grid;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px dashed rgba(53, 35, 18, 0.14);
  background: rgba(var(--surface-rgb), 0.74);
}

.lookup-empty {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.lookup-section {
  display: grid;
  gap: 4px;
}

.lookup-section strong {
  font-size: 0.8rem;
  color: var(--text);
}

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

.lookup-filter-row select {
  border: 1px solid rgba(53, 35, 18, 0.18);
  border-radius: 10px;
  padding: 0.24rem 0.5rem;
  background: rgb(var(--surface-rgb));
  color: var(--text);
}

.lookup-embed-wrap {
  width: 100%;
  border: 1px solid rgba(53, 35, 18, 0.14);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(var(--surface-rgb), 0.92);
}

.lookup-embed {
  width: 100%;
  min-height: 220px;
  border: 0;
  background: #fff;
}

.lookup-definition {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
}

.lookup-synonym-groups {
  margin-top: 0.5rem;
  display: grid;
  gap: 8px;
}

.lookup-synonym-group-card {
  padding: 0.72rem 0.78rem;
  border: 1px solid rgba(53, 35, 18, 0.14);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(var(--surface-rgb), 0.96), rgba(var(--surface-rgb), 0.84));
  box-shadow: 0 8px 18px rgba(58, 37, 20, 0.05);
}

.lookup-synonym-group-title {
  margin-bottom: 0.45rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
  font-weight: 700;
}

.lookup-synonym-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.lookup-synonym-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.56rem;
  border-radius: 999px;
  border: 1px solid rgba(49, 92, 102, 0.18);
  background: rgba(49, 92, 102, 0.08);
  color: var(--text);
  font-size: 0.77rem;
  line-height: 1.2;
}

.lookup-rhyme-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 14rem;
  overflow: auto;
  padding-right: 4px;
}

.lookup-rhyme-list li {
  font-size: 0.78rem;
  border: 1px solid rgba(53, 35, 18, 0.14);
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  background: rgba(var(--surface-rgb), 0.88);
}

.lookup-rhyme-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 0.5rem;
  padding: 0.4rem 0.55rem;
  border-radius: 12px;
  border: 1px solid rgba(53, 35, 18, 0.1);
  background: rgba(var(--surface-rgb), 0.7);
  font-size: 0.75rem;
  color: var(--muted);
}

.lookup-rhyme-pagination span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.lookup-rhyme-pagination button {
  border: 1px solid rgba(49, 92, 102, 0.16);
  border-radius: 999px;

.pagination-selector {
  margin-bottom: 24px; /* creates a gap after the selector */
}

.lookup-rhyme-pagination-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(53, 35, 18, 0.1);
  background: rgba(var(--surface-rgb), 0.72);
}

.lookup-rhyme-pagination-size span {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-2);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.lookup-rhyme-pagination-size select {
  min-width: 5rem;
  border: 1px solid rgba(53, 35, 18, 0.14);
  border-radius: 999px;
  background: rgba(var(--surface-rgb), 0.96);
  color: var(--text);
  padding: 0.2rem 0.5rem;
  font: inherit;
}
  background: rgba(49, 92, 102, 0.08);
  color: var(--text);
  padding: 0.14rem 0.55rem;
  font-size: 0.74rem;
}

.lookup-rhyme-pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.lookup-rhyme-pagination input {
  width: 4.5rem;
  min-width: 4.5rem;
  text-align: center;
  border: 1px solid rgba(53, 35, 18, 0.14);
  border-radius: 999px;
  background: rgba(var(--surface-rgb), 0.96);
  color: var(--text);
  padding: 0.14rem 0.35rem;
  font: inherit;
}

.lookup-rhyme-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 0.5rem;
}

.lookup-rhyme-control {
  display: grid;
  gap: 4px;
  padding: 0.42rem 0.5rem;
  border-radius: 12px;
  border: 1px solid rgba(53, 35, 18, 0.1);
  background: rgba(var(--surface-rgb), 0.72);
}

.lookup-rhyme-control span {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-2);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lookup-rhyme-control select,
.lookup-rhyme-control input {
  width: 100%;
  border: 1px solid rgba(53, 35, 18, 0.14);
  border-radius: 10px;
  background: rgba(var(--surface-rgb), 0.96);
  color: var(--text);
  padding: 0.28rem 0.45rem;
  font: inherit;
}

.lookup-rhyme-control input {
  appearance: textfield;
}

.lookup-attribution {
  margin: 0;
  font-size: 0.74rem;
  color: var(--muted);
}

.lookup-attribution a {
  color: var(--accent-2);
  font-weight: 700;
  text-decoration: none;
}

.lookup-attribution a:hover {
  text-decoration: underline;
}

.lookup-loader {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--accent-2);
  font-weight: 700;
}

.lookup-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(49, 92, 102, 0.2);
  border-top-color: var(--accent-2);
  border-radius: 999px;
  animation: lookup-spin 0.85s linear infinite;
}

@keyframes lookup-spin {
  to {
    transform: rotate(360deg);
  }
}

.selected-word-input {
  min-height: 30px;
  padding: 0.22rem 0.62rem;
  border-radius: 999px;
  border: 1px solid rgba(53, 35, 18, 0.14);
  background: rgba(var(--surface-rgb), 0.92);
  font-size: 0.82rem;
  color: var(--muted);
  width: min(42vw, 230px);
}

.selected-word-input::placeholder {
  color: var(--muted);
}

.word-lookup-bar.is-active .selected-word-input {
  color: var(--text);
  border-color: var(--poem-border, rgba(49, 92, 102, 0.34));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-2) 24%, transparent);
}

.config-shell {
  background:
    linear-gradient(var(--poem-surface-strong, transparent), var(--poem-surface-strong, transparent)),
    rgba(var(--surface-rgb), 0.8);
  border: 1px solid var(--poem-border, rgba(53, 35, 18, 0.1));
  border-radius: 18px;
  padding: 10px 12px 12px;
  transition: background 260ms ease, border-color 260ms ease;
}

.config-shell > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text);
}

.config-shell > summary::-webkit-details-marker {
  display: none;
}

.summary-hint {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.guide-hover {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.guide-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid rgba(49, 92, 102, 0.24);
  background: rgba(49, 92, 102, 0.12);
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1;
}

.guide-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 5;
  width: min(360px, 78vw);
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(53, 35, 18, 0.12);
  background: rgba(var(--surface-rgb), 0.98);
  color: var(--text);
  box-shadow: 0 14px 32px rgba(58, 37, 20, 0.12);
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.guide-hover:hover .guide-popover,
.guide-hover:focus-within .guide-popover {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.config-chevron {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  fill: none;
  transition: transform 160ms ease;
}

.config-shell[open] .config-chevron {
  transform: rotate(180deg);
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 10px;
  width: 100%;
}

.config-group {
  border: 1px solid rgba(53, 35, 18, 0.1);
  border-radius: 16px;
  background: rgba(var(--surface-rgb), 0.62);
  padding: 8px 10px 10px;
}

.config-group > summary {
  list-style: none;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--text);
}

.config-group > summary::-webkit-details-marker {
  display: none;
}

.config-body {
  margin-top: 8px;
  display: grid;
  gap: 8px;
}

.config-body label {
  font-size: 0.82rem;
  color: var(--muted);
}

.config-body input,
.config-body select {
  border: 1px solid rgba(53, 35, 18, 0.18);
  border-radius: 10px;
  padding: 0.42rem 0.55rem;
  background: rgb(var(--surface-rgb));
}

.config-body .checkbox-row {
  color: var(--text);
}

.compact-action {
  align-self: start;
  padding: 0.45rem 0.7rem;
  width: fit-content;
  min-height: 0;
  box-shadow: none;
  border: 1px solid rgba(53, 35, 18, 0.16);
  background: rgba(var(--surface-rgb), 0.88);
  color: var(--text);
}

.compact-action:hover {
  box-shadow: none;
  transform: none;
}

.format-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 62px;
  min-height: 32px;
  padding: 0.34rem 0.58rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  border-radius: 10px;
  border: 1px solid rgba(53, 35, 18, 0.18);
  background: rgba(var(--surface-rgb), 0.9);
}

.format-action svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
}

.logo-action img {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  object-fit: cover;
}

.format-action span {
  font-size: 0.68rem;
  font-weight: 800;
}

.top-action-group,
.format-action-group {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 3px;
  border-radius: 12px;
  border: 1px solid rgba(53, 35, 18, 0.14);
  background: rgba(var(--surface-rgb), 0.5);
  white-space: nowrap;
}

.top-action-group .icon-action,
.top-action-group .format-action {
  min-height: 32px;
  height: 32px;
  border-radius: 9px;
}

.top-action-group .icon-action {
  min-width: 32px;
  width: 32px;
}

.memory-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.icon-action {
  min-width: 28px;
  min-height: 28px;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(53, 35, 18, 0.16);
  background: rgba(var(--surface-rgb), 0.88);
  color: var(--text);
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  line-height: 1;
}

.icon-action:hover {
  transform: none;
  box-shadow: none;
  opacity: 0.85;
}

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

.hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

button {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fdf7ee;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(139, 77, 44, 0.22);
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(139, 77, 44, 0.28);
}

button.secondary {
  background: #f4e3d7;
  color: var(--text);
  box-shadow: none;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  border-radius: 26px;
  padding: 0;
  background: transparent;
  transition: background 260ms ease, padding 260ms ease, box-shadow 260ms ease;
}

body.has-poem-theme .workspace {
  padding: 14px;
  background: var(--poem-surface);
  box-shadow: inset 0 0 0 1px var(--poem-border, transparent);
}

.workspace.view-writing-only,
.workspace.view-analysis-only {
  grid-template-columns: minmax(0, 1fr);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  overflow: hidden;
  min-height: 60vh;
}

.input-panel {
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid rgba(53, 35, 18, 0.08);
}

.panel-header span {
  color: var(--muted);
  font-size: 0.88rem;
}

.panel-header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  white-space: normal;
  overflow: visible;
  max-width: none;
  margin-left: auto;
}

.poem-panel-title-input {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font: inherit;
  line-height: 0.95;
  font-size: 1.5rem;
  font-weight: 700;
  padding: 0.08rem 0.25rem;
  border-radius: 8px;
  min-width: 260px;
  max-width: 100%;
  width: 100%;
}

.poem-panel-title-input:focus {
  outline: none;
  border-color: rgba(49, 92, 102, 0.35);
  background: rgba(var(--surface-rgb), 0.62);
}

.input-panel textarea {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  border: 0;
  outline: none;
  resize: vertical;
  padding: 8px 10px 10px;
  color: var(--text);
  background: transparent;
  font-size: calc(var(--verse-font-size) * var(--user-font-scale));
  line-height: var(--verse-line-height);
  font-family: inherit;
}

.input-memory-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(53, 35, 18, 0.08);
  overflow-x: hidden;
}

.input-memory-bar .format-action {
  min-width: 0;
}

.input-memory-bar label {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.input-memory-bar input,
.input-memory-bar select {
  border: 1px solid rgba(53, 35, 18, 0.18);
  border-radius: 8px;
  padding: 0.3rem 0.45rem;
  background: rgba(var(--surface-rgb), 0.92);
}

.input-memory-bar select {
  min-width: 180px;
}

#editPoemNameInput,
#editPoemVersionInput {
  min-width: 180px;
}

.saved-versions-panel {
  display: grid;
  gap: 8px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid rgba(53, 35, 18, 0.08);
  background: rgba(var(--surface-rgb), 0.22);
}

.saved-versions-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.8rem;
}

.saved-versions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  flex: 1 1 auto;
  max-height: min(80vh, 900px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable both-edges;
  padding-bottom: 8px;
  padding-right: 6px;
}

.poem-tree-node {
  flex-shrink: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--poem-accent-soft-2, rgba(53, 35, 18, 0.12));
  border-radius: 12px;
  background:
    linear-gradient(var(--poem-accent-soft, transparent), var(--poem-accent-soft, transparent)),
    rgba(var(--surface-rgb), 0.82);
  overflow: hidden;
  transition: background 220ms ease, border-color 220ms ease;
}

.poem-tree-node[open] {
  border-color: var(--poem-accent-soft-2, rgba(49, 92, 102, 0.32));
}

.poem-tree-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  min-height: 66px;
  min-width: 0;
}

.poem-tree-summary::-webkit-details-marker {
  display: none;
}

.poem-tree-heading {
  font-weight: 800;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.poem-tree-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid rgba(53, 35, 18, 0.16);
  color: var(--muted);
  font-size: 1.02rem;
  margin-left: 2px;
  line-height: 1;
}

.poem-tree-node[open] .poem-tree-indicator {
  color: var(--accent-2);
  transform: rotate(180deg);
}

.poem-title-input {
  border: 1px solid rgba(53, 35, 18, 0.12);
  border-radius: 999px;
  background: rgba(var(--surface-rgb), 0.9);
  padding: 0.28rem 0.62rem;
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--text);
  min-width: 180px;
  max-width: none;
  width: auto;
  flex: 1 1 260px;
}

.poem-title-input:focus {
  outline: none;
  border-color: rgba(49, 92, 102, 0.35);
}

.poem-select-all {
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  margin: 0;
  border-radius: 7px;
  cursor: pointer;
  accent-color: var(--accent-2);
}

.poem-tree-count {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  flex: 0 0 auto;
}

.poem-tree-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-left: auto;
  flex: 0 1 auto;
  justify-content: flex-end;
}

.poem-tree-actions .saved-version-action {
  min-height: 38px;
  height: 38px;
  min-width: 72px;
  width: 72px;
  border-radius: 12px;
}

.poem-version-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 8px 8px;
  min-height: 0;
  max-height: min(48vh, 420px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable both-edges;
  min-width: 0;
}

.saved-version-item {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 10px;
  border: 1px solid rgba(53, 35, 18, 0.12);
  background: rgba(var(--surface-rgb), 0.84);
}

.saved-version-item.is-active {
  border-color: rgba(49, 92, 102, 0.3);
  background: rgba(49, 92, 102, 0.08);
}

.saved-version-item input[type="checkbox"] {
  margin: 0;
  accent-color: var(--accent-2);
}

.saved-version-text {
  min-width: 0;
  display: grid;
  gap: 2px;
  flex: 1 1 auto;
  overflow: hidden;
}

.saved-version-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  align-items: center;
}

.saved-version-action {
  min-height: 34px;
  height: 34px;
  min-width: 68px;
  width: 68px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  align-self: auto;
  white-space: nowrap;
}

.saved-version-action.logo-action {
  width: 68px;
  min-width: 68px;
  padding: 0 8px;
}

.saved-version-action.is-danger {
  min-width: 68px;
  width: 68px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
}

.version-manager-inline button,
.saved-version-action,
.poem-tree-actions button {
  border-radius: 10px;
}

#editSelectors {
  color: #d2a200;
  font-size: 1.05rem;
}

#editSelectors:hover,
#editSelectors:focus-visible {
  color: #b78c00;
}

.saved-versions-list,
.poem-version-list {
  scrollbar-width: thin;
  scrollbar-color: rgba(49, 92, 102, 0.42) rgba(49, 92, 102, 0.08);
}

.saved-versions-list::-webkit-scrollbar,
.poem-version-list::-webkit-scrollbar {
  width: 9px;
}

.saved-versions-list::-webkit-scrollbar-track,
.poem-version-list::-webkit-scrollbar-track {
  background: rgba(49, 92, 102, 0.08);
  border-radius: 999px;
}

.saved-versions-list::-webkit-scrollbar-thumb,
.poem-version-list::-webkit-scrollbar-thumb {
  background: rgba(49, 92, 102, 0.42);
  border-radius: 999px;
}

.version-manager-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: end;
}

.version-manager-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.version-manager-picker select {
  width: 100%;
  border: 1px solid rgba(53, 35, 18, 0.18);
  border-radius: 10px;
  padding: 0.42rem 0.55rem;
  background: rgb(var(--surface-rgb));
}

.version-manager-actions--inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  grid-column: 1 / -1;
}

.saved-version-main {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  min-width: 0;
}

.saved-version-label-input {
  border: 1px solid rgba(49, 92, 102, 0.22);
  border-radius: 999px;
  background: rgba(49, 92, 102, 0.08);
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.14rem 0.5rem;
  min-width: 0;
  max-width: 100%;
}

.saved-version-label-input:focus {
  outline: none;
  border-color: rgba(49, 92, 102, 0.45);
  background: rgba(var(--surface-rgb), 0.98);
}

.saved-version-label {
  display: inline-flex;
  align-items: center;
  padding: 0.14rem 0.44rem;
  border-radius: 999px;
  border: 1px solid rgba(49, 92, 102, 0.24);
  background: rgba(49, 92, 102, 0.1);
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 800;
}

.saved-version-meta {
  color: var(--muted);
  font-size: 0.72rem;
}

.saved-version-kind {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
}

.version-manager-inline {
  width: 100%;
  min-height: 0;
  min-width: 0;
  border-radius: 16px;
  border: 1px solid var(--poem-border, rgba(53, 35, 18, 0.2));
  background:
    linear-gradient(var(--poem-surface-strong, transparent), var(--poem-surface-strong, transparent)),
    linear-gradient(135deg, rgba(244, 227, 210, 0.7) 0%, rgba(222, 206, 190, 0.5) 100%);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: background 260ms ease, border-color 260ms ease;
}

.version-manager-inline-status-row {
  display: flex;
  justify-content: flex-end;
}

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

.version-manager-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid rgba(53, 35, 18, 0.15);
  color: var(--muted);
  background: rgba(53, 35, 18, 0.08);
}

.version-manager-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}

.version-manager-status.is-open {
  color: #23643a;
  border-color: rgba(35, 100, 58, 0.32);
  background: rgba(35, 100, 58, 0.12);
}

.version-manager-status.is-closed {
  color: #7a5e23;
  border-color: rgba(122, 94, 35, 0.3);
  background: rgba(122, 94, 35, 0.1);
}

.version-modal-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 12px 12px;
  min-height: 0;
  min-width: 0;
  flex: 1 1 auto;
  overflow: visible;
  background: rgba(248, 240, 232, 0.38);
}

.color-picker-swatch-default {
  background: linear-gradient(145deg, rgba(49, 92, 102, 0.16), rgba(49, 92, 102, 0.07));
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 800;
  border-style: dashed;
}

/* Poem node color palette — 6 cycling hues */
.poem-color-0 .poem-tree-summary { background: rgba(234, 245, 250, 0.9); border-bottom: 2px solid rgba(49, 130, 160, 0.25); }
.poem-color-0 { border-color: rgba(49, 130, 160, 0.28); }
.poem-color-0 .poem-version-list { background: rgba(234, 245, 250, 0.35); }

.poem-color-1 .poem-tree-summary { background: rgba(244, 240, 255, 0.9); border-bottom: 2px solid rgba(110, 85, 200, 0.22); }
.poem-color-1 { border-color: rgba(110, 85, 200, 0.25); }
.poem-color-1 .poem-version-list { background: rgba(244, 240, 255, 0.35); }

.poem-color-2 .poem-tree-summary { background: rgba(235, 248, 240, 0.9); border-bottom: 2px solid rgba(35, 140, 75, 0.22); }
.poem-color-2 { border-color: rgba(35, 140, 75, 0.25); }
.poem-color-2 .poem-version-list { background: rgba(235, 248, 240, 0.35); }

.poem-color-3 .poem-tree-summary { background: rgba(255, 246, 232, 0.9); border-bottom: 2px solid rgba(200, 120, 20, 0.25); }
.poem-color-3 { border-color: rgba(200, 120, 20, 0.28); }
.poem-color-3 .poem-version-list { background: rgba(255, 246, 232, 0.35); }

.poem-color-4 .poem-tree-summary { background: rgba(255, 238, 240, 0.9); border-bottom: 2px solid rgba(195, 55, 80, 0.22); }
.poem-color-4 { border-color: rgba(195, 55, 80, 0.25); }
.poem-color-4 .poem-version-list { background: rgba(255, 238, 240, 0.35); }

.poem-color-5 .poem-tree-summary { background: rgba(240, 252, 250, 0.9); border-bottom: 2px solid rgba(20, 150, 140, 0.22); }
.poem-color-5 { border-color: rgba(20, 150, 140, 0.25); }
.poem-color-5 .poem-version-list { background: rgba(240, 252, 250, 0.35); }

.poem-color-custom {
  border-color: var(--poem-accent-soft-2, rgba(49, 92, 102, 0.28));
}

.poem-color-custom .poem-tree-summary {
  background: var(--poem-accent-soft, rgba(49, 92, 102, 0.12));
  border-bottom: 2px solid var(--poem-accent-soft-2, rgba(49, 92, 102, 0.25));
}

.poem-color-custom .poem-version-list {
  background: var(--poem-accent-soft-3, rgba(49, 92, 102, 0.08));
}

.version-modal-actions {
  display: grid;
  flex: 0 0 auto;
  gap: 8px;
  overflow: visible;
}

.version-modal-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.version-search-input {
  flex: 0 0 auto;
}

.version-modal-actions > button {
  min-width: 120px;
  width: 120px;
  min-height: 38px;
  height: 38px;
  border-radius: 12px;
}

#selectAllVersions {
  min-width: 176px;
  width: auto;
}

#deleteSelectedVersions {
  min-width: 220px;
  width: auto;
}

#newPoemManager {
  min-width: 160px;
  width: auto;
}

#defaultPoemColorBtn {
  min-width: 210px;
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.default-color-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(53, 35, 18, 0.28);
  box-shadow: inset 0 0 0 2px rgba(var(--surface-rgb), 0.55);
  background: transparent;
  flex: 0 0 auto;
}

.version-search-input {
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(53, 35, 18, 0.2);
  border-radius: 12px;
  background: rgba(var(--surface-rgb), 0.95);
  padding: 0.5rem 0.72rem;
  font-size: 0.9rem;
}

.version-search-input:focus {
  outline: none;
  border-color: rgba(49, 92, 102, 0.45);
  box-shadow: 0 0 0 2px rgba(49, 92, 102, 0.15);
}

.version-label-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.version-label-row input {
  flex: 1 1 280px;
  min-width: 200px;
  border: 1px solid rgba(53, 35, 18, 0.18);
  border-radius: 10px;
  padding: 0.35rem 0.5rem;
  background: rgb(var(--surface-rgb));
}

.tiny-icon-action {
  width: 24px;
  min-width: 24px;
  height: 24px;
  min-height: 24px;
  font-size: 0.75rem;
}

.input-panel textarea::placeholder {
  color: rgba(112, 95, 80, 0.72);
}

.analysis-output {
  padding: 4px 6px 8px;
}

.analysis-text-output {
  margin: 0;
  padding: 10px 12px;
  min-height: clamp(220px, calc(46vh - 84px), 560px);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border-top: 1px solid rgba(53, 35, 18, 0.08);
  background: rgba(var(--surface-rgb), 0.68);
  font-family: "OpenDyslexic", "OpenDyslexicAlta", "Lexend", "Atkinson Hyperlegible", system-ui, sans-serif;
  font-size: calc(0.82rem * var(--user-font-scale));
  line-height: 1.45;
}

.hidden {
  display: none;
}

.empty-state {
  min-height: clamp(220px, calc(46vh - 84px), 560px);
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  padding: 24px;
  line-height: 1.6;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stat {
  background: rgba(var(--surface-rgb), 0.75);
  border: 1px solid rgba(53, 35, 18, 0.08);
  border-radius: 20px;
  padding: 14px 16px;
}

.stat-label {
  color: var(--muted);
  font-size: 0.82rem;
  display: block;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.line-card {
  padding: 14px 16px 16px;
  border-radius: 22px;
  background: rgba(var(--surface-rgb), 0.82);
  border: 1px solid rgba(53, 35, 18, 0.08);
  margin-top: 12px;
}

.clean-analysis {
  margin-top: 2px;
  padding: 0;
}

.analysis-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.poem-block {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(244, 227, 215, 0.56);
  border: 1px solid rgba(53, 35, 18, 0.08);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

.analysis-lines {
  margin-top: 2px;
  display: flex;
  flex-direction: column;
}

.analysis-line-wrap {
  padding: 0;
}

.stanza-gap {
  height: 10px;
  margin: 2px 0 4px;
  border-top: 1px solid rgba(53, 35, 18, 0.08);
}

.analysis-row {
  position: relative;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content max-content max-content max-content max-content;
  gap: 4px;
  align-items: start;
  padding: 2px 0 4px;
  border: 0;
  border-bottom: 1px solid rgba(53, 35, 18, 0.08);
  border-radius: 0;
  background: transparent;
}

.analysis-col {
  min-width: 0;
}

.verse-index-col {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  min-width: 2ch;
  text-align: right;
  align-self: start;
  padding-top: 0.12rem;
}

.visual-col {
  font-family: inherit;
  font-size: calc(var(--verse-font-size) * var(--user-font-scale));
}

.visual-col strong {
  font-weight: 800;
  color: var(--accent);
}

.count-col,
.stress-col,
.rhyme-col,
.scheme-col,
.advanced-col {
  color: var(--accent-2);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  align-self: start;
  justify-self: end;
  text-align: right;
}

.scheme-col:empty {
  display: none;
}

.count-col {
  width: auto;
  min-width: 0;
  text-align: right;
  border-left: 1px solid rgba(53, 35, 18, 0.08);
  font-size: 0.96rem;
}

.stress-col {
  white-space: normal;
  line-height: 2.2;
}

.analysis-row .visual-col {
  justify-self: stretch;
}

.rhyme-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.42rem;
  border-radius: 999px;
  border: 1px solid rgba(49, 92, 102, 0.24);
  background: rgba(49, 92, 102, 0.1);
  color: var(--accent-2);
  font-weight: 800;
  font-size: 0.68rem;
  letter-spacing: 0.01em;
}

.rhyme-tone-0 { color: #315c66; background: rgba(49, 92, 102, 0.12); border-color: rgba(49, 92, 102, 0.28); }
.rhyme-tone-1 { color: #8b4d2c; background: rgba(139, 77, 44, 0.12); border-color: rgba(139, 77, 44, 0.24); }
.rhyme-tone-2 { color: #1f7a35; background: rgba(33, 161, 85, 0.12); border-color: rgba(33, 161, 85, 0.24); }
.rhyme-tone-3 { color: #7b4ab7; background: rgba(123, 74, 183, 0.12); border-color: rgba(123, 74, 183, 0.24); }
.rhyme-tone-4 { color: #9f1f2b; background: rgba(214, 59, 72, 0.12); border-color: rgba(214, 59, 72, 0.24); }
.rhyme-tone-5 { color: #8f6f18; background: rgba(230, 184, 45, 0.14); border-color: rgba(230, 184, 45, 0.28); }

/* Paleta cálida */
.rhyme-warm-0 { color: #b52020; background: rgba(181, 32, 32, 0.11); border-color: rgba(181, 32, 32, 0.26); }
.rhyme-warm-1 { color: #c4620a; background: rgba(196, 98, 10, 0.12); border-color: rgba(196, 98, 10, 0.26); }
.rhyme-warm-2 { color: #a07a00; background: rgba(200, 160, 0, 0.13); border-color: rgba(200, 160, 0, 0.28); }
.rhyme-warm-3 { color: #8b3a3a; background: rgba(139, 58, 58, 0.12); border-color: rgba(139, 58, 58, 0.24); }
.rhyme-warm-4 { color: #9b5000; background: rgba(155, 80, 0, 0.12); border-color: rgba(155, 80, 0, 0.26); }
.rhyme-warm-5 { color: #7c2a50; background: rgba(124, 42, 80, 0.12); border-color: rgba(124, 42, 80, 0.24); }

/* Paleta fría */
.rhyme-cool-0 { color: #1a5da8; background: rgba(26, 93, 168, 0.11); border-color: rgba(26, 93, 168, 0.26); }
.rhyme-cool-1 { color: #5530a8; background: rgba(85, 48, 168, 0.11); border-color: rgba(85, 48, 168, 0.24); }
.rhyme-cool-2 { color: #0e7a7a; background: rgba(14, 122, 122, 0.11); border-color: rgba(14, 122, 122, 0.24); }
.rhyme-cool-3 { color: #295c8a; background: rgba(41, 92, 138, 0.11); border-color: rgba(41, 92, 138, 0.24); }
.rhyme-cool-4 { color: #3a2aa0; background: rgba(58, 42, 160, 0.11); border-color: rgba(58, 42, 160, 0.24); }
.rhyme-cool-5 { color: #0a6b55; background: rgba(10, 107, 85, 0.11); border-color: rgba(10, 107, 85, 0.24); }

/* Paleta neutro */
.rhyme-neutral-0 { color: #4a4a4a; background: rgba(74, 74, 74, 0.10); border-color: rgba(74, 74, 74, 0.22); }
.rhyme-neutral-1 { color: #5c4a36; background: rgba(92, 74, 54, 0.10); border-color: rgba(92, 74, 54, 0.22); }
.rhyme-neutral-2 { color: #3d5246; background: rgba(61, 82, 70, 0.10); border-color: rgba(61, 82, 70, 0.22); }
.rhyme-neutral-3 { color: #5a4a6a; background: rgba(90, 74, 106, 0.10); border-color: rgba(90, 74, 106, 0.22); }
.rhyme-neutral-4 { color: #6a3030; background: rgba(106, 48, 48, 0.10); border-color: rgba(106, 48, 48, 0.22); }
.rhyme-neutral-5 { color: #3d3d3d; background: rgba(61, 61, 61, 0.10); border-color: rgba(61, 61, 61, 0.20); }

/* Round color button for poem nodes */
.poem-tree-actions .saved-version-action.poem-color-btn,
.poem-color-btn {
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 50% !important;
  border: 2px solid rgba(53, 35, 18, 0.2);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55), 0 1px 3px rgba(58, 37, 20, 0.18);
  font-size: 0;
  cursor: pointer;
  flex: 0 0 auto;
  align-self: center;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.poem-color-btn:hover,
.poem-color-btn:focus-visible {
  transform: scale(1.08);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.7), 0 2px 6px rgba(58, 37, 20, 0.28);
}

.rhyme-color-btn {
  width: 16px;
  min-width: 16px;
  height: 16px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(53, 35, 18, 0.16);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.rhyme-color-btn:hover,
.rhyme-color-btn:focus-visible {
  transform: scale(1.05);
}

/* Color picker modal */
.color-picker-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.color-picker-modal.is-open {
  display: flex;
}

.color-picker-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 22, 12, 0.5);
  backdrop-filter: blur(2px);
}

.color-picker-content {
  position: relative;
  z-index: 1;
  width: min(360px, 100%);
  background: linear-gradient(180deg, #fdf7ee 0%, #f6ecdd 100%);
  border-radius: 18px;
  border: 1px solid rgba(53, 35, 18, 0.16);
  box-shadow: 0 24px 60px rgba(38, 24, 10, 0.32);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.color-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.color-picker-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text);
}

.color-picker-swatches {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}

.color-picker-swatch {
  aspect-ratio: 1 / 1;
  width: 100%;
  min-width: 0;
  padding: 0;
  border-radius: 10px;
  border: 2px solid rgba(53, 35, 18, 0.14);
  cursor: pointer;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.color-picker-swatch:hover,
.color-picker-swatch:focus-visible {
  transform: scale(1.08);
}

.color-picker-swatch.is-selected {
  border-color: #1f1a15;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.75), 0 0 0 3px rgba(31, 26, 21, 0.55);
}

.color-picker-custom-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

.color-picker-custom-row input[type="color"] {
  width: 44px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(53, 35, 18, 0.18);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.color-picker-preview {
  margin-left: auto;
  min-width: 92px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(53, 35, 18, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.color-picker-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.color-picker-actions button {
  min-width: 96px;
}

/* Version preview panel */
.version-preview-panel {
  flex: 0 0 100%;
  width: 100%;
  margin-top: 8px;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid rgba(53, 35, 18, 0.16);
  background: linear-gradient(180deg, rgba(248, 240, 228, 0.98) 0%, rgba(241, 230, 217, 0.9) 100%);
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.02rem;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 360px;
  overflow-y: auto;
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 8px 22px rgba(58, 37, 20, 0.08);
}

.preview-action.is-active {
  color: var(--accent-2);
  border-color: rgba(49, 92, 102, 0.4);
  background: rgba(49, 92, 102, 0.1);
}

.saved-version-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 10px;
  border: 1px solid rgba(53, 35, 18, 0.12);
  background: rgba(var(--surface-rgb), 0.84);
}

.saved-version-item .version-preview-panel {
  flex-basis: 100%;
}

.poemtype-chip,
.poemtype-badge,
.scheme-chip,
.scheme-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.42rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  border: 1px solid rgba(53, 35, 18, 0.16);
}

.poemtype-chip.is-valid,
.poemtype-badge.is-valid,
.scheme-chip.is-valid,
.scheme-badge.is-valid {
  color: #1f7a35;
  background: rgba(33, 161, 85, 0.14);
  border-color: rgba(33, 161, 85, 0.24);
}

.poemtype-chip.is-invalid,
.poemtype-badge.is-invalid,
.scheme-chip.is-invalid,
.scheme-badge.is-invalid {
  color: #9f1f2b;
  background: rgba(214, 59, 72, 0.16);
  border-color: rgba(214, 59, 72, 0.26);
}

.scheme-chip.is-warning,
.scheme-badge.is-warning {
  color: #8f6f18;
  background: rgba(230, 184, 45, 0.18);
  border-color: rgba(230, 184, 45, 0.28);
}

.hover-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 4px;
  border-radius: 999px;
  border: 1px solid rgba(230, 184, 45, 0.55);
  background: rgba(255, 248, 214, 0.88);
  color: #8f6f18;
  font-size: 0.64rem;
  font-weight: 800;
  cursor: help;
}

.info-click {
  cursor: pointer;
}

.info-click:hover {
  transform: translateY(-1px);
}

.aguda-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 18px;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid rgba(159, 31, 43, 0.28);
  background: rgba(214, 59, 72, 0.12);
  color: #9f1f2b;
  font-size: 0.64rem;
  font-weight: 800;
}

.jump-to-verse {
  cursor: pointer;
}

.jump-to-verse:focus-visible {
  outline: 1px solid rgba(49, 92, 102, 0.6);
  outline-offset: 1px;
}


.vpos {
  font-weight: 800;
  padding: 0 2px;
  border-radius: 6px;
}

.vpos.green {
  color: #1f7a35;
  background: rgba(33, 161, 85, 0.14);
}

.vpos.yellow {
  color: #8f6f18;
  background: rgba(230, 184, 45, 0.2);
}

.vpos.red {
  color: #9f1f2b;
  background: rgba(214, 59, 72, 0.16);
}

.hemistich-marker {
  color: var(--accent-2);
  font-weight: 700;
}

.sinalefa-toggle {
  min-width: 42px;
  min-height: 24px;
  border-radius: 999px;
  border: 1px solid rgba(53, 35, 18, 0.25);
  background: rgba(var(--surface-rgb), 0.92);
  color: var(--text);
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0 8px;
  margin: 0 3px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  vertical-align: middle;
}

.sinalefa-toggle.is-active {
  border-color: rgba(31, 122, 53, 0.5);
  background: rgba(33, 161, 85, 0.16);
}

.sinalefa-toggle.is-warning {
  border-color: rgba(230, 184, 45, 0.68);
  background: rgba(230, 184, 45, 0.16);
}

.sinalefa-toggle.is-inactive {
  border-color: rgba(160, 38, 45, 0.45);
  background: rgba(214, 59, 72, 0.08);
}

.sinalefa-toggle:hover {
  transform: none;
  box-shadow: none;
  opacity: 0.8;
}

.sinalefa-toggle.is-locked {
  opacity: 0.45;
  cursor: default;
}

.invalid-hemi {
  color: #a0262d;
  font-weight: 700;
}

.line-advanced {
  margin: 0;
  padding: 0;
  border: 0;
  position: relative;
}

.line-advanced summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  list-style: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(53, 35, 18, 0.16);
  border-radius: 999px;
  background: rgba(var(--surface-rgb), 0.82);
}

.line-advanced summary::-webkit-details-marker {
  display: none;
}

.line-advanced summary svg {
  width: 16px;
  height: 16px;
}

.line-advanced summary svg path {
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  fill: none;
}

.line-advanced-grid {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(53, 35, 18, 0.12);
  border-radius: 12px;
  background: rgb(var(--surface-rgb));
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 4;
  width: min(460px, 78vw);
  box-shadow: 0 14px 32px rgba(58, 37, 20, 0.12);
}

.line-advanced-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}

.line-advanced-grid input,
.line-advanced-grid select {
  border: 1px solid rgba(53, 35, 18, 0.18);
  border-radius: 8px;
  padding: 0.35rem 0.45rem;
}

.line-advanced[open] summary {
  background: rgba(49, 92, 102, 0.12);
  color: var(--accent-2);
}

.app-footer {
  margin-top: 18px;
  padding: 8px 0 0;
  border-top: 1px solid rgba(53, 35, 18, 0.12);
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
}

.app-footer a {
  color: var(--accent-2);
  font-weight: 700;
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

.app-toast {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 20;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(53, 35, 18, 0.2);
  background: rgba(var(--surface-rgb), 0.95);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(58, 37, 20, 0.16);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.app-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.app-toast.is-success {
  border-color: rgba(33, 161, 85, 0.3);
  background: rgba(236, 252, 243, 0.98);
  color: #1f7a35;
}

.app-toast.is-warning {
  border-color: rgba(230, 184, 45, 0.44);
  background: rgba(255, 248, 224, 0.98);
  color: #8f6f18;
}

.app-toast.is-error {
  border-color: rgba(214, 59, 72, 0.38);
  background: rgba(255, 236, 239, 0.98);
  color: #9f1f2b;
}

.line-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 10px;
}

.line-text {
  margin: 0 0 12px;
  font-size: 1.02rem;
  line-height: 1.6;
}

.words {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.word {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.word-name {
  min-width: 7ch;
  font-weight: 700;
  color: var(--accent-2);
}

.syllables {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0;
  line-height: 1.8;
}

.syllable {
  display: inline-flex;
  padding: 0 3px;
  border-radius: 8px;
}

.syllable + .syllable::before {
  content: "-";
  color: rgba(112, 95, 80, 0.75);
  margin-right: 1px;
}

.syllable.stress {
  font-weight: 800;
  color: var(--accent);
  background: rgba(139, 77, 44, 0.1);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  background: rgba(49, 92, 102, 0.12);
  color: var(--accent-2);
}

.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;
}

@media (max-width: 920px) {
  .app-shell {
    width: min(100%, calc(100% - 12px));
    padding: 16px 0 24px;
  }

  .hero {
    flex-direction: column;
    align-items: start;
    gap: 12px;
    margin-bottom: 16px;
  }

  .eyebrow {
    margin-bottom: 6px;
    font-size: 0.7rem;
    letter-spacing: 0.14em;
  }

  h1 {
    font-size: clamp(2.1rem, 9vw, 3.4rem);
    line-height: 0.98;
  }

  .lede {
    margin-top: 10px;
    font-size: 0.94rem;
  }

  .controls {
    margin-bottom: 12px;
  }

  .quick-controls {
    margin-top: 8px;
    padding: 8px;
  }

  .quick-control-group {
    width: 100%;
    flex-wrap: wrap;
  }

  .quick-control-group input[type="range"] {
    flex: 1 1 160px;
    min-width: 120px;
  }

  .quick-control-group select {
    width: 100%;
  }

  .config-shell {
    padding: 10px 10px 12px;
    border-radius: 16px;
  }

  .config-shell > summary {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    font-size: 0.9rem;
  }

  .summary-hint {
    width: 100%;
    flex-wrap: wrap;
    gap: 6px;
    line-height: 1.35;
  }

  .guide-popover {
    left: 0;
    right: auto;
    width: min(320px, calc(100vw - 28px));
  }

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

  .config-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .panel,
  .input-panel textarea,
  .empty-state {
    min-height: auto;
  }

  .panel {
    border-radius: 22px;
  }

  .panel-header {
    padding: 14px 14px 10px;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .panel-header-meta {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .top-action-group {
    width: auto;
    justify-content: flex-end;
  }

  .poem-panel-title-input {
    min-width: 0;
    max-width: 100%;
    font-size: 1.1rem;
    padding: 0.02rem 0.08rem;
  }

  .input-memory-bar {
    padding: 8px;
    flex-wrap: wrap;
    overflow-x: hidden;
  }

  .saved-versions-panel {
    padding: 8px;
  }

  .version-manager-inline {
    width: 100%;
    min-height: 0;
    border-radius: 14px;
  }

  .version-label-row input {
    min-width: 0;
    width: 100%;
  }

  .saved-versions-list {
    max-height: none;
  }

  .poem-tree-summary {
    min-height: 58px;
    padding: 8px 10px;
    gap: 8px;
  }

  .poem-select-all {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
  }

  .poem-tree-actions {
    gap: 6px;
  }

  .poem-tree-actions .saved-version-action {
    min-height: 34px;
    height: 34px;
    min-width: 66px;
    width: 66px;
  }

  .poem-tree-actions .saved-version-action.poem-color-btn {
    min-width: 32px;
    width: 32px;
    height: 32px;
    min-height: 32px;
  }

  #deleteSelectedVersions {
    min-width: 190px;
  }

  .poem-tree-indicator {
    width: 28px;
    height: 28px;
    font-size: 0.94rem;
  }

  .input-memory-bar select,
  .input-memory-bar input {
    width: auto;
    min-width: 130px;
    flex: 0 0 auto;
    font-size: 0.82rem;
    padding: 0.25rem 0.38rem;
  }

  .poem-title-input {
    min-width: 130px;
    max-width: none;
  }

  .input-memory-bar label {
    width: auto;
    font-size: 0.72rem;
  }

  .saved-version-label-input {
    min-width: 0;
    max-width: 100%;
    width: 100%;
  }

  .input-panel textarea {
    min-height: 34vh;
    padding: 9px 10px 10px;
    font-size: 0.8rem;
    line-height: 1.34;
  }

  .analysis-output {
    padding: 2px 4px 6px;
  }

  .analysis-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 10px 12px 12px;
    border-bottom: 0;
    border-radius: 18px;
    background: rgba(var(--surface-rgb), 0.66);
    margin: 0 4px 8px;
  }

  .analysis-col {
    width: auto;
  }

  .verse-index-col {
    min-width: 2.4ch;
    font-size: 0.78rem;
  }

  .visual-col {
    flex: 1 1 100%;
    font-size: 0.86rem;
    line-height: 1.45;
  }

  .stress-col,
  .rhyme-col,
  .scheme-col,
  .advanced-col,
  .count-col {
    justify-self: start;
    text-align: left;
    width: auto;
    white-space: normal;
  }

  .stress-col,
  .rhyme-col,
  .scheme-col,
  .advanced-col {
    font-size: 0.8rem;
    white-space: nowrap;
  }

  .count-col {
    border-left: 0;
    padding-left: 0;
    text-align: left;
    font-size: 0.92rem;
    min-width: 44px;
  }

  .analysis-row .line-advanced summary {
    width: 30px;
    height: 30px;
  }

  .line-advanced-grid {
    width: 100%;
    max-width: 100%;
  }

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

  .line-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .line-text {
    font-size: 0.98rem;
    line-height: 1.55;
  }

  .badge {
    font-size: 0.72rem;
    padding: 0.22rem 0.6rem;
  }

  .app-footer {
    margin-top: 14px;
    font-size: 0.74rem;
  }
}

@media (max-width: 560px) {
  button {
    padding: 0.78rem 1rem;
    font-size: 0.93rem;
  }

  .config-group {
    padding: 8px;
    border-radius: 14px;
  }

  .config-body {
    gap: 7px;
  }

  .config-body label {
    font-size: 0.74rem;
  }

  .config-body input,
  .config-body select {
    font-size: 0.82rem;
    padding: 0.28rem 0.42rem;
  }

  .hint {
    font-size: 0.74rem;
  }

  .compact-action,
  .secondary,
  .icon-action {
    font-size: 0.8rem;
  }

  .input-memory-bar select,
  .input-memory-bar input,
  .config-body input,
  .config-body select {
    border-radius: 9px;
  }

  .sinalefa-toggle {
    min-width: 38px;
    min-height: 22px;
    padding: 0 6px;
    font-size: 0.66rem;
  }

  .line-advanced-grid {
    margin-top: 6px;
    padding: 8px;
    gap: 6px;
  }

  .summary-grid {
    gap: 8px;
  }

  .stat {
    padding: 12px 14px;
  }

  .stat-value {
    font-size: 1.35rem;
  }

  .color-picker-content {
    width: 100%;
    padding: 14px;
    gap: 14px;
    border-radius: 16px;
  }

  .color-picker-swatches {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }

  .color-picker-custom-row {
    flex-wrap: wrap;
  }

  .color-picker-preview {
    margin-left: 0;
    flex: 1 1 100%;
  }

  .color-picker-actions button {
    flex: 1 1 auto;
    min-width: 0;
  }
}
.lookup-collapsible-section summary::-webkit-details-marker {
  display: none;
}
.lookup-collapsible-section summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Indicador de estado: Cerrado por defecto */
.lookup-collapsible-section summary::before {
  content: "►";
  font-size: 0.7rem;
  color: var(--text-muted, #6b7280);
  transition: transform 0.2s ease;
}

/* Indicador de estado: Abierto */
.lookup-collapsible-section[open] summary::before {
  content: "▼";
}