:root {
  color-scheme: light;
  --bg: #f7f0e5;
  --surface: #fffaf1;
  --surface-strong: #fff4df;
  --ink: #202629;
  --muted: #66716f;
  --line: #dacbb9;
  --accent: #0b7569;
  --accent-strong: #064d46;
  --purple: #7f0b82;
  --purple-soft: rgba(127, 11, 130, 0.08);
  --red: #a43c31;
  --shadow: 0 18px 42px rgba(32, 38, 41, 0.1);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 250, 241, 0.9), rgba(247, 240, 229, 0.96)),
    repeating-linear-gradient(
      90deg,
      rgba(32, 38, 41, 0.035) 0,
      rgba(32, 38, 41, 0.035) 1px,
      transparent 1px,
      transparent 32px
    );
  color: var(--ink);
}

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

.login-panel {
  display: grid;
  gap: 18px;
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

button,
textarea,
input {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0 16px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 750;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  border-color: var(--line);
  background: #d6d0c6;
  color: var(--muted);
  cursor: default;
}

button.secondary {
  background: var(--surface);
  color: var(--accent-strong);
}

button.secondary:hover {
  background: var(--surface-strong);
}

button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

button.ghost:hover {
  background: rgba(32, 38, 41, 0.06);
  color: var(--ink);
}

.app-shell {
  width: min(980px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  margin-bottom: 18px;
}

.topbar-controls {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.auth-panel {
  display: grid;
  gap: 6px;
  min-width: min(360px, 100%);
}

.auth-form,
.auth-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-form input {
  min-height: 40px;
  min-width: 0;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--ink);
}

.auth-user span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4.2rem);
  line-height: 0.96;
  letter-spacing: 0;
  white-space: nowrap;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

h3 {
  margin: 18px 0 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.language-pair {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr);
  min-width: min(440px, 100%);
  overflow: hidden;
  border: 2px solid var(--purple);
  border-radius: 14px;
  background: rgba(255, 250, 241, 0.9);
}

.language-field {
  display: grid;
  gap: 3px;
  padding: 10px 14px;
}

.language-field + .language-field {
  border-left: 2px solid var(--purple);
}

.language-field span {
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  line-height: 1;
  text-transform: uppercase;
}

.language-field select {
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 4px;
  padding: 3px 22px 3px 0;
  background: transparent;
  color: var(--ink);
  font-weight: 850;
  outline-offset: 4px;
}

.language-field select:focus-visible {
  outline: 3px solid rgba(11, 117, 105, 0.28);
}

.workspace {
  display: grid;
  gap: 16px;
  align-items: start;
}

.root-pane {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.9);
  box-shadow: var(--shadow);
}

.input-view {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
}

.root-pane {
  overflow: hidden;
}

.pane-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  border-bottom: 1px solid var(--line);
  padding: 0 14px;
  background: rgba(255, 244, 223, 0.75);
}

.pane-heading.compact {
  min-height: 36px;
  border: 0;
  padding: 0;
  background: transparent;
}

.metric {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

textarea {
  width: 100%;
  min-height: 300px;
  flex: 1;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  background: white;
  color: var(--ink);
  font-family:
    "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  font-size: 1.35rem;
  line-height: 1.7;
}

textarea:focus,
button:focus-visible,
.selectable-char:focus-visible {
  outline: 3px solid rgba(11, 117, 105, 0.28);
  outline-offset: 2px;
}

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

.input-actions {
  justify-content: flex-end;
}

.reader-view {
  min-height: 300px;
  max-height: calc(100vh - 256px);
  overflow: auto;
  margin: 0;
  padding: 28px 30px 34px;
  background: white;
  color: var(--ink);
  font-family:
    "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  font-size: clamp(1.65rem, 3.4vw, 3rem);
  line-height: 1.85;
  white-space: pre-wrap;
}

.reader-actions {
  border-top: 1px solid var(--line);
  padding: 12px 14px;
  background: rgba(255, 244, 223, 0.36);
}

.selectable-text {
  cursor: text;
  touch-action: pan-y;
  user-select: none;
}

.selectable-char {
  border-radius: 4px;
  padding: 0 1px 2px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  cursor: text;
}

.selectable-char:hover {
  background: rgba(127, 11, 130, 0.05);
}

.selectable-char.is-draft,
.selectable-char.is-pending {
  background: rgba(11, 117, 105, 0.1);
  box-shadow: inset 0 -0.2em 0 rgba(11, 117, 105, 0.35);
}

.selectable-char.is-branch-source {
  background: rgba(127, 11, 130, 0.12);
  box-shadow: inset 0 -0.2em 0 rgba(127, 11, 130, 0.38);
}

.branches-view {
  display: grid;
  gap: 16px;
}

.history-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 250, 241, 0.9);
  box-shadow: var(--shadow);
}

