:root {
  --bg: #f7f4ef;
  --paper: #ffffff;
  --paper-soft: #fbf8f3;
  --paper-strong: #ffffff;
  --ink: #171412;
  --muted: #746a62;
  --line: rgba(35, 28, 23, 0.1);
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --accent-dark: #1d4ed8;
  --warm: #f97316;
  --shadow: 0 18px 45px rgba(28, 24, 20, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 0%, rgba(37, 99, 235, 0.1), transparent 28%),
    linear-gradient(180deg, #fffdfa 0%, var(--bg) 48%, #eee7dc 100%);
  color: var(--ink);
  font-family: "Manrope", sans-serif;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(480px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border-radius: 28px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0;
  font-family: "Fraunces", serif;
}

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

button {
  cursor: pointer;
  border: none;
  border-radius: 999px;
  min-height: 46px;
  padding: 0.86rem 1.15rem;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

@media (hover: hover) {
  button:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 20px rgba(37, 99, 235, 0.16);
    background: var(--accent-dark);
  }
}

button:disabled {
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  background: #b8a89f;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.92rem 1rem;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
}

textarea {
  resize: vertical;
  min-height: 8rem;
}

.page-shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 18px 14px 36px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.hero h1,
.settings-form h2 {
  font-family: "Fraunces", serif;
}

.hero h1 {
  margin: 0.16rem 0 0;
  font-size: clamp(1.72rem, 7vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.hero-copy {
  min-width: 0;
}

.eyebrow,
.card-label,
.sentence-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.75rem;
  color: var(--muted);
}

.hero-meta,
.muted-text,
.muted-block,
.field-hint,
.analysis-note {
  color: var(--muted);
}

.hero-meta {
  margin: 0.72rem 0 0;
  line-height: 1.6;
}

.content-stack {
  display: grid;
  gap: 12px;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.reading-card {
  padding: 18px;
}

.reading-card {
  position: relative;
}

.selector-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.progress-card {
  min-width: 0;
  padding: 14px 16px;
  border-radius: 20px;
  background: linear-gradient(180deg, var(--accent-soft), rgba(255, 255, 255, 0.85));
}

.progress-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.progress-value {
  margin-top: 6px;
  font-size: 1rem;
  font-weight: 700;
}

.nav-buttons,
.mode-toggle,
.toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.reading-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.mode-button,
.ghost-button {
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink);
  border: 1px solid var(--line);
}

.menu-button,
.tool-button {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  font-size: 1.05rem;
  font-weight: 700;
}

.mode-toggle,
.subview-toggle,
.settings-tabs {
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper-soft);
}

.mode-button,
.subview-button,
.settings-tab {
  min-height: 40px;
  padding: 0 1rem;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  border: 0;
  box-shadow: none;
  font-weight: 800;
}

.mode-button:hover,
.subview-button:hover,
.settings-tab:hover {
  transform: none;
  box-shadow: none;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
}

.menu-button {
  background: var(--paper-soft);
  color: var(--ink);
  border: 1px solid var(--line);
}

.mode-button.active {
  background: var(--ink);
  color: #fff;
  border-color: transparent;
}

.mode-button.active:hover {
  background: var(--ink);
  color: #fff;
}

.subview-button.active,
.settings-tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(28, 24, 20, 0.07);
}

.subview-button.active:hover,
.settings-tab.active:hover {
  background: #fff;
  box-shadow: 0 8px 18px rgba(28, 24, 20, 0.07);
}

.tool-button {
  gap: 4px;
  width: auto;
  padding: 0 0.78rem;
  background: var(--accent);
  color: #fff;
}

.status-line {
  margin: 14px 0;
  padding: 0.88rem 1rem;
  border-radius: 18px;
  background: var(--paper-soft);
  color: var(--muted);
  overflow-wrap: anywhere;
}

.reading-panel {
  display: grid;
  gap: 14px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.hidden {
  display: none !important;
}

.original-text,
.simplified-text,
.sentence-text {
  font-size: 1.08rem;
  line-height: 1.82;
}

.original-reader-card {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid rgba(35, 28, 23, 0.08);
  border-radius: 24px;
  background:
    linear-gradient(90deg, rgba(249, 115, 22, 0.08), transparent 34%),
    linear-gradient(180deg, #fffdf9, #ffffff);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.reader-accent {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: var(--warm);
}

.original-text {
  padding: 0;
  color: #2a211c;
}

.speakable-word {
  display: inline;
  min-height: 0;
  padding: 0 0.08em;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  line-height: inherit;
  vertical-align: baseline;
}

.speakable-word:focus-visible {
  transform: none;
  box-shadow: none;
  background: rgba(37, 99, 235, 0.12);
  color: var(--accent-dark);
}

@media (hover: hover) {
  .speakable-word:hover {
    transform: none;
    box-shadow: none;
    background: rgba(37, 99, 235, 0.12);
    color: var(--accent-dark);
  }
}

.speakable-word.active {
  background: rgba(249, 115, 22, 0.18);
  color: #9a3412;
}

.speakable-word.selected {
  background: rgba(37, 99, 235, 0.18);
  color: var(--accent-dark);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.28) inset;
}

.speech-float-panel {
  position: fixed;
  right: max(14px, calc((100vw - 960px) / 2 + 14px));
  bottom: 86px;
  z-index: 30;
  display: grid;
  justify-items: end;
  gap: 10px;
  width: min(460px, calc(100vw - 28px));
  pointer-events: none;
}

.speech-selection-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  padding: 8px;
  border: 1px solid rgba(37, 99, 235, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.56);
  box-shadow: 0 12px 28px rgba(23, 20, 18, 0.1);
  backdrop-filter: blur(18px) saturate(1.1);
  pointer-events: auto;
}

.speech-action-button {
  min-height: 38px;
  padding: 0.55rem 0.9rem;
}

.speech-float-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 42px;
  padding: 0.68rem 0.9rem;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 14px 30px rgba(23, 20, 18, 0.18);
  pointer-events: auto;
}

