/* VLS Reader — minimal pilot styles */

:root {
  --bg: #f7f3ec;
  --surface: #ffffff;
  --surface-2: #ece5d8;
  --border: #d6cdb8;
  --ink: #221f1a;
  --ink-soft: #5a5347;
  --ink-muted: #8a8273;
  --accent: #4a86e8;
  --accent-soft: #d4e2fa;
  --hl: #fff3a8;
  --bad: #c0392b;
  --good: #2f8f4d;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1816;
    --surface: #25221e;
    --surface-2: #2e2a25;
    --border: #3a3530;
    --ink: #e8e3d8;
    --ink-soft: #b3ad9f;
    --ink-muted: #807a6b;
    --accent: #6ea3f0;
    --accent-soft: #2a3854;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", system-ui, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

a { color: var(--accent); }
a.back { font-size: 22px; line-height: 1; padding: 6px 10px; text-decoration: none; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-weight: 600; letter-spacing: 0.04em;
}
.user {
  margin-left: auto;
  padding: 4px 10px;
  background: var(--surface-2); border-radius: 999px;
  font-size: 13px; color: var(--ink-soft);
}
.title-mini { flex: 1; font-size: 14px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.page { max-width: 720px; margin: 0 auto; padding: 30px 20px 60px; }
h1 { margin: 0 0 8px; font-size: 26px; }
.lead { color: var(--ink-soft); margin: 0 0 28px; }
.footnote { color: var(--ink-muted); font-size: 13px; margin-top: 30px; }

/* --- login --- */
#login-form { display: flex; gap: 8px; margin-top: 20px; }
#login-form input {
  flex: 1; padding: 12px 14px; font-size: 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font-family: ui-monospace, "SF Mono", "Menlo", monospace;
}
#login-form button {
  padding: 12px 20px; font-size: 16px;
  background: var(--accent); color: white; border: 0; border-radius: var(--radius);
  cursor: pointer;
}
.error {
  margin-top: 14px; padding: 10px 14px;
  background: #fdecea; color: var(--bad);
  border-radius: var(--radius);
  font-size: 14px;
}
@media (prefers-color-scheme: dark) {
  .error { background: rgba(192, 57, 43, 0.2); }
}

/* --- library --- */
.books { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 600px) { .books { grid-template-columns: repeat(3, 1fr); } }

.book-card {
  display: block;
  padding: 18px 18px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.1s ease;
}
.book-card:hover { transform: translateY(-2px); }
.book-card .num {
  font-size: 11px; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--ink-muted);
}
.book-card .name {
  font-family: Georgia, serif; font-size: 19px; line-height: 1.3;
  margin: 6px 0 12px;
}
.book-card .progress {
  height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden;
}
.book-card .progress-bar {
  height: 100%; background: var(--accent);
}
.book-card .progress-label {
  margin-top: 8px; font-size: 12px; color: var(--ink-soft);
}

/* --- reader --- */
.reading { background: var(--bg); }
.reader-main {
  max-width: 700px; margin: 0 auto; padding: 16px 18px 80px;
}
.chapter-nav {
  display: flex; gap: 8px; align-items: center;
  margin: 14px 0 20px;
}
.chapter-nav.bottom { margin-top: 30px; }
.chapter-nav button {
  padding: 8px 12px; font-size: 14px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.chapter-nav button:disabled { opacity: 0.4; cursor: default; }
#chapter-select {
  flex: 1; padding: 8px 12px; font-size: 14px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px;
}
.icon-btn {
  background: transparent; border: 0; cursor: pointer;
  font-size: 18px; padding: 6px 10px; position: relative;
}
.badge {
  position: absolute; top: -2px; right: -4px;
  background: var(--accent); color: white;
  font-size: 10px; font-weight: 600;
  padding: 1px 5px; border-radius: 999px;
  min-width: 16px; text-align: center;
}

.reader-content {
  font-family: "Iowan Old Style", Georgia, "Times New Roman", serif;
  font-size: 18px;
  line-height: 1.7;
}
.reader-content h2.chapter-title {
  font-size: 24px; margin: 0 0 24px;
  font-family: Georgia, serif;
  text-align: center; color: var(--ink-soft);
}
.reader-content p.para {
  margin: 0 0 18px;
}

/* word styling */
.w {
  display: inline; cursor: pointer;
  position: relative;
  padding: 0 1px;
  border-radius: 2px;
}
.w[data-show] {
  border-bottom: 1px dotted var(--ink-muted);
}
.w:hover {
  background: var(--accent-soft);
}
.w.is-saved {
  background: var(--hl);
}
.w.is-active {
  background: var(--accent);
  color: white;
}
@media (prefers-color-scheme: dark) {
  .w.is-saved { background: rgba(255, 243, 168, 0.25); color: inherit; }
}

/* popover */
.popover {
  position: absolute; z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  max-width: 320px; min-width: 220px;
  font-size: 15px; line-height: 1.45;
}
.popover .word { font-size: 22px; font-weight: 600; }
.popover .ipa {
  margin-top: 4px; color: var(--ink-soft);
  font-family: "Charis SIL", "Lucida Sans Unicode", serif;
  font-size: 14px;
}
.popover .tr { margin-top: 10px; font-size: 16px; }
.popover .meta { margin-top: 6px; font-size: 12px; color: var(--ink-muted); }
.popover .examples { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 13px; }
.popover .examples .ex { margin-bottom: 6px; color: var(--ink-soft); }
.popover .actions { margin-top: 12px; display: flex; gap: 8px; }
.popover .actions button {
  flex: 1; padding: 8px 10px;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; font-size: 13px;
}
.popover .actions button.primary {
  background: var(--accent); color: white; border-color: var(--accent);
}
.popover .actions button.danger {
  background: transparent; color: var(--bad); border-color: transparent;
}

/* words panel */
.words-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(90%, 380px); z-index: 90;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 20px rgba(0,0,0,0.06);
  padding: 16px 18px;
  overflow-y: auto;
}
.words-panel header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.words-panel h2 { margin: 0; font-size: 18px; }
.words-panel #words-count {
  margin-left: 6px; font-weight: normal; color: var(--ink-muted); font-size: 14px;
}
.word-bubble {
  display: block;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 14px;
}
.word-bubble .lem { font-weight: 600; font-size: 16px; }
.word-bubble .tr { color: var(--ink-soft); margin-top: 4px; }
.word-bubble .src { color: var(--ink-muted); font-size: 12px; margin-top: 4px; font-style: italic; }

.loading { color: var(--ink-muted); padding: 30px; text-align: center; }
