:root {
  color-scheme: light dark;
  --bg: #f7f6f3;
  --panel: #ffffff;
  --text: #1f2320;
  --muted: #6b6f6c;
  --border: #e1ded6;
  --accent: #5b7a63;
  --accent-contrast: #ffffff;
  --highlight: #eef3ec;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1c19;
    --panel: #24261f;
    --text: #ece9e2;
    --muted: #9a9d97;
    --border: #3a3c34;
    --accent: #7fa387;
    --accent-contrast: #10130f;
    --highlight: #2d3427;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 1.5rem;
  max-width: 900px;
  margin-inline: auto;
}

header h1 {
  font-size: 1.4rem;
  margin-bottom: 0.15rem;
}

.subtitle {
  color: var(--muted);
  margin-top: 0;
  font-size: 0.9rem;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.7rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  width: 100%;
  max-width: 420px;
}

.modal h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.modal form {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.modal label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: var(--muted);
  gap: 0.25rem;
}

.modal input,
.modal textarea {
  font-size: 0.95rem;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  resize: vertical;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.modal-status {
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.1em;
}

.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.controls-bar, .player-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}

.controls-bar label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  color: var(--muted);
  gap: 0.25rem;
}

select, button {
  font-size: 0.95rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

button {
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  font-weight: 600;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.button-link {
  display: inline-block;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  text-decoration: none;
}

.status {
  font-size: 0.9rem;
  color: var(--muted);
  margin-left: auto;
}

.wake-note {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: -0.6rem;
  margin-bottom: 1rem;
  padding: 0 0.2rem;
}

.now-playing {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
}

.now-playing .line {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.2rem 0;
  font-size: 1.05rem;
  opacity: 0.45;
  transition: opacity 0.15s ease;
}

.now-playing .line.active {
  opacity: 1;
  font-weight: 600;
}

.now-playing .tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-contrast);
  background: var(--accent);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  flex-shrink: 0;
}

.list-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 55vh;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--panel);
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
}

tbody td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: var(--highlight);
}

tbody tr.selected {
  background: var(--highlight);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

tbody tr.playing {
  background: var(--accent);
  color: var(--accent-contrast);
}

td.pos {
  color: var(--muted);
  white-space: nowrap;
}

td.empty {
  text-align: center;
  color: var(--muted);
  padding: 1.5rem;
}

tr.section-heading-row {
  cursor: default;
}

td.section-heading {
  background: var(--highlight);
  padding: 0.55rem 0.6rem;
}

.section-heading-lang1 {
  font-weight: 700;
  font-size: 0.95rem;
}

.section-heading-lang2 {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.clickable-word {
  cursor: pointer;
  border-radius: 3px;
}

.clickable-word:hover {
  background: var(--highlight);
}

.word-popup {
  position: fixed;
  z-index: 200;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  max-width: 260px;
}

.word-popup[hidden] {
  display: none;
}

.help-body {
  max-width: 1000px;
}

.help-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.help-nav {
  position: sticky;
  top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
}

.help-nav a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.25rem 0;
}

.help-nav a:hover {
  color: var(--accent);
}

.help-content section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
  scroll-margin-top: 1.5rem;
}

.help-content h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.help-content ol,
.help-content ul {
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.help-content p {
  line-height: 1.5;
}

.help-content p + p {
  margin-top: 0.6rem;
}

@media (max-width: 700px) {
  .help-layout {
    grid-template-columns: 1fr;
  }

  .help-nav {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
  }
}