.history-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.history-item {
  display: grid;
  gap: 4px;
  width: clamp(220px, 28vw, 300px);
  min-height: 0;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.history-preview {
  overflow: hidden;
  font-family:
    "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-meta,
.history-empty {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.history-empty {
  margin: 0;
}

.branch-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.94);
}

.branch-stack {
  display: grid;
  gap: 14px;
}

.branch-level {
  display: grid;
  gap: 10px;
}

.branch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.branch-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px;
  width: clamp(210px, 28vw, 270px);
  overflow: hidden;
}

.branch-card.is-active {
  border-color: rgba(127, 11, 130, 0.56);
  box-shadow: 0 0 0 3px rgba(127, 11, 130, 0.08);
}

.branch-card.is-error {
  border-color: rgba(164, 60, 49, 0.42);
}

.branch-selector {
  display: grid;
  width: 100%;
  align-items: center;
  min-width: 0;
  min-height: 0;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 14px;
  background: rgba(255, 244, 223, 0.55);
  color: var(--ink);
  text-align: left;
}

.branch-selector:hover {
  background: rgba(255, 244, 223, 0.88);
  color: var(--ink);
}

.branch-count-button {
  display: grid;
  place-items: center;
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: rgba(255, 250, 241, 0.76);
  color: var(--purple);
  font-size: 1.05rem;
  font-weight: 900;
}

.branch-count-button:hover:not(:disabled) {
  background: var(--purple-soft);
  color: var(--purple);
}

.branch-count-button:disabled {
  background: rgba(255, 250, 241, 0.7);
  color: var(--muted);
  cursor: default;
  opacity: 0.54;
}

.branch-card.is-content-active .branch-selector,
.branch-card.is-children-active .branch-count-button {
  background: var(--purple-soft);
  color: var(--purple);
}

.branch-title {
  overflow: hidden;
  font-family:
    "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  font-size: 1.08rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.branch-content {
  overflow: hidden;
  border: 1px solid rgba(127, 11, 130, 0.24);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.94);
}

.branch-content.is-active {
  border-color: rgba(127, 11, 130, 0.56);
  box-shadow: 0 0 0 3px rgba(127, 11, 130, 0.08);
}

.branch-body {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.pending-selection-panel {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
  cursor: default;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 1rem;
  line-height: 1.4;
  user-select: text;
  white-space: normal;
}

.selected-text {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: white;
  font-family:
    "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  font-size: clamp(1.6rem, 3vw, 2.6rem);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.selected-reading {
  color: var(--accent-strong);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: clamp(1rem, 1.7vw, 1.25rem);
  font-weight: 850;
  line-height: 1.2;
}

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

.meta-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--surface);
}

.meta-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.meta-value {
  font-weight: 850;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.json-block {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #17201d;
  color: #e8fff8;
  font-size: 0.82rem;
  line-height: 1.55;
}

.explanation-view {
  display: grid;
  gap: 4px;
}

.selection-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.explanation-section {
  margin-top: 12px;
}

.explanation-copy,
.meta-line,
.note-list {
  color: var(--ink);
  font-size: 0.98rem;
  line-height: 1.55;
}

.explanation-copy,
.meta-line {
  margin-bottom: 0;
}

.status-box {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 14px;
  background: white;
  color: var(--muted);
  font-weight: 800;
}

.status-error {
  border-color: rgba(164, 60, 49, 0.45);
  background: #fff4f1;
  color: var(--red);
}

.payload-details {
  margin-top: 12px;
}

.payload-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  text-transform: uppercase;
}