.speech-float-button.active {
  transform: none;
  background: var(--accent-dark);
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.22);
}

@media (hover: hover) {
  .speech-float-button:hover {
    transform: none;
    background: var(--accent-dark);
    box-shadow: 0 14px 30px rgba(37, 99, 235, 0.22);
  }
}

.inline-speech-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  min-width: 1.9rem;
  height: 1.9rem;
  min-height: 1.9rem;
  margin-left: 0.35rem;
  padding: 0;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.12);
  color: var(--accent-dark);
  font-size: 0.9rem;
  vertical-align: middle;
}

.inline-speech-button:hover,
.inline-speech-button:focus-visible,
.inline-speech-button.active {
  transform: none;
  box-shadow: none;
  background: rgba(249, 115, 22, 0.18);
  color: #9a3412;
}

.simplified-text {
  padding: 16px;
  border-radius: 22px;
  background: linear-gradient(180deg, #eef6ff, #ffffff);
  border: 1px solid rgba(37, 99, 235, 0.12);
}

.empty-state {
  color: var(--muted);
}

.analysis-section {
  display: grid;
  gap: 14px;
}

.simplified-subview {
  min-width: 0;
}

.subview-toggle {
  display: grid;
  gap: 4px;
}

.subview-toggle.after-content {
  margin-top: 12px;
  grid-template-columns: 1fr;
  background: transparent;
  border: 0;
  padding: 0;
}

.subview-toggle.after-content .subview-button {
  background: var(--ink);
  color: #fff;
  min-height: 48px;
}

.subview-toggle.after-content .subview-button:hover {
  background: var(--ink);
  color: #fff;
}

.subview-toggle.after-content .subview-button.active {
  background: var(--ink);
  color: #fff;
  box-shadow: none;
}

.analysis-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
}

.sentence-analysis-list {
  display: grid;
  gap: 12px;
  touch-action: pan-y;
}

.sentence-carousel-controls {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 10px;
}

.sentence-carousel-controls button {
  min-height: 44px;
  padding: 0;
  border-radius: 14px;
}

.sentence-counter {
  display: grid;
  place-items: center;
  min-height: 44px;
  border-radius: 14px;
  background: var(--paper-soft);
  color: var(--muted);
  font-weight: 800;
}

.sentence-card {
  padding: 12px;
  border-radius: 20px;
  background: #fff;
  border: 1px solid var(--line);
  display: grid;
  gap: 10px;
}

.sentence-card-head {
  display: flex;
  justify-content: space-between;
}

.sentence-index {
  display: inline-flex;
  align-items: center;
  padding: 0.38rem 0.7rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 700;
}

.sentence-summary {
  display: grid;
  gap: 8px;
}

.sentence-block {
  display: grid;
  gap: 5px;
}

.sentence-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.simplified-pair {
  padding: 10px;
  border-radius: 16px;
  background: var(--paper-soft);
}

.simplified-pair {
  background: #eef6ff;
}

