:root {
  --bg: #f6f7fb; --surface: #ffffff; --surface2: #eef0f6; --text: #1b1d28; --muted: #6b7083;
  --border: #dde0ea; --primary: #4f46e5; --primary-text: #fff; --danger: #dc2626;
  --ok: #059669; --warn: #d97706; --radius: 12px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12131a; --surface: #1c1e28; --surface2: #262935; --text: #e9eaf0; --muted: #9a9eb2;
    --border: #2f3240; --primary: #818cf8; --primary-text: #0e0f16; --danger: #f87171;
    --ok: #34d399; --warn: #fbbf24; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--surface);
  border-bottom: 1px solid var(--border); }
.topbar h1 { font-size: 18px; margin: 0; flex: 1; }
.actions { display: flex; gap: 6px; }
.btn { border: 1px solid var(--border); background: var(--surface); padding: 7px 12px;
  border-radius: 9px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface2); }
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn.danger { color: var(--danger); }
.btn.icon { padding: 7px 10px; }
.menu { position: absolute; right: 16px; top: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.15); padding: 6px; display: flex;
  flex-direction: column; min-width: 200px; }
.menu[hidden] { display: none; }
.menu button { text-align: left; background: none; border: 0; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--surface2); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.danger { color: var(--danger); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px 0; }
.filters input, .filters select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); min-width: 0; }
.filters input { flex: 1 1 220px; }
.filters select { flex: 1 1 150px; }
.summary { margin: 10px 16px 0; color: var(--muted); font-size: 13px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; padding: 12px 16px 40px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; display: flex; flex-direction: column; }
.card:hover { border-color: var(--primary); }
.card .thumb { height: 150px; background: var(--surface2); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.card .thumb span { color: var(--muted); font-size: 13px; }
.card .body { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.card .title { font-weight: 600; }
.card .sub { color: var(--muted); font-size: 13px; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--surface2); }
.tag.st-tekrar { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.tag.st-ogrendim { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.tag.untagged { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.ans { font-size: 13px; }
.ans b.wrong { color: var(--danger); } .ans b.right { color: var(--ok); }

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

dialog { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text);
  padding: 18px; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); }
dialog.wide { width: min(900px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(10,10,20,.55); }
dialog h2 { margin: 0 0 12px; font-size: 18px; }
form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 10px; flex: 1; min-width: 0; }
form input, form select, form textarea { padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); color: var(--text); width: 100%; }
.row { display: flex; gap: 10px; }
.row.three label { flex: 1; }
.dropzone { position: relative; border: 2px dashed var(--border); border-radius: var(--radius); min-height: 120px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 12px; overflow: hidden; text-align: center; color: var(--muted); padding: 8px; }
.dropzone.over { border-color: var(--primary); }
.dropzone img { max-width: 100%; max-height: 260px; }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dlg-actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.dlg-actions.center { justify-content: center; }
.spacer { flex: 1; }
.muted { color: var(--muted); font-size: 13px; }

.view img { width: 100%; max-height: 62vh; object-fit: contain; background: #fff; border-radius: 10px; }
.meta { margin-top: 12px; display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 14px; }
.meta dt { color: var(--muted); } .meta dd { margin: 0; }
.meta[hidden] { display: none; }
.review-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; color: var(--muted); }

.stat-block { margin-bottom: 18px; }
.stat-block h3 { font-size: 14px; margin: 0 0 8px; }
.bar { display: grid; grid-template-columns: minmax(90px, 180px) 1fr 40px; gap: 8px; align-items: center; font-size: 13px; margin-bottom: 4px; }
.bar .track { background: var(--surface2); border-radius: 6px; height: 12px; overflow: hidden; }
.bar .fill { background: var(--primary); height: 100%; border-radius: 6px; }
.bar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 18px; }
.kpi { background: var(--surface2); border-radius: 10px; padding: 10px 12px; }
.kpi b { display: block; font-size: 22px; }
.kpi span { color: var(--muted); font-size: 12px; }

.toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 100; font-size: 14px; }

@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; }
  .topbar h1 { flex-basis: 100%; }
  .actions { width: 100%; }
  .actions .btn { flex: 1; padding: 7px 6px; }
  .actions .btn.icon { flex: 0 0 auto; }
  .row { flex-direction: column; gap: 0; }
  .row.three { flex-direction: row; gap: 8px; }
  .grid { grid-template-columns: 1fr; }
}

/* Kilit ekranı */
body.locked > :not(#lock):not(script) { display: none !important; }
.lock { display: none; }
body.locked .lock { display: flex; position: fixed; inset: 0; align-items: center; justify-content: center; padding: 16px; background: var(--bg); z-index: 1000; }
.lock-box { width: min(340px, 100%); display: flex; flex-direction: column; gap: 10px; text-align: center; align-items: stretch; }
.lock-box img { align-self: center; border-radius: 18px; }
.lock-box h1 { font-size: 20px; margin: 4px 0 0; }
.lock-box p { margin: 0; }
.lock-box input { padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-size: 16px; text-align: center; }
.lock-box input[hidden] { display: none; }
.lock-box .btn { padding: 11px; font-size: 16px; }
.lock-err { color: var(--danger); font-size: 14px; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 13px; }
.link[hidden] { display: none; }

/* Yapay zekâ */
.ai-progress { margin: 8px 16px 0; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.ai-progress[hidden] { display: none; }
.ai-progress .track { flex: 1; background: var(--surface2); height: 8px; border-radius: 6px; overflow: hidden; }
.ai-progress .fill { display: block; height: 100%; width: 0; background: var(--primary); transition: width .3s; }
.tag.ai-wait { background: color-mix(in srgb, var(--primary) 15%, transparent); color: var(--primary); }
.tag.ai-check { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.tag.ai-err { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
label.check input { width: auto; }
