/* ============================================================
   Okuma Yarışması — Ortak Tasarım Sistemi (açık tema)
   ============================================================ */
:root {
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-2: #f0f4f2;
  --border: #e2e8e5;
  --text: #15231d;
  --muted: #5d6e66;
  --primary: #047857;        /* zümrüt */
  --primary-600: #065f46;
  --primary-50: #ecfdf5;
  --primary-100: #d1fae5;
  --navy: #1e3a5f;           /* lacivert */
  --danger: #b42318;
  --danger-50: #fef3f2;
  --warn-50: #fffaeb;
  --warn: #b54708;
  --gold: #c99a06;   --gold-bg: #fdf6d8;
  --silver: #7b8794; --silver-bg: #eef1f4;
  --bronze: #a8622a; --bronze-bg: #f9ebdf;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 40, 30, .05), 0 4px 16px rgba(16, 40, 30, .06);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.5;
  color: var(--text); background: var(--bg);
}
h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -.01em; }
a { color: var(--primary); }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Form öğeleri ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; position: relative; }
.field label { font-weight: 600; font-size: .95rem; }
.field .hint { font-size: .82rem; color: var(--muted); }
.input, select.input {
  width: 100%; min-height: 48px; padding: 11px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); font-size: 1rem;
  transition: border-color .15s, box-shadow .15s;
}
select.input { appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235d6e66' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-100); }
.input.invalid { border-color: var(--danger); }
.input.sm { min-height: 38px; padding: 6px 10px; font-size: .92rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: var(--radius-sm); border: 1.5px solid transparent;
  font-weight: 600; cursor: pointer; text-decoration: none; transition: background .15s, transform .05s, box-shadow .15s;
  background: var(--surface); color: var(--text); border-color: var(--border); white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--primary-100); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-600); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-50); border-color: #fecdca; }
.btn-block { width: 100%; min-height: 52px; font-size: 1.05rem; }
.btn-sm { min-height: 34px; padding: 5px 11px; font-size: .86rem; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }

.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 54px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  font-weight: 600; cursor: pointer; font-size: .95rem; line-height: 1.15; text-align: center; transition: all .15s;
}
.segmented label small { font-weight: 500; font-size: .7rem; color: var(--muted); }
.segmented input:checked + label { background: var(--primary); border-color: var(--primary); color: #fff; }
.segmented input:checked + label small { color: var(--primary-100); }
.segmented input:focus-visible + label { box-shadow: 0 0 0 4px var(--primary-100); }

.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: .93rem; margin-bottom: 16px; }
.alert-error { background: var(--danger-50); color: var(--danger); border: 1px solid #fecdca; }
.alert-warn { background: var(--warn-50); color: var(--warn); border: 1px solid #fedf89; }
.alert-ok { background: var(--primary-50); color: var(--primary-600); border: 1px solid #a7f3d0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- Otomatik tamamlama ---------- */
.ac-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 20; margin-top: 4px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(16,40,30,.12); max-height: 240px; overflow-y: auto; list-style: none;
}
.ac-list li { padding: 10px 12px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.ac-list li[aria-selected="true"], .ac-list li:hover { background: var(--primary-50); }
.ac-list li .tag { font-size: .75rem; color: var(--primary); font-weight: 600; }
.ac-list mark { background: none; color: var(--primary); font-weight: 700; }
.picked-chip {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 2px; font-size: .82rem;
  color: var(--primary-600); background: var(--primary-50); padding: 3px 10px; border-radius: 999px; width: fit-content;
}

/* ---------- Rozetler ---------- */
.medal {
  display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%;
  font-weight: 700; font-size: .85rem; background: var(--surface-2); color: var(--muted);
}
.medal.r1 { background: var(--gold-bg);   color: var(--gold);   box-shadow: inset 0 0 0 2px var(--gold); }
.medal.r2 { background: var(--silver-bg); color: var(--silver); box-shadow: inset 0 0 0 2px var(--silver); }
.medal.r3 { background: var(--bronze-bg); color: var(--bronze); box-shadow: inset 0 0 0 2px var(--bronze); }

/* ---------- Diyalog ---------- */
dialog { border: none; border-radius: var(--radius); padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); color: var(--text); }
dialog::backdrop { background: rgba(15, 30, 25, .45); }
dialog .dlg-body { padding: 22px; }
dialog .dlg-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 0 22px 20px; flex-wrap: wrap; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--text); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: .93rem;
  transition: all .25s; z-index: 100; pointer-events: none; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Medrese arama kutusu ---------- */
.combo { position: relative; }
.combo .input { padding-right: 44px; }
.combo-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 38px; height: 38px;
  border: 0; background: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; border-radius: 8px; }
.combo-btn:hover { background: var(--primary-50); }
.m-list { max-height: 300px; }
.m-list li.grp { cursor: default; padding: 8px 12px 4px; font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); background: none !important; }
.m-list li.empty { cursor: default; color: var(--muted); background: none !important; }
.m-list li .tag { color: var(--muted); font-weight: 500; }