.breakdown-list,
.example-list {
  display: grid;
  gap: 10px;
}

.breakdown-card,
.example-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  background: white;
}

.breakdown-card {
  display: grid;
  grid-template-columns: minmax(90px, auto) 1fr;
  gap: 12px;
  align-items: start;
}

.target-snippet {
  color: var(--ink);
  font-family:
    "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  font-size: 1.35rem;
  line-height: 1.8;
  white-space: pre-wrap;
}

.compact-snippet {
  font-size: 1.55rem;
  line-height: 1.55;
}

.target-snippet .selectable-char,
.target-chip .selectable-char {
  padding: 0 1px 1px;
}

.breakdown-content {
  display: grid;
  gap: 5px;
}

.meta-line-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.note-list {
  margin: 0;
  padding-left: 20px;
}

.note-list li + li {
  margin-top: 6px;
}

.target-chip {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  background: white;
  font-family:
    "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  font-weight: 800;
}

.target-chip-label {
  color: var(--muted);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 0.78rem;
}

@media (max-width: 1020px) {
  .reader-view {
    max-height: none;
  }

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

}

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .topbar-controls,
  .auth-panel {
    width: 100%;
  }

  .auth-form,
  .auth-user {
    flex-wrap: wrap;
  }

  .language-pair {
    width: 100%;
    min-width: 0;
  }

  .language-field select {
    min-width: 0;
  }

  .reader-view {
    min-height: 300px;
    padding: 20px 16px 26px;
    font-size: 1.75rem;
  }

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

  .breakdown-card {
    grid-template-columns: 1fr;
  }

}

/* Dark academy theme */
:root {
  color-scheme: dark;
  --bg: #080912;
  --surface: rgba(31, 33, 52, 0.82);
  --surface-strong: rgba(43, 45, 70, 0.9);
  --ink: #f4f1fb;
  --muted: #a9aec6;
  --line: rgba(132, 149, 196, 0.28);
  --accent: #8f6bef;
  --accent-strong: #b08dff;
  --purple: #9b63ff;
  --purple-soft: rgba(155, 99, 255, 0.18);
  --gold: #f1d36b;
  --gold-soft: rgba(241, 211, 107, 0.18);
  --blue: #78aef7;
  --red: #ff8278;
  --shadow: 0 26px 70px rgba(0, 0, 0, 0.42);
}

body {
  position: relative;
  overflow-x: hidden;
  background:
    linear-gradient(90deg, rgba(43, 27, 68, 0.9), rgba(13, 15, 29, 0.76) 42%, rgba(6, 8, 17, 0.96)),
    linear-gradient(155deg, rgba(111, 83, 147, 0.24), rgba(10, 12, 24, 0.2) 36%, rgba(5, 6, 12, 0.86)),
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.028) 0,
      rgba(255, 255, 255, 0.028) 1px,
      transparent 1px,
      transparent 28px
    ),
    #080912;
  color: var(--ink);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(90deg, rgba(7, 8, 17, 0.18), rgba(7, 8, 17, 0.8) 78%),
    repeating-linear-gradient(
      90deg,
      rgba(124, 92, 180, 0.07) 0,
      rgba(124, 92, 180, 0.07) 1px,
      transparent 1px,
      transparent 80px
    );
  opacity: 0.9;
}

button {
  min-height: 38px;
  border: 1px solid rgba(172, 134, 255, 0.58);
  border-radius: 8px;
  padding: 0 16px;
  background:
    linear-gradient(180deg, rgba(126, 77, 177, 0.9), rgba(74, 48, 116, 0.92));
  color: #fbf8ff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

button:hover {
  background:
    linear-gradient(180deg, rgba(151, 95, 210, 0.96), rgba(91, 59, 141, 0.96));
}

button:disabled {
  border-color: rgba(132, 149, 196, 0.2);
  background: rgba(25, 28, 44, 0.72);
  color: rgba(169, 174, 198, 0.58);
}

button.secondary {
  border-color: rgba(124, 174, 247, 0.48);
  background: rgba(25, 29, 49, 0.74);
  color: #dfe9ff;
}

button.secondary:hover {
  background: rgba(42, 50, 78, 0.86);
}

button.ghost {
  color: var(--muted);
}

button.ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
}

