/* ==========================================================================
   Nöbetçi — stiller
   Mobil öncelikli; 360 px'te yatay kaydırma yok, dokunma alanları ≥ 44 px.
   ========================================================================== */

/* ---------- Tokenlar ---------- */
:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --ink: #14161a;
  --ink-2: #3b414b;
  --muted: #5d6470;
  --line: #e2e5ea;
  --accent: #2f5bd8;
  --accent-ink: #ffffff;
  --accent-soft: #e6ecfb;
  --danger: #c92a2a;
  --ok: #17683f;
  --warn-bg: #fff4d6;
  --warn-ink: #6b4a00;

  /* Zaman çizelgesi renkleri */
  --tl-sleep: #d9dce3;
  --tl-buffer: repeating-linear-gradient(135deg, #c7ccd6 0 4px, #e2e5ea 4px 8px);
  --tl-free: #e3f4ea;
  --tl-free-line: #9bd3b3;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 22, 26, .06), 0 6px 20px -12px rgba(20, 22, 26, .25);
  --tabbar-h: 64px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1f232b;
    --ink: #eceef2;
    --ink-2: #c7cbd3;
    --muted: #9aa1ad;
    --line: #2a2f38;
    --accent: #7c9cff;
    --accent-ink: #0f1115;
    --accent-soft: #1e2740;
    --danger: #ff6b6b;
    --ok: #4cc38a;
    --warn-bg: #3a2f12;
    --warn-ink: #f5d58a;
    --tl-sleep: #2a2f3a;
    --tl-buffer: repeating-linear-gradient(135deg, #3a404c 0 4px, #262a33 4px 8px);
    --tl-free: #15301f;
    --tl-free-line: #2f6b47;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115;
  --surface: #171a20;
  --surface-2: #1f232b;
  --ink: #eceef2;
  --ink-2: #c7cbd3;
  --muted: #9aa1ad;
  --line: #2a2f38;
  --accent: #7c9cff;
  --accent-ink: #0f1115;
  --accent-soft: #1e2740;
  --danger: #ff6b6b;
  --ok: #4cc38a;
  --warn-bg: #3a2f12;
  --warn-ink: #f5d58a;
  --tl-sleep: #2a2f3a;
  --tl-buffer: repeating-linear-gradient(135deg, #3a404c 0 4px, #262a33 4px 8px);
  --tl-free: #15301f;
  --tl-free-line: #2f6b47;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .6);
}

/* ---------- Temel ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
}
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 100;
  padding: 10px 14px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none;
  transform: translateY(-160%); transition: transform .2s var(--ease);
}
.skip-link:focus { transform: none; }

main { max-width: 640px; margin: 0 auto; padding: 0 16px; }
/* İlk çizim JS ile yapılır; o ana kadar içerik gizli (sonradan dolup kayma olmasın) */
.js:not(.is-ready) main { visibility: hidden; }
.noscript { max-width: 640px; margin: 16px auto; padding: 12px 16px; border-radius: 12px; background: var(--warn-bg); color: var(--warn-ink); }
main:focus { outline: none; }

/* ---------- Üst çubuk ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 640px; margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 750; letter-spacing: -.02em; min-width: 0; }
.brand__mark { width: 30px; height: 30px; flex: none; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.brand__moon { fill: var(--accent); stroke: none; }
.brand__tag { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 400px) { .brand__tag { display: none; } }
.topbar__actions { display: flex; gap: 4px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; border-radius: 12px; border: 0;
  background: transparent; color: var(--ink);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn--lg { width: 48px; height: 48px; background: var(--surface); box-shadow: var(--shadow); }
.lang-code { font-size: 13px; font-weight: 700; letter-spacing: .04em; }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: block; }
  :root:not([data-theme="light"]) .i-moon { display: none; }
}

/* ---------- Butonlar ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 600; text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { border-color: var(--accent); filter: brightness(1.05); }
.btn--ghost { background: transparent; }
.btn--danger { color: var(--danger); }
.btn--small { min-height: 40px; padding: 6px 14px; font-size: 14px; }
.btn--block { width: 100%; }
.link-btn { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 4px 8px; min-height: 32px; font-size: 14px; }

/* ---------- Uyarı / demo ---------- */
.demo-bar {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  margin: 4px 0 12px; padding: 10px 10px 10px 14px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--ink-2); font-size: 14px;
}
.storage-warning { margin: 4px 0 12px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--warn-bg); color: var(--warn-ink); font-size: 14px; }

/* ---------- Hafta gezintisi ---------- */
.weeknav { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 8px; margin: 8px 0 16px; }
.weeknav__title { text-align: center; min-width: 0; }
.weeknav__title h2 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }

