/* ============================================================
   News Bean — Editorial Cream design system
   Audience: modern young educated Chinese learners
   References: Linear, Substack, Arc, Things, NYT
   ============================================================ */

:root {
  /* paper palette */
  --paper:        #FAF8F3;
  --paper-2:      #F4F1E8;
  --surface:      #FFFFFF;
  --ink:          #1A1A1A;
  --ink-2:        #2C2A26;
  --muted:        #6B6660;
  --muted-2:      #9C968D;
  --line:         #ECE6D6;
  --line-2:       #E2DCCB;

  /* accent: roasted bean amber */
  --accent:       #D9621A;
  --accent-2:     #B84F0E;
  --accent-soft:  #FBE9D6;

  /* highlights for active states */
  --hl-soft:      #FEF5DA;  /* current sentence bg */
  --hl-medium:    #FCE2A0;  /* word selection bg */
  --hl-strong:    #F59E0B;

  /* feedback colors */
  --ok:           #15803D;
  --ok-soft:      #DCFCE7;
  --warn:         #B45309;
  --warn-soft:    #FEF3C7;
  --err:          #B91C1C;
  --err-soft:     #FEE4E4;

  /* radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 24px;

  /* type stacks */
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "PingFang SC", "Helvetica Neue", sans-serif;
  --font-serif: "New York", "Charter", "Iowan Old Style", "Palatino", Georgia, "Source Serif Pro", "Songti SC", serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, "Courier New", monospace;
}

* { box-sizing: border-box; }
*::selection { background: var(--hl-medium); color: var(--ink); }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "tnum", "ss01";
}
body { min-height: 100vh; min-height: 100dvh; }

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }

/* form controls */
input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 11px 14px;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.06);
}
input[disabled] { background: var(--paper-2); color: var(--muted); }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.dot { margin: 0 6px; color: var(--muted-2); }
.tnum { font-variant-numeric: tabular-nums; }
.kicker {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-weight: 500;
  font-size: 14px;
  letter-spacing: -0.01em;
  transition: background 0.18s, border-color 0.18s, transform 0.06s, color 0.18s;
  background: var(--surface);
  color: var(--ink);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.btn.primary:hover { background: var(--ink-2); }
.btn.accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.accent:hover { background: var(--accent-2); }
.btn.ghost {
  background: transparent;
  border-color: var(--line-2);
  color: var(--ink);
}
.btn.ghost:hover { background: var(--paper-2); }
.btn.danger {
  background: transparent;
  color: var(--err);
  border-color: var(--line-2);
}
.btn.danger:hover { background: var(--err-soft); border-color: var(--err); }
.btn.block { width: 100%; }
.btn.small { padding: 7px 12px; font-size: 12px; border-radius: 6px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-family: var(--font-ui);
}
.badge.muted {
  background: var(--paper-2);
  color: var(--muted);
}
.badge.outline {
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--muted);
}

/* ---------------- bottom bar (10% pinned) ---------------- */
.bottom-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 10vh;
  min-height: 68px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  position: relative;
  transition: color 0.18s;
}
.bottom-tab .ico {
  font-size: 22px;
  line-height: 1;
}
.bottom-tab.active { color: var(--ink); }
.bottom-tab.active::after {
  content: "";
  position: absolute;
  bottom: 8px;
  width: 18px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

/* ---------------- home ---------------- */
.home-shell { min-height: 100vh; }
.home-main {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px calc(10vh + 40px);
  animation: pageIn 0.4s ease;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.home-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 12px;
}
.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--ink);
}
.brand-sub {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.02em;
}
.admin-link {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--line-2);
  padding-bottom: 1px;
  transition: color 0.18s, border-color 0.18s;
}
.admin-link:hover { color: var(--ink); border-color: var(--ink); }

/* section tabs — editorial underline style */
.section-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  padding-bottom: 0;
}
.section-tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  position: relative;
  transition: color 0.18s;
  letter-spacing: -0.005em;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); font-weight: 600; }