.app-shell {
  width: min(1180px, 100%);
  padding: 42px 24px 56px;
}

.topbar {
  min-height: auto;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 18px;
  background: rgba(29, 31, 49, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar > div:first-child {
  min-width: max-content;
}

h1 {
  font-size: clamp(2rem, 3.2vw, 3.4rem);
  font-weight: 850;
  text-shadow: 0 2px 22px rgba(0, 0, 0, 0.42);
}

h2 {
  color: #f4f1fb;
  letter-spacing: 0.01em;
}

h3 {
  color: #b7bdd6;
  letter-spacing: 0.08em;
}

.language-pair {
  border: 1px solid rgba(155, 99, 255, 0.58);
  border-radius: 8px;
  background: rgba(18, 20, 36, 0.72);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 16px 40px rgba(0, 0, 0, 0.22);
}

.language-field {
  padding: 9px 14px;
}

.language-field + .language-field {
  border-left: 1px solid rgba(155, 99, 255, 0.62);
}

.language-field span {
  color: #c0c5db;
}

.language-field select {
  color: #fbf8ff;
}

.language-field select option {
  background: #171a2b;
  color: #fbf8ff;
}

textarea,
.reader-view {
  border: 1px solid rgba(132, 149, 196, 0.24);
  background:
    linear-gradient(180deg, rgba(13, 16, 31, 0.94), rgba(11, 13, 25, 0.92));
  color: #f7f4ff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

textarea {
  border-radius: 8px;
}

textarea::placeholder {
  color: rgba(185, 190, 215, 0.54);
}

textarea:focus,
button:focus-visible,
.selectable-char:focus-visible,
.language-field select:focus-visible {
  outline: 3px solid rgba(155, 99, 255, 0.35);
}

.workspace {
  gap: 18px;
}

.root-pane,
.branch-content {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(32, 35, 57, 0.78), rgba(20, 22, 38, 0.72));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.pane-heading {
  border-bottom: 1px solid var(--line);
  background: rgba(31, 34, 55, 0.7);
}

.metric {
  color: #b7bdd6;
}

.input-view,
.reader-actions {
  background: rgba(16, 18, 32, 0.42);
}

.reader-view {
  background:
    linear-gradient(180deg, rgba(11, 14, 27, 0.96), rgba(8, 10, 20, 0.94));
}

.reader-actions {
  border-top: 1px solid var(--line);
}

.selectable-char:hover {
  background: rgba(155, 99, 255, 0.15);
}

.selectable-char.is-draft,
.selectable-char.is-pending {
  background: rgba(120, 174, 247, 0.18);
  box-shadow: inset 0 -0.2em 0 rgba(120, 174, 247, 0.62);
}

.selectable-char.is-branch-source {
  background: rgba(241, 211, 107, 0.18);
  box-shadow: inset 0 -0.2em 0 rgba(241, 211, 107, 0.72);
}

.branch-card {
  border: 1px solid rgba(132, 149, 196, 0.28);
  border-radius: 8px;
  background: rgba(23, 26, 43, 0.82);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.24);
}

.branch-card.is-active {
  border-color: rgba(155, 99, 255, 0.8);
  box-shadow:
    0 0 0 2px rgba(155, 99, 255, 0.16),
    0 18px 40px rgba(0, 0, 0, 0.28);
}

.branch-card.is-error {
  border-color: rgba(255, 130, 120, 0.7);
}

.branch-selector {
  border-right: 1px solid rgba(132, 149, 196, 0.28);
  background: rgba(31, 35, 56, 0.72);
  color: #f7f4ff;
}

.branch-selector:hover {
  background: rgba(43, 49, 76, 0.9);
  color: #ffffff;
}

.branch-count-button {
  background: rgba(15, 18, 32, 0.76);
  color: var(--gold);
}

.branch-count-button:hover:not(:disabled) {
  background: var(--gold-soft);
  color: #ffe891;
}

.branch-count-button:disabled {
  background: rgba(12, 14, 25, 0.7);
  color: rgba(169, 174, 198, 0.42);
}

.branch-card.is-content-active .branch-selector {
  background: var(--purple-soft);
  color: #f7f0ff;
}

.branch-card.is-children-active .branch-count-button {
  background: var(--gold-soft);
  color: #ffe891;
}

.selected-text,
.meta-item,
.status-box,
.breakdown-card,
.example-card,
.target-chip {
  border-color: rgba(132, 149, 196, 0.24);
  background: rgba(13, 16, 29, 0.7);
  color: #f7f4ff;
}

.selected-reading,
.meta-line-label {
  color: var(--gold);
}

.meta-label,
.target-chip-label,
.payload-details summary {
  color: #b7bdd6;
}

.meta-value,
.explanation-copy,
.meta-line,
.note-list,
.target-snippet {
  color: #f4f1fb;
}

.status-box {
  color: #c0c7de;
}

.status-error {
  border-color: rgba(255, 130, 120, 0.58);
  background: rgba(77, 31, 37, 0.58);
  color: #ffb9b2;
}

.json-block {
  border-color: rgba(132, 149, 196, 0.26);
  background: #090b14;
  color: #dfe9ff;
}

@media (max-width: 720px) {
  .app-shell {
    padding: 18px 12px 36px;
  }

  .topbar {
    padding: 14px;
  }

  .language-pair {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

/* Dark academy theme polish */
:root {
  --surface: rgba(28, 31, 51, 0.84);
  --surface-strong: rgba(43, 46, 72, 0.92);
  --line: rgba(126, 145, 197, 0.34);
  --purple: #a56dff;
  --purple-soft: rgba(165, 109, 255, 0.18);
  --gold: #f3d86f;
  --gold-soft: rgba(243, 216, 111, 0.16);
  --blue: #73aefb;
}

body {
  background:
    linear-gradient(90deg, rgba(32, 20, 55, 0.92), rgba(11, 13, 27, 0.78) 43%, rgba(5, 7, 14, 0.98)),
    linear-gradient(180deg, rgba(120, 88, 171, 0.1), rgba(0, 0, 0, 0.2) 64%),
    repeating-linear-gradient(
      90deg,
      rgba(139, 116, 202, 0.08) 0,
      rgba(139, 116, 202, 0.08) 1px,
      transparent 1px,
      transparent 96px
    ),
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.03) 0,
      rgba(255, 255, 255, 0.03) 1px,
      transparent 1px,
      transparent 28px
    ),
    #080912;
}

body::before {
  background:
    linear-gradient(90deg, rgba(10, 11, 22, 0.1), rgba(7, 8, 17, 0.88) 78%),
    linear-gradient(135deg, transparent 0 28%, rgba(115, 174, 251, 0.06) 28% 30%, transparent 30% 100%),
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent 92px,
      rgba(124, 92, 180, 0.09) 92px,
      rgba(124, 92, 180, 0.09) 93px,
      transparent 93px,
      transparent 184px
    );
  opacity: 1;
}

.app-shell {
  width: min(1240px, 100%);
  padding-top: 40px;
}

.topbar,
.root-pane,
.branch-content {
  border-color: rgba(126, 145, 197, 0.4);
  background:
    linear-gradient(180deg, rgba(37, 40, 64, 0.86), rgba(17, 20, 36, 0.78));
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.topbar {
  position: relative;
  overflow: hidden;
  min-height: 86px;
  padding: 16px 20px;
}

.topbar::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(165, 109, 255, 0.55), rgba(243, 216, 111, 0.34), transparent);
}

