:root {
  color-scheme: dark;
  --bg: #14120f;
  --card: #1f1c18;
  --text: #f4efe6;
  --muted: #b6ad9e;
  --en: #f2d08a;
  --tr: #9fd4c2;
  --active: #3a3328;
  --accent: #e8b86d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  background: var(--bg);
  color: var(--text);
}

body.locked .app,
body.locked .modal {
  display: none;
}

.gate {
  display: none;
}

body.locked .gate {
  display: grid;
  min-height: 70vh;
  place-items: center;
}

.gate-card {
  display: grid;
  gap: 0.75rem;
  width: min(22rem, 100%);
  padding: 1.2rem 1.15rem 1.15rem;
  background: var(--card);
  border-radius: 1rem;
}

.gate-card h1 {
  margin: 0 0 0.2rem;
}

.gate-card label {
  display: grid;
  gap: 0.35rem;
  font-family: system-ui, sans-serif;
  font-size: 0.82rem;
  color: var(--muted);
}

.gate-card input {
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 0;
  border-radius: 0.7rem;
  padding: 0.6rem 0.75rem;
}

.gate-card button {
  justify-self: start;
  font-family: system-ui, sans-serif;
  font-weight: 600;
  border: 0;
  border-radius: 999px;
  padding: 0.5rem 0.95rem;
  background: var(--accent);
  color: #1a150f;
  cursor: pointer;
}