/* ---------- Özet kartları ---------- */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat { padding: 14px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); min-width: 0; }
.stat__label { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat__value { font-size: 24px; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; margin-top: 2px; }
.stat__value--alert { color: var(--danger); }
.stat__sub { font-size: 13px; color: var(--muted); }
.stat .link-btn { padding: 0; margin-top: 4px; text-align: left; }

.hint { font-size: 13px; color: var(--muted); margin: 0 4px 8px; }

/* ---------- Günler ---------- */
.days { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.day__btn {
  display: grid; grid-template-columns: 52px 1fr auto; grid-template-rows: auto auto; column-gap: 12px; row-gap: 8px; align-items: center;
  width: 100%; min-height: 72px; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid transparent; background: var(--surface); box-shadow: var(--shadow); text-align: left;
}
.day__btn:hover { border-color: var(--line); }
.day--today .day__btn { border-color: var(--accent); }
.day__date { display: flex; flex-direction: column; line-height: 1.15; }
.day__date b { font-size: 15px; }
abbr[title] { text-decoration: none; }
.day__date small { font-size: 13px; color: var(--muted); }
.day--today .day__date b { color: var(--accent); }
.day__shift { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 650; }
.day__shift span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day__shift small { display: block; font-weight: 500; color: var(--muted); font-size: 13px; }
.dot { width: 12px; height: 12px; border-radius: 4px; background: var(--c, var(--muted)); flex: none; }
.day__shift--empty { color: var(--muted); font-weight: 500; }
.day__shift--empty .dot { background: transparent; border: 1.5px dashed var(--muted); }
.day__hours { font-weight: 700; font-size: 15px; text-align: right; }
.day__hours small { display: block; font-size: 12px; font-weight: 600; color: var(--danger); }
.day__bar { grid-column: 1 / -1; position: relative; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.day__bar i { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: var(--c); }
.day__bar i.spill { opacity: .45; }
.day__bar .night-band { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--ink) 7%, transparent); }

.row-actions { display: flex; justify-content: center; margin: 12px 0 18px; }

/* ---------- Kart ---------- */
.card { padding: 16px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); margin-bottom: 16px; }
.card__title { font-size: 16px; font-weight: 700; margin-bottom: 10px; }
.month__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
.month__grid dt { font-size: 13px; color: var(--muted); font-weight: 600; }
.month__grid dd { margin: 0; font-size: 18px; font-weight: 700; }
.month__grid div { min-width: 0; }

.export-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
@media (max-width: 380px) { .export-actions { grid-template-columns: 1fr; } }

/* ---------- Görünüm başlıkları ---------- */
.view__title { font-size: 22px; font-weight: 750; letter-spacing: -.02em; margin: 8px 0 6px; }
.view__intro { color: var(--muted); font-size: 15px; margin-bottom: 16px; }

/* ---------- Formlar ---------- */
.field { display: grid; gap: 6px; }
.field label, .field .label { font-size: 13px; font-weight: 650; color: var(--ink-2); }
.field small { font-size: 12px; color: var(--muted); }
.input {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stack { display: grid; gap: 14px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { position: relative; }
.swatch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.swatch span { display: block; width: 36px; height: 36px; border-radius: 10px; background: var(--c); border: 3px solid transparent; }
.swatch input:checked + span { border-color: var(--ink); }
.swatch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.form-actions { display: flex; gap: 10px; justify-content: space-between; margin-top: 6px; }
.form-actions .btn--primary { flex: 1; }

/* ---------- Ayarlar listeleri ---------- */
.list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.list__item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; padding: 10px 14px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); text-align: left;
}
.list__item:hover { border-color: var(--muted); }
.list__main { flex: 1; min-width: 0; }
.list__main b { display: block; }
.list__main small { color: var(--muted); font-size: 13px; }
.list__item svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none; }
.section-title { font-size: 15px; font-weight: 700; margin: 22px 0 10px; }
.about { font-size: 13px; color: var(--muted); margin-top: 16px; }

/* ---------- Alt sekme çubuğu ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; background: none; color: var(--muted); font-size: 12px; font-weight: 650;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--accent); }

/* ---------- Alttan açılan panel ---------- */
.sheet {
  width: 100%; max-width: 560px; max-height: 88dvh;
  margin: auto auto 0; padding: 0; border: 0;
  border-radius: 22px 22px 0 0; background: var(--surface); color: var(--ink);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .25);
}
@media (min-width: 600px) { .sheet { margin: auto; border-radius: 22px; } }
.sheet::backdrop { background: rgba(10, 12, 16, .45); }
.sheet[open] { animation: sheetIn .28s var(--ease); }
@keyframes sheetIn { from { transform: translateY(24px); opacity: 0; } }
.sheet__inner { padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0 10px; }
.sheet__title { font-size: 18px; font-weight: 750; }
.picker { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.picker button {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 14px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface); text-align: left; font-weight: 650;
}
.picker button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.picker small { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 14px; }
.sheet__foot { display: flex; justify-content: center; margin-top: 12px; }
.confirm-text { color: var(--ink-2); margin-bottom: 16px; }

