* { box-sizing: border-box; }
:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e6e8eb;
  --text: #1f2933;
  --muted: #8a94a3;
  --accent: #2f7cf6;
  --ok: #21a366;
  --row-alt: #fafbfc;
}
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}
#app { display: flex; height: 100vh; }

/* Sidebar */
#sidebar {
  width: 230px; flex: 0 0 230px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}
.sidebar-title {
  padding: 18px 20px 10px; font-size: 13px; color: var(--muted);
  letter-spacing: .5px; position: sticky; top: 0; background: var(--panel);
}
#cat-list a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px; color: var(--text); text-decoration: none;
  font-size: 14px; border-left: 3px solid transparent; cursor: pointer;
}
#cat-list a:hover { background: var(--row-alt); }
#cat-list a.active { background: #eef4ff; border-left-color: var(--accent); color: var(--accent); }
#cat-list a .cnt { font-size: 12px; color: var(--muted); }

/* Main */
#main { flex: 1; overflow-y: auto; }
#cat-header {
  position: sticky; top: 0; z-index: 5;
  background: #eef0f3; border-bottom: 1px solid var(--line);
  padding: 18px 28px; display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; justify-content: space-between;
}
#cat-title { margin: 0; font-size: 22px; font-weight: 600; }
#cat-title .sub { font-size: 14px; color: var(--muted); font-weight: 400; margin-left: 8px; }
#toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tool-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 6px;
  padding: 6px 12px; font-size: 13px; cursor: pointer; color: var(--text);
}
.tool-btn:hover { background: var(--row-alt); }
.chk { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 4px; cursor: pointer; }

/* Rows */
#rows { padding: 0 0 60px; }
.row {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 10px 28px; border-bottom: 1px solid var(--line);
  border-left: 5px solid transparent;
}
.row:nth-child(even) { background: var(--row-alt); }
.row.playing { background: #fff7e6; }
/* idx + icon buttons stay aligned to the first line (the input box) */
.idx {
  width: 34px; color: var(--muted); font-variant-numeric: tabular-nums;
  height: 40px; display: flex; align-items: center;
}
.icon-btn {
  background: none; border: none; cursor: pointer; font-size: 18px;
  height: 40px; display: flex; align-items: center; justify-content: center;
  padding: 0 4px; line-height: 1; color: #444; border-radius: 6px;
}
.icon-btn:hover { background: #eceff3; }
.icon-btn.on { color: var(--accent); }
.icon-btn.error { color: #c0392b; cursor: not-allowed; opacity: .5; }

.answer-cell { flex: 1; min-width: 0; }
.input-line { display: flex; align-items: center; gap: 12px; }
.spell {
  width: 340px; max-width: 50%;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 15px; background: #fbfcfd; outline: none;
}
.spell:focus { border-color: var(--accent); background: #fff; }
.spell.correct { border-color: var(--ok); background: #f0fbf5; color: var(--ok); }

.reveal { font-size: 15px; color: var(--text); }
.reveal .w { font-weight: 600; }
.reveal .alt { color: var(--muted); font-weight: 400; }
.reveal .mean { color: #5a6573; margin-left: 8px; }
.reveal .ex { display: block; margin-top: 4px; color: #46505d; font-size: 14px; }
.reveal .ex b { color: var(--accent); font-weight: 600; }
.hidden { display: none; }

.pos {
  width: 70px; text-align: right; color: var(--muted); font-style: italic;
  flex: 0 0 auto; height: 40px; display: flex; align-items: center; justify-content: flex-end;
}

@media (max-width: 640px) {
  #sidebar { display: none; }
  .spell { max-width: 100%; width: 100%; }
}
