:root{
  --bg:#0b1220;
  --bg-accent:#132043;
  --muted:#9fb0d0;
  --text:#eef2ff;
  --good:#4ade80;
  --bad:#f87171;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 18px;
  --panel-bg: rgba(255,255,255,.04);
  --panel-border: rgba(255,255,255,.08);
  --surface: rgba(0,0,0,.12);
  --surface-strong: rgba(0,0,0,.18);
  --surface-border: rgba(255,255,255,.12);
  --input-bg: rgba(0,0,0,.2);
  --input-border: rgba(255,255,255,.14);
  --table-head-bg: rgba(255,255,255,.03);
  --reveal-bg: rgba(124,156,255,.12);
  --reveal-border: rgba(124,156,255,.25);
  --tag-bg: rgba(124,156,255,.22);
  --tag-text: #cfe0ff;
  --modal-bg: #0f1a34;
  --modal-border: rgba(255,255,255,.12);
  --backdrop: rgba(7,12,26,.6);
  --btn-info-bg: rgba(255,255,255,.12);
  --btn-info-border: rgba(255,255,255,.12);
}
body[data-theme="light"]{
  --bg:#f3f5ff;
  --bg-accent:#ffffff;
  --muted:#5d6c8a;
  --text:#1b2437;
  --shadow: 0 14px 30px rgba(30,44,70,.12);
  --panel-bg: rgba(18,28,58,.05);
  --panel-border: rgba(18,28,58,.12);
  --surface: rgba(18,28,58,.06);
  --surface-strong: rgba(18,28,58,.08);
  --surface-border: rgba(18,28,58,.12);
  --input-bg: rgba(18,28,58,.05);
  --input-border: rgba(18,28,58,.18);
  --table-head-bg: rgba(18,28,58,.06);
  --reveal-bg: rgba(67,112,255,.12);
  --reveal-border: rgba(67,112,255,.3);
  --tag-bg: rgba(67,112,255,.18);
  --tag-text: #2a3f7b;
  --modal-bg: #ffffff;
  --modal-border: rgba(18,28,58,.14);
  --backdrop: rgba(18,28,58,.35);
  --btn-info-bg: rgba(18,28,58,.08);
  --btn-info-border: rgba(18,28,58,.12);
}
*{box-sizing:border-box}
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 700px at 10% 0%, var(--bg-accent) 0%, var(--bg) 55%);
  color:var(--text);
  min-height:100vh;
  display:flex;
  justify-content:center;
}
body.study-active{
  overflow:hidden;
  height:100vh;
}
.wrap{
  width:min(920px, 100%);
  padding:18px 14px 22px;
  display:flex;
  flex-direction:column;
  gap:14px;
  min-height:100vh;
}
body.study-active .wrap{
  height:100vh;
  min-height:0;
}
header{display:flex; align-items:flex-start; justify-content:space-between; gap:12px;}
.header-actions{display:flex; align-items:center; gap:10px;}
h1{font-size:18px; margin:0; letter-spacing:.2px;}
.sub{margin-top:4px; font-size:12.5px; color:var(--muted); line-height:1.35;}
.panel{
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding:12px;
  box-shadow: var(--shadow);
}
.row{display:flex; gap:10px; flex-wrap:wrap; align-items:center}
.row > *{flex: 1 1 auto}
.btn{
  -webkit-tap-highlight-color: transparent;
  border:0;
  border-radius: 14px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding: 14px 14px;
  font-weight: 800;
  font-size: 16px;
  color: #081028;
  background: #dbe3ff;
  cursor:pointer;
  box-shadow: 0 8px 20px rgba(0,0,0,.25);
  min-height:48px;
}
.btn:active{transform: scale(.99)}
.btn.secondary{
  background: rgba(255,255,255,.08);
  color: var(--text);
  border: 1px solid rgba(255,255,255,.10);
  box-shadow:none;
}
.btn.good{background: color-mix(in srgb, var(--good) 85%, white); }
.btn.bad{background: color-mix(in srgb, var(--bad) 85%, white); }
.btn.info{
  width:40px;
  height:40px;
  min-height:40px;
  padding:0;
  border-radius:999px;
  font-size:18px;
  line-height:1;
  font-weight:900;
  background: var(--btn-info-bg);
  color: var(--text);
  border: 1px solid var(--btn-info-border);
  box-shadow:none;
}
.btn.info.theme{
  font-size:19px;
}
.btn.info.text{
  width:auto;
  min-width:120px;
  height:40px;
  min-height:40px;
  padding:0 14px;
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.6px;
}
.btn.small{
  min-height:36px;
  padding:8px 12px;
  font-size:13px;
}
.toggle{
  display:flex;
  gap:10px;
  align-items:center;
  padding:10px 12px;
  border-radius: 14px;
  border:1px solid var(--panel-border);
  background: var(--panel-bg);
  min-height:48px;
  user-select:none;
}
.toggle input{width:18px; height:18px;}
.drop{display:flex; flex-direction:column; gap:8px;}
.load-controls{
  display:flex;
  gap:10px;
  align-items:flex-end;
  flex-wrap:wrap;
}
.field{
  display:flex;
  flex-direction:column;
  gap:6px;
  flex: 1 1 320px;
  font-size:12.5px;
  color: var(--muted);
}
.field select{
  min-height:44px;
  border-radius:12px;
  border:1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  padding:10px 12px;
  font-size:14px;
}
.file-picker{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}
.file-picker input{display:none;}
.btn.browse{
  min-width:160px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
}
.preview{
  display:flex;
  flex-direction:column;
  gap:10px;
  margin-top:8px;
}
.preview-controls{
  align-items:center;
  gap:12px;
}
.filter{
  display:flex;
  flex-direction:column;
  gap:6px;
  flex: 1 1 320px;
  font-size:13px;
  color: var(--muted);
}
.filter-row{
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
}
.filter input{
  flex:1 1 320px;
  min-width:220px;
  border-radius:12px;
  border:1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  padding:10px 12px;
  font-size:14px;
}
.filter-count{
  min-width:120px;
}
.table-wrap{
  overflow:auto;
  border-radius: 14px;
  border:1px solid var(--surface-border);
  background: var(--surface);
}
.table-wrap table{
  width:100%;
  border-collapse: collapse;
  min-width:520px;
}
.table-wrap th,
.table-wrap td{
  text-align:left;
  padding:10px 12px;
  border-bottom:1px solid var(--panel-border);
  vertical-align:top;
}
.table-wrap th{
  font-size:13px;
  text-transform:uppercase;
  letter-spacing:.4px;
  color: var(--muted);
  background: var(--table-head-bg);
}
.table-wrap tbody tr:last-child td{border-bottom:none;}
.dropzone{
  border:1.5px dashed var(--panel-border);
  background: var(--panel-bg);
  border-radius: var(--radius);
  padding:14px;
  text-align:center;
  color: var(--muted);
  font-size:13px;
  line-height:1.35;
}
.dropzone strong{color: var(--text)}
.card{
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel-bg) 90%, transparent), color-mix(in srgb, var(--panel-bg) 70%, transparent));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding:16px;
  box-shadow: var(--shadow);
  display:flex;
  flex-direction:column;
  gap:14px;
  min-height: 52vh;
  max-height: 100%;
}
body.study-active .card{
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}
.card-body{
  display:flex;
  flex-direction:column;
  gap:14px;
  flex:1;
  overflow:auto;
  padding-right:4px;
}
body.study-active .card-body{
  min-height:0;
}
.card-section{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.topline{
  display:flex; align-items:center; justify-content:space-between; gap:10px;
  color: var(--muted); font-size: 12.5px;
}
.topline-info{
  display:flex;
  flex-direction:column;
  gap:4px;
}
.q{font-size: 18px; line-height:1.35; font-weight: 900; margin: 2px 0 0;}
.answers{display:grid; gap:10px; margin-top:4px;}
.ans{
  border-radius: 14px;
  border:1px solid var(--surface-border);
  background: var(--surface);
  padding: 12px;
  line-height:1.35;
  color: var(--text);
  font-size: 15px;
}
.ans .tag{
  display:inline-flex;
  min-width: 26px;
  height: 24px;
  border-radius: 999px;
  align-items:center;
  justify-content:center;
  margin-right:8px;
  padding: 0 8px;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-weight: 900;
  font-size: 12.5px;
}
.reveal{
  border-radius: 14px;
  border: 1px solid var(--reveal-border);
  background: var(--reveal-bg);
  padding: 12px;
  line-height:1.4;
  display:none;
  white-space: pre-wrap;
}
.reveal h3{margin:0 0 6px 0; font-size: 14px; color:var(--text); letter-spacing:.2px;}
.reveal .correct{font-weight: 950; margin-bottom: 6px; color: var(--text);}
.reveal .explain{color: var(--muted); opacity:.95; font-size: 14px;}
.wrong-wrap{margin-top:10px; display:flex; flex-direction:column; gap:6px;}
.wrong-wrap h4{margin:0; font-size:13px; color:var(--text); letter-spacing:.2px;}
.wrong-list{display:flex; flex-direction:column; gap:6px;}
.wrong-item{
  border-radius: 12px;
  border:1px solid var(--surface-border);
  background: var(--surface);
  padding: 10px;
}
.wrong-answer{font-weight: 700; color:var(--text); margin-bottom:4px;}
.wrong-explain{color:var(--muted); opacity:.9; font-size: 13px;}
.actions{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
}
.actions.single{grid-template-columns: 1fr;}
footer{color:var(--muted); font-size:12px; text-align:center; padding: 2px 6px 0;}
footer .version{margin-top:4px; font-size:11px; opacity:.85;}
.modal-backdrop{
  position:fixed;
  inset:0;
  background: var(--backdrop);
  display:none;
  align-items:center;
  justify-content:center;
  padding:16px;
  z-index:100;
}
.modal-backdrop.active{display:flex;}
.modal{
  width:min(520px, 100%);
  max-width:95vw;
  max-height:95vh;
  background: var(--modal-bg);
  border:1px solid var(--modal-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding:16px;
  display:flex;
  flex-direction:column;
}
.modal-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:8px;
}
.modal-actions{
  display:flex;
  align-items:center;
  gap:8px;
}
.modal-header h2{
  margin:0;
  font-size:16px;
  letter-spacing:.3px;
}
.modal-body{
  color: var(--muted);
  font-size:13.5px;
  line-height:1.5;
  overflow:auto;
}
.modal-body strong{color: var(--text);}
.modal-body ul{padding-left:18px; margin:10px 0 0;}
.modal-body li{margin:4px 0;}
.modal-body .csv-rules{
  margin:0;
  padding:12px;
  border-radius: 12px;
  border:1px solid var(--surface-border);
  background: var(--surface-strong);
  color: var(--text);
  font-size:13px;
}
.modal-body .csv-rules h1,
.modal-body .csv-rules h2,
.modal-body .csv-rules h3{
  margin:0 0 8px;
  color: var(--text);
  letter-spacing:.2px;
}
.modal-body .csv-rules h1{font-size:16px;}
.modal-body .csv-rules h2{font-size:14px;}
.modal-body .csv-rules h3{font-size:13.5px;}
.modal-body .csv-rules p{margin:0 0 8px;}
.modal-body .csv-rules ul,
.modal-body .csv-rules ol{
  margin:0 0 8px;
  padding-left:18px;
}
.modal-body .csv-rules li{margin:4px 0;}
.modal-body .csv-rules code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  padding:2px 6px;
  border-radius:8px;
  background: rgba(255,255,255,.08);
  color: #e9efff;
}
.modal-body .csv-rules pre{
  margin:0 0 8px;
  padding:10px 12px;
  border-radius: 10px;
  border:1px solid var(--surface-border);
  background: var(--surface);
  overflow:auto;
}
.modal-body .csv-rules pre code{
  background: none;
  padding:0;
  font-size:12px;
}
@media (min-width: 760px){
  .wrap{padding:22px}
  h1{font-size:20px}
  .q{font-size:22px}
  .card{min-height: 56vh; padding:18px}
}