/* ---------- Bildirim ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px); z-index: 60;
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 12px;
  background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 600;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .25s var(--ease);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Boş zaman (3. aşama) ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); margin: 0 0 10px; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: block; }
.k-shift { background: var(--accent); }
.k-buffer { background: var(--tl-buffer); }
.k-sleep { background: var(--tl-sleep); }
.k-free { background: var(--tl-free); border: 1px solid var(--tl-free-line); }
.k-session { background: #16a37f; }

/* Boş zaman görünümü */
.weeknav--compact { margin: 0 0 14px; }
.weeknav--compact h3 { font-size: 16px; font-weight: 700; }
.card__row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card__big { font-size: 22px; font-weight: 750; letter-spacing: -.02em; }
.card__muted { font-size: 14px; color: var(--muted); font-weight: 600; }

.fdays { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.fday {
  display: grid; grid-template-columns: 1fr auto; row-gap: 6px; align-items: center;
  width: 100%; min-height: 56px; padding: 8px 10px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); text-align: left;
}
.fday.is-active { border-color: var(--accent); background: var(--accent-soft); }
.fday.is-today .fday__label b { color: var(--accent); }
.fday__label { font-size: 14px; color: var(--muted); }
.fday__label b { color: var(--ink); }
.fday__free { font-size: 13px; font-weight: 700; color: var(--ok); }
.fbar { grid-column: 1 / -1; position: relative; height: 14px; border-radius: 5px; overflow: hidden; background: var(--surface-2); }
.seg { position: absolute; top: 0; bottom: 0; }
.seg--free { background: var(--tl-free); }
.seg--sleep { background: var(--tl-sleep); }
.seg--buffer { background: var(--tl-buffer); }
.seg--shift { background: var(--c, var(--accent)); }
.seg--session { background: var(--c); top: 3px; bottom: 3px; border-radius: 3px; box-shadow: 0 0 0 1.5px var(--surface); }

.plan-actions { display: flex; gap: 10px; margin-top: 12px; }
.plan-actions .btn--primary { flex: 1; }
.plan-result { margin-top: 12px; padding: 12px 14px; border-radius: 12px; font-size: 14px; display: grid; gap: 4px; }
.plan-result--ok { background: var(--tl-free); color: var(--ink); }
.plan-result--warn { background: var(--warn-bg); color: var(--warn-ink); }

/* Dikey zaman çizelgesi */
.tl { --hour: 30px; position: relative; height: calc(24 * var(--hour)); margin: 12px 0 4px 44px; }
.tl__hour { position: absolute; left: -44px; transform: translateY(-50%); font-size: 11px; color: var(--muted); width: 38px; text-align: right; }
.tl__track { position: absolute; inset: 0; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.tl__track::after { /* saat çizgileri */
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: repeating-linear-gradient(to bottom, color-mix(in srgb, var(--ink) 10%, transparent) 0 1px, transparent 1px var(--hour));
}
.tl__block { position: absolute; left: 0; right: 0; display: flex; align-items: flex-start; padding: 4px 8px; font-size: 12px; font-style: normal; font-weight: 600; overflow: hidden; }
.tl__block--free { background: var(--tl-free); border-top: 1px solid var(--tl-free-line); border-bottom: 1px solid var(--tl-free-line); }
.tl__block--sleep { background: var(--tl-sleep); color: var(--muted); }
.tl__block--buffer { background: var(--tl-buffer); }
.tl__block--shift { background: var(--c); color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .35); }
.tl__session {
  position: absolute; left: 16%; right: 6%; z-index: 2;
  display: flex; flex-direction: column; justify-content: center; gap: 0; padding: 2px 10px;
  border: 0; border-radius: 8px; background: var(--c); color: #fff; text-align: left;
  font-size: 12px; line-height: 1.25; touch-action: none; cursor: grab;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}
.tl__session b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl__session.is-dragging { cursor: grabbing; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); z-index: 3; }
.tl__session:focus-visible { outline: 3px solid var(--ink); outline-offset: 1px; }

.srows { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.srow { display: flex; align-items: center; gap: 8px; padding: 6px 4px 6px 10px; border-radius: 12px; border: 1px solid var(--line); }
.srow__main { flex: 1; min-width: 0; }
.srow__main b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.srow__main small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Hareket azaltma ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