.app {
  max-width: 42rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 4rem;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.tracks {
  display: flex;
  gap: 0.4rem;
}

.rebuild {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin: 0.9rem 0 0;
  font-family: system-ui, sans-serif;
  font-size: 0.82rem;
  color: var(--muted);
}

.rebuild button,
.rebuild .download {
  font: inherit;
  font-family: system-ui, sans-serif;
  font-weight: 600;
  border: 0;
  border-radius: 999px;
  padding: 0.5rem 0.95rem;
  text-decoration: none;
  cursor: pointer;
}

.rebuild button {
  background: var(--accent);
  color: #1a150f;
}

.rebuild .download {
  background: #3a4a42;
  color: #d8efe6;
}

.rebuild .download.ready {
  background: #4d7a66;
}

.rebuild button:disabled {
  opacity: 0.55;
}

.rebuild button.danger,
.phrase-x {
  background: #5a3228;
  color: #ffd8cf;
}

.badge-wrap {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.badge-x,
.phrase-x {
  font-family: system-ui, sans-serif;
  font-size: 0.8rem;
  border: 0;
  border-radius: 999px;
  width: 1.7rem;
  height: 1.7rem;
  cursor: pointer;
}

.badge-x {
  background: transparent;
  color: #8a8378;
  width: 1.35rem;
  height: 1.35rem;
  font-size: 1.05rem;
  line-height: 1;
  opacity: 0.7;
}

.badge-x:hover {
  opacity: 1;
  color: #c9a227;
  background: transparent;
}

.list li {
  position: relative;
}

.phrase-x {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
}

.tr-edit {
  width: 100%;
  min-height: 3.2rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 0;
  border-radius: 0.5rem;
  padding: 0.4rem 0.5rem;
}

.tracks button,
.controls button,
.rate select {
  font: inherit;
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  background: var(--card);
  color: var(--text);
}

.tracks button.active,
.controls button#play {
  background: var(--accent);
  color: #1a150f;
}

.controls button:disabled,
.bar input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.now {
  margin: 1.25rem 0;
  padding: 1rem 1.1rem;
  background: var(--card);
  border-radius: 1rem;
}

.hint {
  margin: 0 0 0.35rem;
  font-family: system-ui, sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.hint.site {
  margin: 0.2rem 0 0;
}

.back {
  display: inline-block;
  margin-bottom: 0.35rem;
  font-family: system-ui, sans-serif;
  font-size: 0.82rem;
  color: var(--muted);
  text-decoration: none;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 1rem 0 1.6rem;
}

.badge {
  font-family: system-ui, sans-serif;
  font-size: 0.95rem;
  border: 0;
  border-radius: 999px;
  padding: 0.65rem 1.05rem;
  background: var(--accent);
  color: #1a150f;
  cursor: pointer;
}

.badge:hover {
  filter: brightness(1.08);
}

.add-text {
  font-family: system-ui, sans-serif;
  font-size: 0.9rem;
  border: 1px dashed #5a5348;
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
}

.add-text:hover,
.add-text.is-open {
  border-color: var(--accent);
  color: var(--accent);
}

.composer {
  display: none;
  gap: 0.7rem;
  padding: 1rem 1.05rem 1.1rem;
  background: var(--card);
  border-radius: 1rem;
}

.composer.is-open {
  display: grid;
}

.composer h2 {
  margin: 0;
  font-size: 1.05rem;
}

.composer label {
  display: grid;
  gap: 0.35rem;
  font-family: system-ui, sans-serif;
  font-size: 0.82rem;
  color: var(--muted);
}

.composer .optional {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.composer input,
.composer textarea {
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 0;
  border-radius: 0.7rem;
  padding: 0.6rem 0.75rem;
}

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

.composer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.composer button {
  justify-self: start;
  font-family: system-ui, sans-serif;
  font-weight: 600;
  border: 0;
  border-radius: 999px;
  padding: 0.5rem 0.95rem;
  background: var(--accent);
  color: #1a150f;
  cursor: pointer;
}

.composer button[type="button"] {
  background: #3a4a42;
  color: #d8efe6;
}

.line {
  margin: 0 0 1rem;
  line-height: 1.55;
  font-size: 1.25rem;
}

.line.tr {
  margin-bottom: 0;
  font-size: 1.1rem;
  color: #d8e8e2;
}

.word {
  border-radius: 0.25rem;
  padding: 0 0.06em;
  cursor: pointer;
}

.word.en-word:hover {
  background: #3a3328;
}

.word.on {
  background: var(--en);
  color: #1a150f;
}

.word.unknown {
  background: #8a3b2c;
  color: #fff4f0;
}

.word.unknown.on {
  background: #d4654a;
  color: #1a100e;
}

.tip,
.filter {
  font-family: system-ui, sans-serif;
  font-size: 0.85rem;
  color: var(--muted);
}

.tip {
  margin: 0 0 0.7rem;
  line-height: 1.4;
}

.filter {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.8rem;
}

.marked {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 1rem;
}

.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  font: inherit;
  font-family: system-ui, sans-serif;
  font-size: 0.8rem;
  border: 0;
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  background: #5a3228;
  color: #ffd8cf;
  cursor: pointer;
}

.chip-tr {
  font-weight: 400;
  opacity: 0.72;
}

.line.tr .word.on {
  background: var(--tr);
  color: #12201b;
}

.controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.controls button#play {
  min-width: 5.5rem;
}

.rate {
  margin-left: auto;
  font-family: system-ui, sans-serif;
  font-size: 0.85rem;
  color: var(--muted);
}

.bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.6rem;
  align-items: center;
  margin: 0.9rem 0 1.2rem;
  font-family: system-ui, sans-serif;
  font-size: 0.8rem;
  color: var(--muted);
}

#seek {
  width: 100%;
  height: 1.35rem;
  cursor: pointer;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list li {
  position: relative;
  padding: 0.7rem 2.2rem 0.7rem 0.8rem;
  border-radius: 0.7rem;
  cursor: pointer;
}

.list li.current {
  background: var(--active);
}

.list .en-small {
  margin: 0 0 0.25rem;
  font-size: 0.98rem;
}

.list .tr-small {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 1rem;
  background: rgba(8, 7, 5, 0.62);
}

.modal.is-open {
  display: grid;
}

.modal-card {
  width: min(22rem, 100%);
  padding: 1.15rem 1.2rem 1.1rem;
  border-radius: 1rem;
  background: var(--card);
  font-family: system-ui, sans-serif;
}

.modal-title {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  font-weight: 600;
}

.modal-text {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

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

.modal-actions button {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  background: #3a3328;
  color: var(--text);
  cursor: pointer;
}

.modal-actions button.danger {
  background: #8a3b2c;
  color: #fff4f0;
}
