:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  /* Ana renk: zeytin yeşili (2026-11-25'te maviden değişti). "Doğru cevap" yeşili (--ok) bilerek
     ayrı ve daha canlıdır; anahtarsız seçili şık ise ana renkle değil nötr tonla (--pick) gösterilir,
     böylece "seçili" ile "doğru" karışmaz. */
  --primary: #58732e;
  --primary-text: #ffffff;
  --soft: #edf1e1;
  --pick: #374151;
  --pick-text: #ffffff;
  --ok: #16a34a;
  --bad: #dc2626;
  --warn-bg: #fef3c7;
  --warn-text: #92400e;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --card: #1a1f29;
    --text: #f3f4f6;
    --muted: #9ca3af;
    --line: #2b3240;
    --primary: #a3be6c;
    --primary-text: #141a0c;
    --soft: #27311a;
    --pick: #d1d5db;
    --pick-text: #111827;
    --warn-bg: #3b2f0b;
    --warn-text: #fcd34d;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--primary); }
[hidden] { display: none !important; }

#app { max-width: 720px; margin: 0 auto; padding-bottom: env(safe-area-inset-bottom); }
main { padding: 14px 16px 40px; }

/* Üst çubuk */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 6px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.bar h1 { flex: 1; margin: 0; font-size: 19px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back {
  width: 40px; height: 40px; display: grid; place-items: center;
  font-size: 30px; line-height: 1; text-decoration: none; color: var(--primary); border-radius: 10px;
}
.icon-btn {
  min-width: 40px; height: 40px; padding: 0 10px; border: 0; border-radius: 10px;
  background: transparent; color: var(--primary); font-size: 16px; font-weight: 600; cursor: pointer;
}

/* Düğmeler ve alanlar */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.block { display: flex; width: 100%; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.danger-text { color: var(--bad) !important; }
.link { border: 0; background: none; color: var(--primary); font: inherit; cursor: pointer; padding: 8px; }
.field {
  display: block; width: 100%; min-height: 44px; padding: 8px 12px; margin-top: 6px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--text); font: inherit;
}
.field.small { width: auto; min-height: 36px; margin: 0; padding: 4px 8px; font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.hint { color: var(--muted); font-size: 14px; margin: 10px 0; }
.center { text-align: center; }
.warn, .msg { background: var(--warn-bg); color: var(--warn-text); padding: 10px 12px; border-radius: 12px; font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; }
.empty b { color: var(--text); }
.foot { display: flex; justify-content: center; gap: 12px; margin-top: 24px; }
.account { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; padding: 14px 16px; }
.account b { display: block; word-break: break-all; }
.account span { display: block; color: var(--muted); font-size: 13px; }
.acc-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.account .link { align-self: flex-start; padding: 4px 0; font-size: 13px; }

/* Ana sayfa */
.card.exam {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 16px; margin-top: 12px; text-decoration: none; color: inherit;
}
.card.exam b { display: block; font-size: 17px; }
.card.exam span { color: var(--muted); font-size: 14px; }
.avg { text-align: right; flex: none; }
.avg b { font-size: 22px; font-variant-numeric: tabular-nums; }
.avg span { display: block; font-size: 12px; }

/* Yeni sınav formu */
.form { padding: 16px; display: grid; gap: 16px; }
.form label { font-weight: 600; font-size: 14px; }
.form fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.form legend { font-weight: 600; font-size: 14px; padding: 0; margin-bottom: 6px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.opt input { margin-top: 4px; }
.opt b { display: block; font-size: 15px; }
.opt small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.chips { display: flex; gap: 6px; }
.chips button {
  flex: 1; min-width: 0; height: 40px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.chips button.on { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.stepper { display: flex; gap: 8px; margin-top: 8px; }
.stepper .btn { flex: none; width: 48px; padding: 0; }
.stepper .btn .ic { margin: 0; }
.stepper .field { flex: 1; min-width: 0; text-align: center; font-size: 20px; font-weight: 700; }
.new-preview { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.new-preview svg { display: block; width: auto; max-width: 100%; height: auto; max-height: 240px; margin: 0 auto; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500 !important; }
.check input, .opt input { width: 18px; height: 18px; flex: none; }

/* Sekmeler */
.tabs { display: flex; gap: 2px; margin: -4px 0 14px; }
.tabs a {
  flex: 1 1 0; min-width: 0; text-align: center; padding: 9px 2px; border-radius: 10px; white-space: nowrap;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14px;
}
.tabs a.on { background: var(--soft); color: var(--primary); }

/* Grup seçici */
.seg { display: inline-flex; align-items: center; gap: 4px; margin: 4px 0 8px; }
.seg-label { color: var(--muted); font-size: 14px; margin-right: 6px; }
.seg button {
  width: 42px; height: 38px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.seg button.on { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }

/* Cevap anahtarı */
.keygrid { padding: 8px 10px; columns: 2 240px; column-gap: 20px; }
.krow { display: flex; align-items: center; gap: 6px; padding: 4px 0; break-inside: avoid; }
.qn { width: 28px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; flex: none; }
.kb {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1.5px solid var(--line); background: transparent; color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.kb.on { background: var(--ok); border-color: var(--ok); color: #fff; }

/* Tarama */
.camwrap { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; }
.camwrap video { display: block; width: 100%; max-height: 70vh; object-fit: contain; }
.camov { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.camrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 8px 0 14px; font-weight: 600; }
.tips { color: var(--muted); font-size: 14px; padding-left: 20px; }
.tips li { margin: 4px 0; }

/* İnceleme */
.review { padding: 14px; margin: 12px 0; }
.rv-score { display: flex; align-items: baseline; gap: 12px; }
.rv-score b { font-size: 38px; line-height: 1; font-variant-numeric: tabular-nums; }
.rv-score span { color: var(--muted); }
.name-img { display: block; width: 100%; max-width: 360px; margin: 12px 0 0; border: 1px solid var(--line); border-radius: 8px; }
.sheet { display: block; width: 100%; max-width: 560px; margin: 12px auto 0; border-radius: 10px; cursor: pointer; touch-action: manipulation; }
.legend { display: inline-flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; margin-left: 4px; }
.lg { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2.5px solid; margin-right: -6px; }
.lg.ok { border-color: var(--ok); }
.lg.bad { border-color: var(--bad); }
.lg.miss { border-color: var(--ok); border-style: dashed; }
.rv-actions {
  position: sticky; bottom: 0; display: flex; gap: 8px;
  padding: 10px 0 calc(4px + env(safe-area-inset-bottom)); background: var(--card);
}
.rv-actions .btn { flex: 1; }

/* Sonuç listesi */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 14px; }
.rrow {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 14px; text-decoration: none; color: inherit; border-top: 1px solid var(--line);
}
.rrow:first-child { border-top: 0; }
.who { min-width: 0; }
.who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who img { display: block; height: 30px; border-radius: 4px; }
.who span { color: var(--muted); font-size: 13px; }
.score { font-size: 20px; font-variant-numeric: tabular-nums; flex: none; }

/* Analiz */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 8px; margin: 6px 0 12px; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stats b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stats span { color: var(--muted); font-size: 12px; }
.qstat { display: grid; grid-template-columns: 28px 1fr 44px; align-items: center; gap: 4px 8px; padding: 8px 12px; border-top: 1px solid var(--line); }
.qstat:first-child { border-top: 0; }
.qbar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.qbar i { display: block; height: 100%; background: var(--ok); }
.qbar i.low { background: var(--bad); }
.pct { text-align: right; font-size: 14px; font-variant-numeric: tabular-nums; }
.dist { grid-column: 2 / 4; display: flex; flex-wrap: wrap; gap: 2px 12px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.dist em { font-style: normal; }
.dist em.key { color: var(--text); font-weight: 700; }

/* Form önizleme */
.preview { padding: 12px; background: #fff; overflow: auto; }
.preview svg { display: block; max-width: 100%; height: auto; margin: 0 auto; }

/* Pencere ve bildirim */
.backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.45); display: grid; place-items: center; padding: 20px; }
.modal { width: 100%; max-width: 380px; background: var(--card); border-radius: 16px; padding: 18px; }
.modal h3 { margin: 0 0 6px; font-size: 18px; }
.modal p { margin: 0 0 6px; color: var(--muted); font-size: 14px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }
.modal > .link { display: block; margin: 10px auto 0; }
.modal.menu { padding: 16px 0 14px; }
.modal.menu h3 { margin: 0 18px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal.menu .btn { width: auto; margin: 12px 14px 0; }
.set-row.danger-text .ic { color: inherit; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 30; max-width: 90vw; padding: 10px 16px; border-radius: 999px;
  background: #111827; color: #fff; font-size: 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

/* Üst çubuk: logo ve simge düğmeler */
.bar-logo { flex: none; width: 30px; height: 30px; margin: 0 6px 0 4px; border-radius: 8px; }
.bar-actions { display: flex; align-items: center; }
a.icon-btn { display: grid; place-items: center; text-decoration: none; }
.icon-btn .ic { width: 22px; height: 22px; }

/* Ana sayfa: ilk açılış */
.welcome { display: flex; flex-direction: column; align-items: center; gap: 24px; padding: 32px 0 12px; }
.welcome-logo { width: 84px; height: 84px; border-radius: 20px; }
.steps { list-style: none; display: flex; gap: 8px; width: 100%; margin: 0; padding: 0; }
.steps li { flex: 1; text-align: center; font-size: 14px; font-weight: 600; }
.step-ic { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 8px; border-radius: 50%; background: var(--soft); color: var(--primary); }
.step-ic .ic { width: 26px; height: 26px; }
.welcome .link .ic { vertical-align: -4px; margin-right: 6px; }

/* Ana sayfa: sınavlar varken */
.week { padding: 14px 16px 12px; }
.week-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.week-head b { font-size: 15px; }
.week-head span { color: var(--muted); font-size: 13px; }
.week svg { display: block; width: 100%; height: 70px; }
.wk-bar { fill: var(--primary); }
.wk-bar.zero { fill: var(--line); }
.week-days { display: flex; margin-top: 4px; color: var(--muted); font-size: 12px; }
.week-days span { flex: 1; text-align: center; }
.week-days .today { color: var(--text); font-weight: 700; }
.exam-main { flex: 1; min-width: 0; text-decoration: none; color: inherit; }
.exam-main b, .exam-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exam-main span { display: block; }
.exam-main small { display: block; color: var(--primary); font-size: 12px; font-weight: 700; margin-bottom: 2px; }
.card.exam.continue { border: 2px solid var(--primary); }
.card.exam .btn.small { flex: none; text-decoration: none; display: inline-flex; align-items: center; }
.exam-go { flex: none; border: 1px solid var(--line); background: var(--card); }
.section-label { margin: 20px 4px 0; color: var(--muted); font-size: 13px; font-weight: 600; }
.new-exam { margin-top: 16px; text-decoration: none; }

/* Ayarlar */
.settings { margin-top: 16px; overflow: hidden; }
.set-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 0 16px;
  border: 0; border-top: 1px solid var(--line); background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.set-row:first-child { border-top: 0; }
.set-row .ic { width: 20px; height: 20px; color: var(--muted); }
#account:empty { display: none; }

/* İnceleme ekranı */
.ic { flex: none; }
.btn .ic { vertical-align: -3px; margin-right: 6px; }
.review { display: flex; flex-direction: column; gap: 10px; }
.review .name-img, .review .sheet, .review .hint { margin: 0; }
.review .seg { margin: 0; }
.sheet[hidden], #rvAll[hidden] { display: none; }
.rv-group.flag, .rv-q.flag, .rv-row.flag { background: var(--warn-bg); border-radius: 12px; }
.rv-group.flag { padding: 8px 10px; }
.rv-group.flag .seg-label, .rv-qn { color: var(--warn-text); font-weight: 600; }
.rv-q { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.rv-crop { display: block; width: 100%; border-radius: 8px; background: #fff; }
.rv-choices { display: flex; gap: 6px; flex: 1; }
.rv-choices button {
  flex: 1; min-width: 0; height: 46px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; touch-action: manipulation;
}
.rv-choices button.key { border-color: var(--ok); border-width: 2.5px; }
.rv-choices button.on { background: var(--pick); border-color: var(--pick); color: var(--pick-text); }
.rv-choices.haskey button.on { background: var(--bad); border-color: var(--bad); color: #fff; }
.rv-choices.haskey button.on.key { background: var(--ok); border-color: var(--ok); }
.rv-tools { display: flex; flex-wrap: wrap; gap: 8px; }
#rvAll { display: flex; flex-direction: column; gap: 4px; }
.rv-row { display: flex; align-items: center; gap: 8px; padding: 3px 6px 3px 0; }
.rv-row .rv-choices button { height: 44px; }
.rv-bar {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 8px; margin-top: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--card); border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0; box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.1);
}
.rv-bar .rv-score { flex: 1; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.rv-bar .rv-score b { font-size: 26px; }
.rv-bar #rvCounts { display: flex; gap: 10px; font-size: 13px; font-variant-numeric: tabular-nums; }
.rv-bar #rvCounts i { font-style: normal; }
.c-ok { color: var(--ok); }
.c-bad { color: var(--bad); }
#rvDiscard { padding: 0 14px; }
#rvDiscard .ic { margin: 0; }
.reviewing > .actions, .reviewing > .tips, .reviewing > #scanCount, .reviewing > #recent, .reviewing > .warn { display: none; }

/* Tarama */
.btn.toggle[aria-pressed="true"] { background: var(--soft); border-color: var(--primary); color: var(--primary); }
.cam-pill {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  background: var(--ok); color: #fff; font-weight: 700; font-size: 20px; padding: 6px 18px; border-radius: 999px;
}
#cam.flash .camwrap { outline: 4px solid var(--ok); outline-offset: -4px; }
.recent { margin-top: 12px; }
.recent-row { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border-top: 1px solid var(--line); }
.recent-row:first-child { border-top: 0; }
.recent-row a { flex: 1; min-width: 0; color: inherit; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-row img { display: block; height: 30px; max-width: 100%; border-radius: 4px; }
.recent-row .score { font-variant-numeric: tabular-nums; }

/* Yazdırma: yalnızca form(lar) */
#printArea { display: none; }
@media print {
  @page { margin: 10mm; }
  body { background: #fff; }
  #app, .backdrop, .toast { display: none !important; }
  #printArea { display: flex; flex-wrap: wrap; gap: 6mm; justify-content: center; align-content: flex-start; }
  .pform { break-inside: avoid; }
  .pform svg { display: block; }
}
