:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1d1f23;
  --muted: #6b7280;
  --line: #e3e5e9;
  --accent: #2f6fdb;
  --accent-text: #ffffff;
  --danger: #c43c3c;
  --field: #ffffff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --card: #1f2226;
    --text: #eef0f3;
    --muted: #9aa0aa;
    --line: #30343a;
    --accent: #4a86ec;
    --danger: #e06666;
    --field: #17191c;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
}
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--card);
}
.brand { color: var(--text); text-decoration: none; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.logo {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: var(--accent-text); font-size: 16px;
}
.muted { color: var(--muted); font-weight: 400; }
main { max-width: 960px; margin: 0 auto; padding: 24px 16px 48px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.narrow { max-width: 520px; margin: 40px auto; padding: 28px; }
h1 { font-size: 20px; margin: 0 0 8px; }
h2 { font-size: 18px; margin: 0 0 12px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 4px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 14px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--field); color: var(--text); font: inherit;
}
input[type="checkbox"] { width: auto; padding: 0; margin: 0; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
#key { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: 1px; text-transform: uppercase; }
button {
  font: inherit; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); cursor: pointer; white-space: nowrap;
}
button:hover { border-color: var(--muted); }
button:disabled { opacity: .6; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.quiet { border-color: transparent; background: transparent; }
button.danger { color: var(--danger); }
#login-button { width: 100%; margin-top: 18px; padding: 12px; }
.error { color: var(--danger); white-space: pre-line; min-height: 1em; margin: 8px 0 0; }
.note { color: var(--muted); font-size: 13px; }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stats b { display: block; font-size: 22px; }
.stats span { color: var(--muted); font-size: 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.toolbar input { flex: 1 1 220px; width: auto; }
.list { overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
td.word { font-weight: 600; word-break: break-all; }
td.reading { color: var(--muted); }
td.pos { font-size: 13px; }
td.ops { text-align: right; }
td.ops button { padding: 5px 10px; font-size: 13px; margin-left: 4px; }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; margin: 0; }
dialog {
  border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: min(460px, calc(100vw - 32px));
  background: var(--card); color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, .4); }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 14px;
}
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .stats { gap: 8px; }
  .stats div { padding: 10px 12px; }
  .stats b { font-size: 18px; }
  th, td { padding: 9px 10px; }
  .toolbar button { flex: 1 1 auto; }
}
