:root {
  --bg: #eef3f8;
  --panel: #ffffff;
  --ink: #132132;
  --muted: #5f6f80;
  --line: #d7e1ea;
  --primary: #006f6d;
  --accent: #d97d17;
  --danger: #c7413d;
  --radius: 8px;
  --shadow: 0 12px 24px rgba(10, 36, 66, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  font-family: "SF Pro Text", "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background:
    radial-gradient(circle at 8% -10%, rgba(0, 111, 109, 0.18), transparent 36%),
    radial-gradient(circle at 95% 0%, rgba(217, 125, 23, 0.14), transparent 38%),
    var(--bg);
}

h1,
p {
  margin: 0;
}

input,
select,
button {
  font: inherit;
}

.page-shell {
  width: min(1580px, calc(100vw - 16px));
  margin: 8px auto;
  display: grid;
  gap: 8px;
}

.topbar,
.control-panel,
.summary-panel,
.table-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.topbar {
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  background: linear-gradient(140deg, var(--primary), var(--accent));
}

.eyebrow {
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  font-size: 20px;
  line-height: 1.2;
}

.back-link {
  min-height: 34px;
  padding: 0 12px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius);
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  background: linear-gradient(140deg, var(--primary), #005b59);
}

.control-panel {
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.control-row {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.control-row label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.control-row input,
.control-row select {
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fbfe;
}

#searchInput {
  width: min(420px, 100%);
}

#fromInput,
#toInput,
#minWrongInput,
#minAttemptInput {
  width: 76px;
}

.checks {
  justify-content: flex-end;
  align-items: center;
}

.checks label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.checks button {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius);
  color: var(--ink);
  font-weight: 700;
  background: #e8eef5;
  cursor: pointer;
}

.summary-panel {
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.summary-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: #fbfdff;
}

.summary-card span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-card strong {
  font-size: 21px;
}

.table-panel {
  min-height: 0;
  padding: 8px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  min-width: 1680px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  background: #f6f9fc;
}

thead th.sortable {
  cursor: pointer;
  user-select: none;
}

thead th.sortable::after {
  content: "↕";
  margin-left: 4px;
  color: #97a7b7;
  font-size: 11px;
}

thead th.sortable.sorted.asc::after {
  content: "↑";
  color: var(--primary);
}

thead th.sortable.sorted.desc::after {
  content: "↓";
  color: var(--primary);
}

thead th.sortable:focus-visible {
  outline: 2px solid rgba(0, 111, 109, 0.35);
  outline-offset: -2px;
}

tbody td {
  padding: 7px 6px;
  border-bottom: 1px solid #edf2f6;
  font-size: 13px;
  vertical-align: top;
}

tbody tr:hover {
  background: #f8fcff;
}

td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

td.emph {
  font-weight: 700;
}

th.num-col {
  text-align: right;
}

td.example {
  min-width: 220px;
}

.line-main {
  color: #163149;
}

.blank-fill {
  text-decoration-line: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
  color: #0f3252;
  font-weight: 700;
}

.danger {
  color: var(--danger);
}

.hint {
  color: #2e77c8;
}

.muted {
  color: var(--muted);
}

.empty {
  display: none;
  padding: 14px;
  color: var(--muted);
  text-align: center;
}

.table-panel.is-empty table {
  display: none;
}

.table-panel.is-empty .empty {
  display: block;
}

@media (max-width: 1260px) {
  .control-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .control-panel {
    grid-template-columns: 1fr;
  }

  .summary-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .checks {
    justify-content: flex-start;
  }
}