h1 {
  color: #f8f4ff;
  font-size: clamp(2rem, 3.4vw, 3.75rem);
  letter-spacing: 0;
}

.login-panel {
  border-color: rgba(126, 145, 197, 0.4);
  background:
    linear-gradient(180deg, rgba(37, 40, 64, 0.86), rgba(17, 20, 36, 0.78));
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px);
}

.login-panel h1 {
  font-size: clamp(2.6rem, 7vw, 4.8rem);
}

.login-panel .auth-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.language-pair {
  min-width: min(460px, 100%);
  border-color: rgba(165, 109, 255, 0.72);
  background:
    linear-gradient(180deg, rgba(18, 20, 37, 0.96), rgba(12, 14, 28, 0.9));
}

.auth-form input {
  border-color: rgba(126, 145, 197, 0.35);
  background:
    linear-gradient(180deg, rgba(11, 14, 28, 0.98), rgba(7, 9, 19, 0.96));
  color: #f7f4ff;
}

.auth-form input::placeholder {
  color: rgba(185, 190, 215, 0.54);
}

.auth-user span,
.auth-status {
  color: #bfc5dd;
}

.language-field {
  min-height: 54px;
  padding: 10px 15px;
}

.language-field + .language-field {
  border-left-color: rgba(165, 109, 255, 0.78);
}

