:root {
  color: #1c1915;
  background: #f4f0e8;
  font-family: "Segoe UI", "Yu Gothic UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body { margin: 0; overflow: hidden; }

button, audio { font: inherit; }

.app {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 300px;
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

aside.tracks {
  grid-row: 1;
  min-height: 0;
  overflow: auto;
  padding: 28px 20px;
  background: #ebe4d6;
  border-right: 1px solid #ddd4c4;
}

.mark {
  margin: 0;
  letter-spacing: 0.08em;
  font-size: 13px;
}

aside.tracks h1 {
  margin: 8px 0 0;
  font-size: 22px;
  font-weight: 600;
}

.sub {
  margin: 4px 0 20px;
  color: #5c564c;
  font-size: 14px;
}

ol { list-style: none; padding: 0; margin: 0; }

aside.tracks button, .tools button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}

button.current { background: #fff; }

main {
  grid-row: 1;
  min-height: 0;
  overflow: auto;
  padding: 28px 48px 36px;
}

.preview {
  margin-bottom: 28px;
  color: #5c564c;
}

.words {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 0 0 6px;
  font-family: "Palatino Linotype", Palatino, Georgia, serif;
  color: #1c1915;
}

.preview-word { display: flex; flex-direction: column; }

.preview-word small {
  font-family: "Segoe UI", "Yu Gothic UI", sans-serif;
  color: #5c564c;
  font-size: 13px;
}

article p {
  font-family: "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 20px;
  line-height: 1.7;
  margin: 0 0 1.1em;
}

#review { margin-bottom: 28px; }

#review-sentence {
  font-family: "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 22px;
  line-height: 1.7;
}

#review-sentence .blank {
  display: inline-block;
  min-width: 4em;
  border-bottom: 2px solid #8a5a2b;
}

#review-input { width: min(100%, 360px); font: inherit; padding: 8px 10px; }

.review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
  position: sticky;
  bottom: 92px;
  z-index: 1;
  background: #f4f0e8;
  padding: 8px 0;
}

.review-actions button {
  border: 1px solid #ddd4c4;
  border-radius: 8px;
  background: #fff;
  padding: 8px 12px;
  cursor: pointer;
}

article p.sentence { cursor: pointer; border-radius: 6px; }

article p.selected { box-shadow: inset 3px 0 0 #8a5a2b; }

article p.playing { background: #f3e2b0; }

article p .when {
  display: block;
  margin-top: 2px;
  font-family: "Segoe UI", "Yu Gothic UI", sans-serif;
  font-size: 13px;
  color: #6d675d;
}

.insertion {
  font-family: "Segoe UI", "Yu Gothic UI", sans-serif;
  font-size: 14px;
  color: #6d675d;
}

article.hidden-text p:not(.insertion) {
  color: transparent;
  background: #e7e1d6;
  border-radius: 6px;
  user-select: none;
}

button.token {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}

button.token.saved { box-shadow: inset 0 -2px 0 #8a5a2b; }

button.token.picked { background: #f3e2b0; }

aside.side {
  grid-row: 1;
  min-height: 0;
  padding: 28px 18px 32px;
  border-left: 1px solid #ddd4c4;
  background: #fbf8f2;
  overflow: auto;
}

aside.side h2 {
  margin: 22px 0 8px;
  font-size: 14px;
  font-weight: 600;
}

aside.side section:first-child h2 { margin-top: 0; }

aside.side button, aside.side textarea, aside.side input, aside.side select {
  width: 100%;
  font: inherit;
}

aside.side button, aside.side textarea, aside.side input, aside.side select {
  border: 1px solid #ddd4c4;
  border-radius: 8px;
  background: #fff;
  padding: 8px 10px;
}

aside.side label { display: block; margin: 10px 0; font-size: 13px; }

aside.side label.check { display: flex; gap: 8px; align-items: center; }

aside.side label.check input { width: auto; }

aside.side .form {
  font-family: "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 20px;
  margin: 0;
}

aside.side .hint, aside.side .note, #ja-preview {
  margin: 8px 0 0;
  color: #5c564c;
  font-size: 14px;
  line-height: 1.6;
}

#ja-preview { color: #1c1915; }

aside.side ul { list-style: none; padding: 0; margin: 16px 0 0; }

aside.side li { margin: 0 0 8px; font-size: 14px; }

aside.side li button { width: auto; margin-left: 8px; padding: 2px 8px; }

footer {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 12px 24px;
  background: #fbf8f2;
  border-top: 1px solid #ddd4c4;
}

audio { flex: 1; }

.tools {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tools button { width: auto; }

.now { color: #6d675d; font-size: 14px; }

.error { color: #8a3b2c; }

[hidden] { display: none !important; }
#check { margin: 16px 0; border: 1px solid #ddd4c4; border-radius: 8px; padding: 16px; background: #fbf8f2; }
#check label { display: block; margin: 10px 0; }
#check textarea { display: block; width: 100%; font: inherit; padding: 8px; }
#reference { margin: 8px 0; }
#reference p { font-size: 14px; line-height: 1.55; }
#review-feedback { min-height: 1.5em; }
.tools { flex-wrap: wrap; }
#timing { display: inline-flex; gap: 6px; }
#review-translation { color: #5c564c; line-height: 1.65; margin: -6px 0 20px; }
#follow-reading[aria-pressed="true"] { background: #fff; }

#text .sentence:has(+ .inline-translation) { margin-bottom: 4px; }
.inline-translation { margin: 0 0 1.3rem; font-size: 14px; }
.inline-translation summary { cursor: pointer; color: #6b4b2d; width: fit-content; }
.inline-translation-text { margin-top: 8px; padding: 8px 12px; border-left: 2px solid #cbb99e; line-height: 1.7; }

#chapter-picker { display: block; margin: 0 0 12px; font-size: 14px; }
#chapter-select { width: 100%; margin-top: 4px; padding: 6px; font: inherit; }

.translation-form label { display: block; }
.translation-form textarea { display: block; width: 100%; margin: 6px 0; padding: 6px; font: inherit; }

.translation-source { display: block; margin-top: 4px; color: #6c6255; font-size: 12px; }

#dictionary-popup {
  position: fixed;
  inset: auto;
  margin: 0;
  width: max-content;
  max-width: min(340px, calc(100vw - 16px));
  max-height: calc(100vh - 16px);
  overflow: auto;
  padding: 12px 14px;
  color: #1c1915;
  background: #fffcf6;
  border: 1px solid #cbb99e;
  border-radius: 10px;
  box-shadow: 0 5px 18px #34281430;
}
.dictionary-popup-heading, .dictionary-popup-lemma { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.dictionary-popup-heading { justify-content: space-between; }
#dictionary-form, #dictionary-lemma { font-family: Georgia, serif; font-size: 19px; }
#dictionary-lemma:empty { display: none; }
#dictionary-close { border: 0; background: none; color: #6b4b2d; cursor: pointer; padding: 4px; }
#dictionary-pos, #dictionary-note { color: #625747; font-size: 13px; }
#dictionary-meaning, #dictionary-note { margin: 5px 0 0; line-height: 1.55; }
