:root {
  --bg: #f6f6f3;
  --card: #ffffff;
  --ink: #1d211c;
  --muted: #6d746b;
  --line: #e4e5df;
  --accent: #2f6f5e;
  --accent-soft: #e7f0ec;
  --danger: #b4483c;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(29, 33, 28, .05), 0 8px 24px rgba(29, 33, 28, .05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: .01em; }
p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }

/* ---------------------------------------------------------------- brand --- */
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 14px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 9px;
  background: radial-gradient(circle at 30% 25%, #4d8f7d, var(--accent));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
}
.brand h1 { font-size: 17px; letter-spacing: .04em; }
.brand p { font-size: 12px; color: var(--muted); }
.brand-lg { padding: 0 0 20px; }
.brand-lg h1 { font-size: 22px; }

/* ---------------------------------------------------------------- login --- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 360px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow);
  padding: 28px;
}

/* ------------------------------------------------------------------ app --- */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100%; }

.sidebar {
  background: var(--card);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.nav { padding: 6px 10px; flex: 1; overflow-y: auto; }
.nav-label {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); padding: 14px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--ink); text-decoration: none; font-size: 13.5px;
}
.nav-item:hover { background: #f2f3ef; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: #cfd3ca; flex: none; }
.dot.live { background: var(--accent); }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 12px 18px; display: flex; justify-content: space-between; align-items: center;
  font-size: 12.5px; color: var(--muted);
}
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 12.5px; }
.link:hover { text-decoration: underline; }

.main { padding: 28px 32px 48px; max-width: 1180px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.page-head h2 { font-size: 20px; margin-bottom: 4px; }

.grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .grid { grid-template-columns: 1fr; }
  .main { padding: 20px; }
}

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px;
}
.side { display: grid; gap: 18px; }
.empty { text-align: center; padding: 48px 18px; }

/* ----------------------------------------------------------------- form --- */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 9px;
  background: #fcfcfa; color: var(--ink);
  font: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: #fff; }
.row.three { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 620px) { .row.three { grid-template-columns: 1fr; } }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 9px 16px; border-radius: 9px; font: inherit; cursor: pointer;
}
.btn:hover { border-color: #cfd3ca; background: #fafaf7; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #295e50; }
.btn.small { padding: 6px 12px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--danger); background: #f7ecea; }
.btn:disabled { opacity: .55; cursor: default; }

.actions { display: flex; align-items: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

.list-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; font-weight: 600; margin: 6px 0 10px;
}

/* ---------------------------------------------------------------- words --- */
.word-list { display: grid; gap: 12px; }
.word-card {
  border: 1px solid var(--line); border-radius: 10px; padding: 14px;
  background: #fdfdfb;
}
.word-card-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--muted); margin-bottom: 8px;
}
.word-grid { display: grid; grid-template-columns: 1.1fr 1fr .7fr; gap: 10px; }
.word-grid .wide { grid-column: 1 / -1; }
@media (max-width: 620px) { .word-grid { grid-template-columns: 1fr; } .word-grid .wide { grid-column: auto; } }

/* ----------------------------------------------------------------- pill --- */
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 600;
}

/* --------------------------------------------------------------- tables --- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-weight: 600; color: var(--muted);
  font-size: 12px; padding: 8px 6px; border-bottom: 1px solid var(--line);
}
.table td { padding: 10px 6px; border-bottom: 1px solid #f0f1ec; }
.table tr:last-child td { border-bottom: 0; }

.dev-list, .log-list { list-style: none; margin: 0; padding: 0; }
.dev-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid #f0f1ec; font-size: 13px;
}
.dev-list li:last-child { border-bottom: 0; }
.dev-id { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.log-list li { padding: 7px 0; border-bottom: 1px solid #f0f1ec; font-size: 12.5px; color: var(--muted); }
.log-list li:last-child { border-bottom: 0; }

/* ---------------------------------------------------------------- toast --- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px;
  border-radius: 999px; font-size: 13px; box-shadow: var(--shadow); z-index: 50;
}
.toast.error { background: var(--danger); }

.error { color: var(--danger); font-size: 12.5px; margin: 4px 0 10px; }

/* ------------------------------------------------------------ audio field -- */
.audio-row { display: flex; gap: 8px; align-items: center; }
.audio-row input { flex: 1 1 auto; min-width: 0; }
.audio-row .btn { flex: none; }
.audio-row .link { flex: none; }

/* --------------------------------------------------------------- repeat ---- */
.repeat { display: grid; gap: 12px; margin-bottom: 6px; }
.repeat .word-card { position: relative; }
.repeat .word-card > .btn.ghost.small { position: absolute; right: 10px; bottom: 8px; }
.repeat-index { color: var(--muted); }

/* ----------------------------------------------------------------- tags ---- */
.tag {
  font-size: 11px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px;
}