.sentence-text {
  margin: 0;
}

.sentence-text.simplified {
  padding-left: 0;
  border-left: 0;
  color: var(--accent-dark);
  font-weight: 700;
}

.sentence-text.translation {
  color: var(--muted);
}

.translation-toggle {
  justify-self: start;
  min-height: 36px;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  border: 1px solid var(--line);
}

.translation-toggle:hover,
.translation-toggle:focus-visible {
  transform: none;
  box-shadow: none;
  background: #fff;
}

.translation-panel {
  display: grid;
  gap: 5px;
}

.sentence-details {
  display: grid;
  gap: 10px;
}

.sentence-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.detail-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper-soft);
}

.detail-card.inset {
  padding: 12px;
}

.detail-card.full {
  width: 100%;
}

.detail-card h3 {
  margin: 0 0 8px;
  font-size: 0.9rem;
}

.mini-pill-list,
.stack-list {
  display: grid;
  gap: 8px;
}

.mini-pill {
  display: grid;
  gap: 4px;
  padding: 9px 10px;
  border-radius: 14px;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.12);
}

.mini-pill strong,
.stack-item strong {
  font-size: 0.9rem;
}

.mini-pill span,
.stack-item span {
  color: var(--ink);
}

.mini-pill em,
.stack-item em {
  color: var(--muted);
  font-style: normal;
}

.stack-item {
  display: grid;
  gap: 4px;
  padding: 9px 10px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
}

.reader-dock {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.dock-progress {
  display: grid;
  place-items: center;
  line-height: 1.2;
  color: var(--muted);
  font-size: 0.75rem;
}

.dock-progress strong {
  margin-top: 3px;
  color: var(--ink);
  font-size: 1rem;
}

.stack-item.compact {
  padding: 9px 10px;
}

.tight {
  gap: 8px;
}

.muted-block {
  margin: 0;
  line-height: 1.72;
}

.settings-dialog {
  width: min(880px, calc(100vw - 20px));
  border: none;
  padding: 0;
  border-radius: 28px;
  background: transparent;
}

.settings-dialog::backdrop {
  background: rgba(40, 25, 18, 0.4);
  backdrop-filter: blur(6px);
}

.settings-form {
  display: grid;
  gap: 14px;
  padding: 20px;
  background: var(--paper-strong);
  border-radius: 28px;
  max-height: min(86vh, 760px);
  overflow: auto;
}

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

.dialog-section {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper-soft);
}

.compact-actions {
  justify-content: end;
}

.dialog-header,
.dialog-actions,
.inline-fields {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.inline-fields {
  align-items: end;
}

.toggle-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-field input {
  width: auto;
}

label {
  display: grid;
  gap: 10px;
  font-weight: 600;
}

@media (max-width: 900px) {
  .selector-grid,
  .sentence-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding: 10px 10px 14px;
  }

  .hero,
  .dialog-header,
  .dialog-actions,
  .inline-fields,
  .reading-toolbar,
  .panel-heading,
  .analysis-head {
    flex-direction: column;
    align-items: stretch;
  }

  .hero {
    flex-direction: row;
    align-items: flex-start;
  }

  .reading-toolbar {
    flex-direction: row;
    align-items: center;
  }

  .reading-card,
  .settings-form {
    padding: 12px;
    border-radius: 24px;
  }

  .settings-dialog {
    width: min(100vw - 12px, 880px);
  }

  .selector-grid {
    gap: 10px;
  }

  .nav-buttons,
  .mode-toggle,
  .toolbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .speech-float-panel {
    right: 10px;
    bottom: 74px;
    width: min(360px, calc(100vw - 20px));
  }

  .speech-selection-bar {
    width: auto;
  }

  .nav-buttons button {
    width: 100%;
  }

  .mode-toggle,
  .toolbar-actions {
    display: flex;
  }

  .mode-button,
  .subview-button,
  .settings-tab {
    padding-inline: 0.7rem;
  }

  .tool-button span:last-child {
    display: none;
  }

  .tool-button {
    width: 44px;
    padding: 0;
  }

  .original-text,
  .simplified-text,
  .sentence-text {
    font-size: 1rem;
    line-height: 1.7;
  }

  .sentence-card {
    padding: 10px;
  }

  .sentence-grid {
    gap: 10px;
  }

  .reader-dock {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 8px;
    align-items: center;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
  }

  .reader-dock button {
    width: 100%;
    padding-inline: 0.7rem;
  }

  .dock-progress {
    min-width: 54px;
  }

  .dialog-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}
