/* study.0426.fun 全站样式：一份文件，无构建，移动端优先。 */

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1f2328;
  --muted: #6b7280;
  --line: #e2e5ea;
  --accent: #2563eb;
  --accent-soft: #eaf0ff;
  --danger: #d92d20;
  --ok: #0f7b3f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

/* hidden 属性要能压过 .settings-row / label 上的 display:flex，否则 JS 隐藏不生效 */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 600; }

/* ---------- 顶栏 ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { font-weight: 600; color: var(--text); }
.brand:hover { text-decoration: none; }

.topnav { display: flex; align-items: center; gap: 14px; font-size: 14px; color: var(--muted); }
.topnav .who { color: var(--muted); }

/* ---------- 布局 ---------- */

.wrap { max-width: 880px; margin: 0 auto; padding: 18px 16px 48px; }
.wrap.narrow { max-width: 380px; }

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.page-title { font-size: 20px; }
.sub { color: var(--muted); font-size: 13px; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 14px;
}

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar .spacer { flex: 1; }

/* ---------- 首页卡片 ---------- */

.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
}

.card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.card-name { font-weight: 600; font-size: 17px; }
.card-desc { color: var(--muted); font-size: 13px; }

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { border-color: #c9cfd8; text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #1d4fd8; border-color: #1d4fd8; }
.btn-danger { color: var(--danger); border-color: #f3c9c4; background: #fff6f5; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 14px; }
.btn-lg { min-height: 52px; padding: 12px 18px; font-size: 17px; }
.btn-block { width: 100%; }

/* ---------- 表单 ---------- */

input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  padding: 9px 10px;
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

textarea { resize: vertical; min-height: 132px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; }

label.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }

.field { margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }

/* ---------- 表格 ---------- */

.table-scroll { overflow-x: auto; }

table.grid { width: 100%; border-collapse: collapse; font-size: 15px; }
table.grid th, table.grid td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.grid th { font-size: 13px; font-weight: 500; color: var(--muted); background: #fafbfc; white-space: nowrap; }
table.grid td.num { color: var(--muted); font-size: 13px; text-align: right; }
table.grid td.ops { white-space: nowrap; }
table.grid input[type="text"] { border-color: transparent; background: transparent; padding: 6px 6px; min-width: 0; }

/* 固定列宽，避免小屏把操作列挤出容器 */
table.items-table { table-layout: fixed; }
table.items-table th:nth-child(1), table.items-table td:nth-child(1) { width: 34px; }
table.items-table th:nth-child(2), table.items-table td:nth-child(2) { width: 34px; }
table.items-table th:last-child, table.items-table td:last-child { width: 108px; }

.col-sel { text-align: center; }
.col-sel input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }

table.lists-table { table-layout: fixed; }
table.lists-table th:nth-child(2), table.lists-table td:nth-child(2) { width: 56px; }
table.lists-table th:nth-child(3), table.lists-table td:nth-child(3) { width: 150px; }
table.lists-table th:last-child, table.lists-table td:last-child { width: 176px; }
table.grid input[type="text"]:hover { border-color: var(--line); }
table.grid input[type="text"]:focus { border-color: var(--accent); background: #fff; }

.empty { padding: 24px 8px; color: var(--muted); text-align: center; }

/* ---------- 提示 / 状态 ---------- */

.msg { font-size: 14px; padding: 8px 10px; border-radius: 8px; margin-bottom: 12px; }
.msg-error { background: #fdf1f0; color: var(--danger); border: 1px solid #f6d3cf; }
.msg-ok { background: #eff9f2; color: var(--ok); border: 1px solid #cdebd8; }
.msg-warn { background: #fff8e6; color: #8a5b00; border: 1px solid #f2e2b5; }
.hint { color: var(--muted); font-size: 13px; }

/* ---------- 导入区 ---------- */

details.import > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 4px 0;
  list-style: none;
}
details.import > summary::-webkit-details-marker { display: none; }
details.import > summary::before { content: "▸ "; color: var(--muted); }
details.import[open] > summary::before { content: "▾ "; }

.import-step { margin: 14px 0; }
.import-step h3 { font-size: 15px; margin-bottom: 6px; }
.import-step ol, .import-step ul { margin: 6px 0; padding-left: 22px; color: var(--muted); font-size: 14px; }

.unparsed {
  max-height: 180px;
  overflow: auto;
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---------- 播放页 ---------- */

.player-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.player-title { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.counter { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; white-space: nowrap; }

.stage {
  position: relative;
  min-height: 168px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px;
  margin-bottom: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
  cursor: pointer;
  user-select: none;
}

.stage .answer { font-size: 30px; font-weight: 600; letter-spacing: .5px; word-break: break-word; }
.stage .answer-zh { font-size: 17px; color: var(--muted); }

.stage .answer-zh.masked-zh { filter: blur(7px); opacity: .5; }
.stage.masked .answer, .stage.masked .answer-zh { filter: blur(9px); opacity: .55; }
.stage.masked::after {
  content: attr(data-hint);
  position: absolute;
  inset: auto 0 10px;
  font-size: 12px;
  color: var(--muted);
  filter: none;
}
.stage .skip-note { font-size: 13px; color: #8a5b00; }

.bar { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; margin: 6px 0 14px; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s linear; }

.controls { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.controls .wide, .controls .stop { grid-column: span 2; }
@media (min-width: 640px) {
  .controls { grid-template-columns: repeat(6, 1fr); }
  .controls .wide, .controls .stop { grid-column: auto; }
}

.settings { margin-top: 14px; }
.settings-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; padding: 8px 0; border-top: 1px dashed var(--line); }
.settings-row:first-of-type { border-top: none; }
.settings-row > label { font-size: 14px; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.settings-row select { width: auto; }
input[type="range"] { width: 140px; accent-color: var(--accent); }

.done-box { text-align: center; padding: 20px 8px; }
.done-box p { color: var(--muted); }

/* ---------- 小屏 ---------- */

@media (max-width: 560px) {
  .wrap { padding: 14px 12px 40px; }
  .stage .answer { font-size: 24px; }
  .btn { min-height: 44px; }
  table.grid td.ops .btn { min-height: 30px; padding: 2px 6px; }
  table.lists-table th:nth-child(3), table.lists-table td:nth-child(3) { display: none; }
  table.grid td.ops .btn { font-size: 13px; }

  /* 条目表格在小屏改成「一行三行」的卡片式，英文/中文各占满宽度，避免被挤成几个字 */
  table.items-table thead { display: none; }
  table.items-table tbody tr {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    grid-template-areas:
      "sel num . ops"
      "en en en en"
      "zh zh zh zh";
    align-items: center;
    gap: 6px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }
  table.items-table tbody tr:last-child { border-bottom: none; }
  table.items-table td { border: none; padding: 0; width: auto !important; }
  table.items-table td.col-sel { grid-area: sel; }
  table.items-table td.num { grid-area: num; text-align: left; }
  table.items-table td.ops { grid-area: ops; justify-self: end; }
  table.items-table td:nth-child(3) { grid-area: en; }
  table.items-table td:nth-child(4) { grid-area: zh; }
  table.items-table td input[type="text"] {
    border-color: var(--line);
    background: #fff;
    padding: 8px 9px;
  }
  table.items-table td.ops .btn { min-height: 30px; }
}