.language-field span,
.metric,
.meta-label,
.target-chip-label,
.payload-details summary {
  color: #bfc5dd;
  letter-spacing: 0.08em;
}

.language-field select {
  color: #fffaf0;
}

.workspace {
  gap: 20px;
}

.pane-heading {
  min-height: 52px;
  background:
    linear-gradient(180deg, rgba(38, 41, 65, 0.82), rgba(29, 32, 52, 0.72));
}

textarea,
.reader-view {
  border-color: rgba(126, 145, 197, 0.35);
  background:
    linear-gradient(180deg, rgba(11, 14, 28, 0.98), rgba(7, 9, 19, 0.96));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

textarea {
  min-height: 290px;
}

.reader-view {
  border-right: 0;
  border-left: 4px solid rgba(115, 174, 251, 0.72);
  font-size: clamp(1.85rem, 3.25vw, 3rem);
}

button {
  border-color: rgba(181, 139, 255, 0.72);
  background:
    linear-gradient(180deg, rgba(140, 85, 198, 0.98), rgba(80, 53, 126, 0.98));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 10px 24px rgba(72, 43, 115, 0.28);
}

button:hover {
  border-color: rgba(204, 173, 255, 0.86);
  background:
    linear-gradient(180deg, rgba(166, 103, 226, 1), rgba(97, 63, 151, 1));
}

button.secondary {
  border-color: rgba(115, 174, 251, 0.62);
  background:
    linear-gradient(180deg, rgba(30, 39, 65, 0.92), rgba(19, 24, 43, 0.92));
}

button.secondary:hover {
  border-color: rgba(143, 193, 255, 0.78);
  background:
    linear-gradient(180deg, rgba(42, 54, 86, 0.96), rgba(24, 31, 52, 0.96));
}

button.ghost {
  box-shadow: none;
}

.selectable-char {
  border-radius: 3px;
}

.selectable-char:hover {
  background: rgba(165, 109, 255, 0.2);
  box-shadow: inset 0 -0.12em 0 rgba(165, 109, 255, 0.42);
}

.selectable-char.is-draft,
.selectable-char.is-pending {
  background: rgba(115, 174, 251, 0.2);
  box-shadow:
    inset 0 -0.22em 0 rgba(115, 174, 251, 0.72),
    0 0 0 1px rgba(115, 174, 251, 0.2);
}

.selectable-char.is-branch-source {
  background: rgba(243, 216, 111, 0.2);
  box-shadow:
    inset 0 -0.22em 0 rgba(243, 216, 111, 0.78),
    0 0 0 1px rgba(243, 216, 111, 0.18);
}

.pending-selection-panel {
  margin-top: 18px;
}

.branch-stack {
  gap: 16px;
}

.branch-row {
  gap: 12px;
}

.branch-card {
  width: clamp(220px, 24vw, 288px);
  border-color: rgba(126, 145, 197, 0.36);
  background:
    linear-gradient(180deg, rgba(33, 37, 60, 0.94), rgba(16, 19, 34, 0.9));
  box-shadow:
    0 16px 34px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.branch-card.is-active {
  border-color: rgba(165, 109, 255, 0.9);
  box-shadow:
    0 0 0 2px rgba(165, 109, 255, 0.2),
    0 20px 44px rgba(0, 0, 0, 0.34);
}

.branch-selector {
  min-height: 54px;
  border-right-color: rgba(126, 145, 197, 0.36);
  background:
    linear-gradient(180deg, rgba(34, 39, 63, 0.92), rgba(22, 26, 45, 0.92));
}

.branch-title {
  color: #fffaf0;
}

.branch-count-button {
  min-height: 54px;
  background:
    linear-gradient(180deg, rgba(28, 31, 51, 0.96), rgba(12, 15, 28, 0.96));
  color: var(--gold);
  font-size: 1.12rem;
}

.branch-card.is-content-active .branch-selector {
  background:
    linear-gradient(180deg, rgba(96, 61, 145, 0.7), rgba(53, 39, 88, 0.76));
}

.branch-card.is-children-active .branch-count-button {
  background:
    linear-gradient(180deg, rgba(105, 87, 41, 0.78), rgba(51, 42, 28, 0.84));
}

.branch-content {
  border-left: 4px solid rgba(165, 109, 255, 0.82);
}

.branch-content.is-active {
  border-color: rgba(126, 145, 197, 0.4);
  border-left-color: rgba(165, 109, 255, 0.9);
  box-shadow:
    0 0 0 1px rgba(165, 109, 255, 0.16),
    0 24px 60px rgba(0, 0, 0, 0.38);
}

.history-panel {
  border-color: rgba(126, 145, 197, 0.4);
  background:
    linear-gradient(180deg, rgba(32, 35, 57, 0.78), rgba(20, 22, 38, 0.72));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.history-item {
  border-color: rgba(126, 145, 197, 0.36);
  background:
    linear-gradient(180deg, rgba(33, 37, 60, 0.94), rgba(16, 19, 34, 0.9));
  color: #f7f4ff;
}

.history-item:hover {
  border-color: rgba(165, 109, 255, 0.72);
  background:
    linear-gradient(180deg, rgba(43, 49, 76, 0.96), rgba(22, 26, 45, 0.96));
}

.history-meta,
.history-empty {
  color: #bfc5dd;
}

.branch-body {
  gap: 12px;
  padding: 16px;
}

.selected-text,
.meta-item,
.status-box,
.breakdown-card,
.example-card,
.target-chip {
  border-color: rgba(126, 145, 197, 0.34);
  background:
    linear-gradient(180deg, rgba(15, 18, 33, 0.82), rgba(9, 12, 24, 0.78));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.selected-text {
  border-color: rgba(243, 216, 111, 0.36);
}

.selected-reading,
.meta-line-label {
  color: #f8dc72;
}

.breakdown-card,
.example-card {
  padding: 14px;
}

.json-block {
  background:
    linear-gradient(180deg, rgba(4, 6, 13, 0.96), rgba(7, 9, 18, 0.96));
}

.login-screen {
  align-items: center;
  justify-items: center;
  padding: 28px;
}

.login-panel {
  gap: 20px;
  width: min(720px, 100%);
  padding: 34px 36px 30px;
}

.login-panel h1 {
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  line-height: 0.95;
  text-align: center;
}

.login-panel .auth-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.login-panel .auth-form input {
  min-height: 48px;
  font-size: 1rem;
}

.login-panel .auth-form button {
  min-height: 48px;
  padding-inline: 20px;
}

.login-panel .auth-status {
  text-align: center;
}

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

  .topbar {
    min-height: 0;
  }

  h1 {
    font-size: 2.35rem;
  }

  .reader-view {
    border-left-width: 3px;
    font-size: 1.75rem;
  }

  .branch-card {
    width: min(100%, 288px);
  }

  .login-screen {
    padding: 16px;
  }

  .login-panel {
    padding: 24px 18px;
  }

  .login-panel h1 {
    font-size: clamp(2.25rem, 14vw, 3.4rem);
    white-space: normal;
  }

  .login-panel .auth-form {
    grid-template-columns: 1fr;
  }
}