.tab.active::after {
  content: "";
  position: absolute;
  left: 16px; right: 16px;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

/* vocab filter row */
.vocab-filter {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  font-size: 12px;
  color: var(--muted);
}
.vocab-filter > label {
  flex: 0 0 auto;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 10px;
}
.vocab-pills {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
}
.vocab-pills::-webkit-scrollbar { display: none; }
.pill {
  flex: 0 0 auto;
  padding: 5px 12px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  transition: all 0.18s;
}
.pill:hover { color: var(--ink); border-color: var(--ink); }
.pill.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

/* material list */
.material-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.material-list .empty {
  text-align: center;
  color: var(--muted-2);
  padding: 80px 20px;
  font-size: 14px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--r-lg);
}
.material-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.18s, box-shadow 0.18s;
}
.material-row:hover {
  border-color: var(--line-2);
  box-shadow: 0 12px 24px -16px rgba(26, 26, 26, 0.18);
  transform: translateY(-1px);
}
.material-row:active { transform: translateY(0) scale(0.995); }
.row-link {
  display: flex;
  gap: 14px;
  padding: 12px;
  align-items: stretch;
}
.cover {
  flex: 0 0 38%;
  max-width: 200px;
  aspect-ratio: 16 / 9;
  background: var(--paper-2);
  border-radius: var(--r-md);
  overflow: hidden;
  position: relative;
}
.cover img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.material-row:hover .cover img { transform: scale(1.03); }
.cover-placeholder {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--muted-2);
}
.meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 4px 4px 4px 0;
}
.meta .title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.015em;
  margin-bottom: 8px;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.meta .sub {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.meta .sub2 {
  font-size: 11px;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
}
.meta .sub2 .eye-ico {
  width: 13px; height: 13px;
  margin-right: 3px;
  vertical-align: -2px;
  display: inline-block;
}

/* ---------------- modal ---------------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(26, 26, 26, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: maskIn 0.18s ease;
}
@keyframes maskIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 380px;
  padding: 28px 26px 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
  animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal h3 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.modal-sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.modal-error { color: var(--err); font-size: 12px; min-height: 16px; margin-top: 8px; }
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px;
}

/* ---------------- detail page ---------------- */
.detail-shell { min-height: 100vh; min-height: 100dvh; }

/* key gate */
.gate {
  position: fixed; inset: 0;
  background: linear-gradient(165deg, #1A1A1A 0%, #2C2A26 60%, #3D352A 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 16px;
  color: #fff;
  animation: maskIn 0.3s ease;
}
.gate-card {
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 400px;
  padding: 32px 28px 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
  animation: modalIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.gate-card h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.gate-sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.gate-help {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 12px;
}
.gate-error { color: var(--err); font-size: 12px; min-height: 16px; margin-top: 8px; }
.gate-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* sticky top bar */
.detail-top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(250, 248, 243, 0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
}
.top-back {
  font-size: 18px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  border-radius: 999px;
  transition: background 0.18s, color 0.18s;
}
.top-back:hover { background: var(--paper-2); color: var(--ink); }
.top-title {
  flex: 1;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
}
.top-study {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.18s, transform 0.06s;
}
.top-study:active { transform: scale(0.97); }
.top-study.on {
  background: var(--accent);
  border-color: var(--accent);
}

/* toast */
.toast {
  position: fixed;
  top: calc(78px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  z-index: 50;
  pointer-events: none;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* main scroll area */
.detail-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px 0;
  animation: pageIn 0.4s ease;
}

/* meta card */
.meta-card {
  padding: 8px 4px 24px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.meta-card h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: var(--ink);
}
.meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 8px;
}
.meta-row.muted {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.tag {
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-weight: 500;
}

/* ---- the reading area (this is where it has to feel premium) ---- */
.sentences {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 0 12px;
}
.sentence {
  padding: 14px 16px;
  border-radius: var(--r-md);
  border-left: 3px solid transparent;
  transition: background 0.25s, border-color 0.25s;
  /* prevent system text selection menu */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  cursor: pointer;
}
.sentence:hover { background: rgba(255, 255, 255, 0.5); }
.sentence.active {
  background: var(--hl-soft);
  border-left-color: var(--accent);
}
.sentence .en {
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1.85;
  letter-spacing: -0.005em;
  color: var(--ink);
  font-weight: 400;
}
.sentence .zh {
  font-size: 13px;
  line-height: 1.65;
  color: var(--muted);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

/* word & collocation spans */
.w {
  display: inline;
  padding: 1px 0;
  border-radius: 3px;
  transition: background 0.12s;
}
.w.selected, .coll.selected .w {
  background: var(--hl-medium);
  color: var(--accent-2);
}
.coll {
  display: inline;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 1px;
}
.coll.selected {
  background: var(--hl-medium);
  border-radius: 3px;
}

.bottom-spacer { height: 140px; }

/* explanation panel — slides in from top, dark, premium */
.explain {
  position: fixed;
  left: 50%;
  transform: translate(-50%, -130%);
  top: calc(80px + env(safe-area-inset-top));
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  width: calc(100% - 28px);
  max-width: 520px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  z-index: 80;
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}
.explain.show { transform: translate(-50%, 0); }
.explain-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.explain-word {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  flex: 1;
  word-break: break-word;
  line-height: 1.2;
  padding-top: 2px;
}
.explain-actions { display: flex; gap: 6px; }
.ico-btn {
  background: rgba(255, 255, 255, 0.08);
  color: var(--paper);
  border: none;
  width: 36px; height: 36px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s, color 0.18s, transform 0.06s;
}
.ico-btn:hover { background: rgba(255, 255, 255, 0.16); }
.ico-btn:active { transform: scale(0.92); }
.ico-btn svg { width: 18px; height: 18px; }
.ico-btn.star.active {
  background: var(--accent);
  color: #fff;
}
.explain-phon {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 14px;
  color: var(--accent-soft);
  margin-top: 6px;
  letter-spacing: 0.02em;
}
.explain-mean {
  font-size: 14px;
  margin-top: 12px;
  line-height: 1.6;
  color: rgba(250, 248, 243, 0.92);
}

/* bottom audio controls */
.detail-bottom {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
  z-index: 30;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
}
.ctrl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  max-width: 760px;
  margin: 0 auto;
}
.speed-wrap {
  position: relative;
}
.speed-btn {
  background: var(--paper-2);
  color: var(--ink);
  border: none;
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  min-width: 56px;
  transition: background 0.18s, transform 0.06s;
}
.speed-btn:hover { background: var(--line); }
.speed-btn:active { transform: scale(0.95); }
.speed-menu {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
  z-index: 90;
  animation: speedIn .18s ease;
}
@keyframes speedIn {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.speed-opt {
  background: transparent;
  border: none;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 8px 20px;
  border-radius: 10px;
  white-space: nowrap;
  transition: background .15s;
}
.speed-opt:hover { background: var(--paper-2); }
.speed-opt.active {
  background: var(--accent);
  color: #fff;
}

.ctrl-btn {
  background: transparent;
  color: var(--ink);
  border: none;
  border-radius: 999px;
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s, transform 0.06s, color 0.18s;
}
.ctrl-btn:hover { background: var(--paper-2); }
.ctrl-btn:active { transform: scale(0.94); }
.ctrl-btn svg { width: 22px; height: 22px; }

.ctrl-btn.play {
  background: var(--ink);
  color: var(--paper);
  width: 60px;
  height: 60px;
  box-shadow: 0 8px 24px -8px rgba(26, 26, 26, 0.4);
}
.ctrl-btn.play:hover { background: var(--accent); }
.ctrl-btn.play svg { width: 26px; height: 26px; }

.ctrl-btn.toggle {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
}
.ctrl-btn.toggle.on {
  background: var(--ink);
  color: var(--paper);
}

/* wordbook export overlay */
.wordbook-overlay {
  position: fixed; inset: 0;
  background: var(--paper);
  z-index: 250;
  display: flex;
  flex-direction: column;
  animation: pageIn 0.3s ease;
}
.wb-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.wb-back {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: color 0.18s;
}
.wb-back:hover { color: var(--ink); }
.wb-title {
  flex: 1;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.wb-copy {
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.18s, transform 0.06s;
}
.wb-copy:hover { background: var(--accent); }
.wb-copy:active { transform: scale(0.96); }
.wb-copy.copied { background: var(--ok); }
.wb-main {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}
.wb-empty {
  text-align: center;
  color: var(--muted-2);
  padding: 80px 20px;
  font-size: 14px;
}
.wb-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  margin-bottom: 12px;
  animation: pageIn 0.3s ease;
}
.wb-phrase {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 17px;
  margin-bottom: 6px;
  color: var(--accent-2);
}
.wb-context {
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--muted);
  line-height: 1.65;
}
.wb-bottom {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}
.wb-bottom .btn { flex: 1; }

/* ---------------- admin ---------------- */
.admin-shell { min-height: 100vh; }
.admin-main {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 24px calc(10vh + 48px);
  animation: pageIn 0.4s ease;
}
.admin-header {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.admin-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex: 1;
}
.admin-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.admin-tools select {
  width: auto;
  padding: 8px 12px;
  font-size: 13px;
}
.back-link {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: color 0.18s;
}
.back-link:hover { color: var(--ink); }

.admin-status {
  padding: 12px 16px;
  border-radius: var(--r-sm);
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
}
.admin-status.info { background: var(--accent-soft); color: var(--accent-2); border-color: var(--accent-soft); }
.admin-status.ok   { background: var(--ok-soft);   color: var(--ok); }
.admin-status.err  { background: var(--err-soft);  color: var(--err); }

.admin-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: 14px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}
.admin-table th {
  background: var(--paper-2);
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: rgba(250, 248, 243, 0.5); }
.admin-table .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-table .empty {
  text-align: center;
  color: var(--muted-2);
  padding: 60px 0;
}

.upload-form {
  background: var(--surface);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.upload-form > label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.upload-form .row.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.upload-form .row.two > label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.upload-form textarea {
  font-family: var(--font-mono);
  font-size: 13px;
  resize: vertical;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  color: var(--ink);
}
.upload-form input, .upload-form select {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  color: var(--ink);
}
.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

/* login */
.login-shell { min-height: 100vh; display: flex; flex-direction: column; }
.login-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  background: var(--surface);
  padding: 40px 36px 32px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 380px;
  animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.login-card h1 {
  margin: 0 0 24px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
}
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-error { color: var(--err); font-size: 13px; font-weight: 500; }
.login-back {
  display: block;
  text-align: center;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  transition: color 0.18s;
}
.login-back:hover { color: var(--ink); }

/* logs */
.log-view {
  background: var(--ink);
  color: #D5CFC0;
  padding: 20px;
  border-radius: var(--r-lg);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 70vh;
  overflow-y: auto;
  border: 1px solid var(--line);
}

/* responsive */
@media (min-width: 768px) {
  .home-main { padding-top: 48px; }
  .brand h1 { font-size: 40px; }
  .row-link { padding: 14px; }
  .meta .title { font-size: 17px; }
  .sentence .en { font-size: 20px; line-height: 1.9; }
  .meta-card h2 { font-size: 32px; }
}
@media (max-width: 600px) {
  .upload-form .row.two { grid-template-columns: 1fr; }
  .upload-form { padding: 20px; }
  .admin-header h1 { font-size: 20px; }
  .admin-table { font-size: 12px; }
  .admin-table th, .admin-table td { padding: 10px 10px; }
  .meta-card h2 { font-size: 22px; }
  .sentence .en { font-size: 17px; line-height: 1.75; }
}
