:root {
  --bg: #f6f3ec;
  --card: #fffdf8;
  --ink: #2b2a26;
  --muted: #8a857a;
  --accent: #b3552e;
  --accent-soft: #f3e3d8;
  --border: #e5dfd2;
  --shadow: 0 18px 50px rgba(43, 42, 38, 0.22);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.6;
}

#view {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.loading, .error {
  padding: 40px 0;
  color: var(--muted);
  text-align: center;
}
.error { color: #a33; }

.page-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  margin: 0 0 6px;
}

.page-sub {
  color: var(--muted);
  margin: 0 0 32px;
  font-size: 14px;
}

.ep-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}

.ep-list li { border-bottom: 1px solid var(--border); }

.ep-item {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 13px 10px;
  text-decoration: none;
  color: inherit;
  transition: background 0.12s;
}

.ep-item:hover { background: var(--accent-soft); }

.ep-num {
  flex: 0 0 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
}

.ep-num--tag {
  flex: 0 0 auto;
  text-align: left;
}

.ep-tag {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 9px;
  border-radius: 999px;
}

.ep-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
}

.back-link {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 18px;
}
.back-link:hover { text-decoration: underline; }

.ep-heading {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  line-height: 1.3;
  margin: 0 0 28px;
}

.ep-text {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  line-height: 1.75;
}

.ep-text p { margin: 0 0 1.2em; }

.w {
  cursor: pointer;
  border-radius: 3px;
  padding: 1px 1px;
  transition: background 0.1s;
}

.w:hover { background: var(--accent-soft); color: var(--accent); }

.w.looked {
  text-decoration: underline dotted var(--accent);
  text-underline-offset: 4px;
}

body.popup-open { overflow: hidden; }

#popup { position: fixed; inset: 0; z-index: 50; }

#popup.hidden { display: none; }

.popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(43, 42, 38, 0.45);
}

.popup-card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(620px, calc(100vw - 32px));
  max-height: min(82vh, 820px);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  animation: pop-in 0.16s ease-out;
}

@keyframes pop-in {
  from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.popup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.popup-word {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  overflow-wrap: anywhere;
}

.popup-close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.popup-close:hover { background: var(--accent-soft); color: var(--accent); }

.popup-body {
  padding: 6px 22px 22px;
  overflow-y: auto;
  font-size: 15px;
  line-height: 1.6;
}

.popup-body h2 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin: 20px 0 8px;
}

.popup-body h2:first-child { margin-top: 14px; }

.popup-body p { margin: 6px 0; }

.popup-body ul, .popup-body ol { margin: 6px 0; padding-left: 22px; }

.popup-body li { margin: 4px 0; }

.popup-body table {
  border-collapse: collapse;
  margin: 10px 0;
  width: 100%;
  font-size: 14px;
}

.popup-body th, .popup-body td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}

.popup-body th { background: var(--accent-soft); }

.popup-body code {
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 13px;
}

.popup-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 28px 0;
  color: var(--muted);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.mock-note {
  background: #fff6dd;
  border: 1px solid #eadfae;
  color: #7a6420;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  margin: 14px 0 4px;
}

body.has-player #view { padding-bottom: 130px; }

#player {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 40;
  width: min(720px, calc(100vw - 24px));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 34px rgba(43, 42, 38, 0.28);
}

#player.hidden { display: none; }

.pl-btn {
  flex: 0 0 auto;
  min-width: 44px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.pl-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.pl-play {
  width: 46px;
  font-size: 14px;
  color: var(--accent);
}

.pl-time {
  flex: 0 0 auto;
  min-width: 40px;
  text-align: center;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.pl-seek {
  flex: 1 1 auto;
  min-width: 60px;
  height: 4px;
  accent-color: var(--accent);
  cursor: pointer;
}

.pl-mute {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  min-width: 38px;
  padding: 0;
}

.pl-vol {
  flex: 0 0 88px;
  height: 4px;
  accent-color: var(--accent);
  cursor: pointer;
}

@media (max-width: 600px) {
  .pl-vol { display: none; }
}
