:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --card: rgba(244, 247, 252, 0.72);
  --ink: #14213a;
  --muted: #566274;
  --line-strong: #b4c3dc;
  --line: #dbe2ec;
  --brand: #0657cc;
  --brand-soft: #dbe8fb;
  --accent: #dd330b;
  --pending: #d3dae4;
  --active: #f2a900;
  --done: #0657cc;
  --danger: #dd330b;
  --chip-pending-bg: #e5eaf2;
  --chip-pending-fg: #4a5666;
  --chip-active-bg: #fff1c7;
  --chip-active-fg: #7a5200;
  --chip-done-bg: #e1ecfb;
  --chip-done-fg: #0549a8;
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { min-height: 100vh; font-size: 16px; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--brand-soft); outline-offset: 1px; box-shadow: 0 0 0 2px var(--brand); }

.muted { color: var(--muted); }
small, .small { font-size: 13px; }

/* header + layout */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: #fff; color: var(--ink);
  border-bottom: 3px solid var(--accent);
}
.brand { display: flex; align-items: center; min-width: 0; }
.brand img { display: block; height: 40px; width: auto; max-width: 100%; }
.user {
  border: 1px solid var(--brand); background: transparent; color: var(--brand); font-weight: 600;
  border-radius: 999px; padding: 6px 14px; min-height: 36px; max-width: 55%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
.stack > * + * { margin-top: 16px; }

/* nav */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav button {
  flex: 1; border: 0; background: none; padding: 14px 4px 12px; min-height: 52px;
  color: var(--muted); border-top: 3px solid transparent; font-size: 15px;
}
.nav button[aria-current="page"] { color: var(--brand); font-weight: 700; border-top-color: var(--accent); }

/* chips */
.chips {
  position: relative; display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: none; overscroll-behavior-x: contain;
}
.chips::-webkit-scrollbar { display: none; }
@media (hover: hover) and (pointer: fine) {
  .chips { padding-bottom: 10px; scrollbar-width: thin; scrollbar-color: var(--brand) var(--brand-soft); }
  .chips::-webkit-scrollbar { display: block; height: 8px; }
  .chips::-webkit-scrollbar-track { background: var(--brand-soft); border-radius: 999px; }
  .chips::-webkit-scrollbar-thumb { background: var(--brand); border-radius: 999px; }
}
.chip {
  flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 8px 16px; min-height: 40px; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.chip.add { border-style: dashed; color: var(--brand); }

/* cards */
.card { background: var(--card); border: 1px solid var(--line-strong); border-radius: 12px; overflow: hidden; }
.card-head {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 14px 16px 12px;
}
.card-head .row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card-head h3 { font-size: 17px; }
.count { font-weight: 700; font-variant-numeric: tabular-nums; }
.card-head .sub { margin-top: 2px; }
.card-body { border-top: 1px solid var(--line); }
.section-title { font-size: 15px; font-weight: 700; margin: 4px 0 8px; }

/* the progress rail: one segment per topic */
.rail { display: flex; gap: 3px; margin-top: 10px; max-width: 100%; overflow: hidden; }
.rail.dense { gap: 2px; }
.rail span { flex: 1 1 0; min-width: 0; height: 8px; border-radius: 2px; background: var(--pending); }
.rail span.active { background: var(--active); }
.rail span.done { background: var(--done); }
.rail.thin span { height: 6px; }

/* topic rows */
.topic {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--line);
  padding: 12px 16px; min-height: 52px;
}
.card-body > .topic:first-child, .list > .topic:first-child { border-top: 0; }
.topic:active, button.card-head:active { background: var(--brand-soft); }
@media (hover: hover) { .topic:hover, button.card-head:hover { background: #eaf1fb; } }
.topic .name { font-weight: 500; }
.topic .meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.topic .note { color: var(--muted); font-size: 13px; margin-top: 2px; font-style: italic;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.status {
  flex: none; font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: var(--chip-pending-bg); color: var(--chip-pending-fg);
}
.status.active { background: var(--chip-active-bg); color: var(--chip-active-fg); }
.status.done { background: var(--chip-done-bg); color: var(--chip-done-fg); }
.list { background: var(--card); border: 1px solid var(--line-strong); border-radius: 12px; overflow: hidden; }

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

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.danger-ghost { color: var(--danger); border-color: transparent; background: transparent; }
.btn:disabled { opacity: .55; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.toolbar .group { display: flex; gap: 8px; flex-wrap: wrap; }
.icon-btn { border: 0; background: none; min-width: 40px; min-height: 40px; font-size: 18px; color: var(--muted); border-radius: 8px; }
.icon-btn:disabled { opacity: .3; }

/* curriculum editor rows */
.edit-row { display: flex; align-items: center; gap: 4px; padding: 6px 8px 6px 16px; border-top: 1px solid var(--line); min-height: 52px; }
.edit-row .grow { flex: 1; min-width: 0; }
.edit-row .name { overflow-wrap: anywhere; }

/* teachers + log */
.person { padding: 14px 16px; }
.person .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.person .name { font-weight: 700; }
.badge-off { font-size: 12px; background: #fde7e2; color: var(--danger); padding: 2px 8px; border-radius: 999px; margin-left: 6px; font-weight: 600; }
.log-item { padding: 12px 16px; border-top: 1px solid var(--line); }
.log-item:first-child { border-top: 0; }
.log-item .row { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }

/* sheet */
.back { position: fixed; inset: 0; background: rgba(20,33,58,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; background: var(--surface);
  border-radius: 16px 16px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.sheet-head h2 { font-size: 19px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
.field small { font-weight: 400; }
.field input, .field select, .field textarea {
  font-size: 16px; font-weight: 400; padding: 11px 12px; border: 1px solid #b4bfd0; border-radius: 10px; background: #fff; width: 100%;
}
.actions { display: flex; flex-direction: column; gap: 8px; }
.form-error { color: var(--danger); font-size: 14px; min-height: 0; }
.form-error:empty { display: none; }
.picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.picker button { min-height: 48px; border: 2px solid var(--line); background: #fff; border-radius: 10px; font-weight: 600; }
.picker button[aria-pressed="true"][data-s="pending"] { border-color: #8a95a3; background: var(--chip-pending-bg); }
.picker button[aria-pressed="true"][data-s="active"] { border-color: var(--active); background: var(--chip-active-bg); }
.picker button[aria-pressed="true"][data-s="done"] { border-color: var(--done); background: var(--chip-done-bg); }

.toast {
  position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 30; font-size: 15px;
}

/* login */
.login { max-width: 400px; margin: 0 auto; padding: calc(56px + env(safe-area-inset-top)) 20px 32px; }
.login h1 { margin: 0; line-height: 0; }
.login-logo { display: block; width: min(340px, 82vw); height: auto; }
.login .muted { margin: 18px 0 28px; }

@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
@media (min-width: 700px) {
  .back { align-items: center; }
  .sheet { border-radius: 16px; }
}

/* theme (başlık) bands inside course cards */
.theme-head { padding: 10px 16px; background: rgba(232, 238, 249, 0.82); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.card-body > .theme-head:first-child { border-top: 0; }
.theme-head .row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.theme-name { font-weight: 700; overflow-wrap: anywhere; }
.theme-head .rail { margin-top: 8px; }
.theme-head.plain { background: transparent; border-bottom: 0; padding: 10px 16px 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.preview { font-size: 13px; font-weight: 400; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; overflow-wrap: anywhere; }
.preview:empty { display: none; }
.preview-title { font-weight: 700; color: var(--ink); margin-bottom: 2px; }

/* arka plan: büyük, bulanık anka kuşu (görünürlüğü opacity ile ayarla) */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: url('/static/bg-phoenix.png') center 46% / min(1100px, 150vw) auto no-repeat;
  opacity: 0.22;
}

/* sıralama: konunun durumu sol kenardaki çizgiyle görünür */
.edit-row[data-s="done"] { box-shadow: inset 4px 0 0 var(--done); }
.edit-row[data-s="active"] { box-shadow: inset 4px 0 0 var(--active); }
.edit-row[data-s="pending"] { box-shadow: inset 4px 0 0 var(--pending); }
.theme-head.reorder { display: flex; align-items: center; gap: 4px; padding-right: 8px; }
.theme-head.reorder .grow { flex: 1; min-width: 0; }

/* uzun listelerde sayfanın yana kaymasını engelle */
.wrap { overflow-x: clip; }
.card, .list, .card-head, .topic > div { min-width: 0; }

/* ders kartı: koyu mavi başlık şeridi ve mavi çerçeve, dersleri birbirinden ayırır */
.card.course { border: 1px solid var(--brand); border-radius: 12px; }
.course-strip { display: block; width: 100%; margin: 0; border: 0; text-align: left; padding: 12px 16px; background: var(--brand); color: #fff; }
button.course-strip { cursor: pointer; }
button.course-strip:hover { background: #054aa8; }
button.course-strip:active { background: #043f90; }
.course-strip h3 { margin: 0; font-size: 17px; color: #fff; overflow-wrap: anywhere; }
.strip-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.strip-right { display: flex; align-items: center; gap: 10px; flex: none; }
.course-strip .count { font-weight: 700; font-variant-numeric: tabular-nums; }
.chev { font-size: 14px; opacity: .9; }
.strip-sub { margin-top: 2px; font-size: 13px; color: rgba(255, 255, 255, .85); }
.course-sum { padding: 10px 16px 12px; }
.course-sum .rail { margin-top: 0; }
.course-tools { padding: 10px 12px; border-bottom: 1px solid var(--line); }

/* ünite: alt konularıyla tek bir blok (sol kenarda çizgi), ünitesiz konular çizgisiz kalır */
.unit { border-left: 5px solid #9fb4d6; }
.card-body > .unit:first-child > .theme-head:first-child { border-top: 0; }

/* günlük */
.log-actions { display: flex; gap: 8px; margin-top: 8px; }
