:root {
  --bg: #f5f5fa; --surface: #ffffff; --surface-2: #f0f0f7; --border: #e3e3ee;
  --text: #15142b; --muted: #5f5e78; --faint: #8f8ea6;
  --brand: #4f46e5; --brand-2: #6366f1; --brand-soft: #e0e7ff;
  --ok: #16a34a; --ok-soft: #dcfce7; --bad: #dc2626; --bad-soft: #fee2e2; --frz: #0284c7; --frz-soft: #e0f2fe;
  --warn-bg: #fff7e6; --warn: #92400e;
  --radius: 14px; --shadow: 0 1px 2px rgba(21, 20, 43, .06), 0 4px 16px rgba(21, 20, 43, .05);
  --nav-w: 210px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e18; --surface: #161625; --surface-2: #1f1f32; --border: #2b2b42;
    --text: #ebebf5; --muted: #a5a4c0; --faint: #74738f;
    --brand: #818cf8; --brand-2: #6366f1; --brand-soft: #25264d;
    --ok: #4ade80; --ok-soft: #133524; --bad: #f87171; --bad-soft: #3d1a1d; --frz: #38bdf8; --frz-soft: #0f2c3d;
    --warn-bg: #3a2a10; --warn: #fcd34d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 13px; }
.okc { color: var(--ok); } .badc { color: var(--bad); }
.right { text-align: right; } .nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- Yerleşim ---------- */
.shell { display: flex; min-height: 100vh; }
.nav { width: var(--nav-w); flex: none; background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; }
.nav .logo { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .3px; padding: 4px 10px 18px; }
.nav .logo img { width: 30px; height: 30px; border-radius: 8px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--muted); font-weight: 550; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--brand-soft); color: var(--brand); }
.nav .spacer { flex: 1; }
main { flex: 1; min-width: 0; padding: 24px 28px 100px; max-width: 1100px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 22px; margin: 0; flex: 1; min-width: 140px; }
.bottom-nav { display: none; }

@media (max-width: 820px) {
  .nav { display: none; }
  main { padding: 16px 16px calc(90px + env(safe-area-inset-bottom)); }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 0; }
  .bottom-nav a .i { font-size: 20px; line-height: 1; }
  .bottom-nav a.on { color: var(--brand); }
}

/* ---------- Bileşenler ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.card h2 { font-size: 15px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.card h2 .x { margin-left: auto; font-weight: 500; font-size: 13px; }
.grid { display: grid; gap: 14px; }
.g-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .g-2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) { .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat .lbl { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat .val { font-size: 24px; font-weight: 750; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--faint); font-size: 12.5px; margin-top: 2px; }
.sec-title { font-size: 12px; font-weight: 750; letter-spacing: .6px; text-transform: uppercase; color: var(--faint); margin: 22px 2px 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0e0e18; } }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: transparent; cursor: pointer; padding: 6px 8px; border-radius: 8px; color: var(--muted); font-size: 16px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); outline: none; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
label.f { display: block; }
label.f > span { display: block; font-size: 12.5px; font-weight: 650; color: var(--muted); margin: 0 0 5px; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 110px; }
.row > .fix { flex: none; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack > * { flex-shrink: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 11px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 9px; cursor: pointer; font-weight: 650; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg.full { display: flex; } .seg.full button { flex: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 13.5px; font-weight: 550; display: inline-flex; gap: 6px; align-items: center; }
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }

.date-nav { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 3px; }
.date-nav span { min-width: 150px; text-align: center; font-weight: 700; }

.bar .top { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; margin-bottom: 4px; }
.track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.fill { height: 100%; border-radius: 99px; background: var(--brand); transition: width .25s; }
.bars { display: flex; flex-direction: column; gap: 10px; }

.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.note { background: var(--warn-bg); color: var(--warn); padding: 10px 12px; border-radius: 10px; font-size: 13.5px; }
.info { background: var(--brand-soft); color: var(--text); padding: 10px 12px; border-radius: 10px; font-size: 13.5px; }

/* ---------- Bugün ---------- */
.today-top { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: stretch; }
@media (max-width: 640px) { .today-top { grid-template-columns: minmax(0, 1fr); } }
.score-card { display: flex; align-items: center; gap: 16px; }
.ring { width: 92px; height: 92px; flex: none; }
.ring text { font-weight: 800; fill: var(--text); }
.mood-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mood-row .lbl { width: 62px; font-size: 13px; font-weight: 650; color: var(--muted); }
.mbtn { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; width: 40px; height: 38px; font-size: 20px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; filter: grayscale(.7); opacity: .75; }
.mbtn:hover { opacity: 1; filter: none; }
.mbtn.on { border-color: var(--brand); background: var(--brand-soft); filter: none; opacity: 1; }
.mbtn.e { font-size: 13px; font-weight: 750; width: 34px; }

.habits { display: flex; flex-direction: column; gap: 10px; }
.hcard { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; position: relative; }
.hcard.done { border-color: color-mix(in srgb, var(--hc, var(--ok)) 55%, var(--border)); }
.hcard .hico { width: 42px; height: 42px; flex: none; border-radius: 12px; background: color-mix(in srgb, var(--hc, var(--brand)) 14%, var(--surface)); display: flex; align-items: center; justify-content: center; font-size: 22px; cursor: pointer; }
.hcard .hmain { flex: 1; min-width: 0; cursor: pointer; }
.hcard .hname { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hcard .hsub { font-size: 12.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; margin-top: 1px; }
.hcard .hsub .streak { color: #ea580c; font-weight: 650; }
.hcard .hprog { height: 5px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.hcard .hprog i { display: block; height: 100%; background: var(--hc, var(--brand)); border-radius: 99px; }
.hcard .hprog.over i { background: var(--bad); }
.hcard .hctl { display: flex; align-items: center; gap: 6px; flex: none; }
.hcard .val { font-weight: 750; font-variant-numeric: tabular-nums; min-width: 44px; text-align: center; font-size: 14px; }
.hcard.frozen { background: var(--frz-soft); }
.hcard.off { opacity: .6; }
.tick { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--border); background: var(--surface); cursor: pointer; font-size: 20px; color: transparent; display: inline-flex; align-items: center; justify-content: center; }
.tick:hover { border-color: var(--hc, var(--ok)); }
.tick.on { background: var(--hc, var(--ok)); border-color: var(--hc, var(--ok)); color: #fff; }
.rbtn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 750; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; }
.rbtn:hover { background: var(--surface-2); }
.rbtn.wide { width: auto; padding: 0 10px; font-size: 13px; }
.rbtn.run { background: var(--brand); color: #fff; border-color: var(--brand); }
.clean { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 520px) {
  .hcard { flex-wrap: wrap; padding: 10px 12px; }
  .hcard:not(.compact) .hmain { flex-basis: calc(100% - 56px); }
  .hcard:not(.compact) .hctl { width: 100%; justify-content: flex-end; padding-left: 54px; }
  .hcard .clean { font-size: 16px; }
}
.remind { font-size: 11.5px; font-weight: 700; color: var(--warn); }

/* ---------- Isı haritası ---------- */
.heat-wrap { overflow-x: auto; padding-bottom: 4px; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 12px); gap: 3px; width: max-content; }
.heat i { width: 12px; height: 12px; border-radius: 3px; background: var(--surface-2); display: block; }
.heat i.none { background: transparent; }
.heat i.done { background: var(--hc, var(--ok)); }
.heat i.part { background: color-mix(in srgb, var(--hc, var(--ok)) 40%, var(--surface-2)); }
.heat i.miss { background: color-mix(in srgb, var(--bad) 70%, var(--surface-2)); }
.heat i.frozen { background: var(--frz); opacity: .55; }
.heat i.off, .heat i.empty { background: var(--surface-2); opacity: .55; }
.heat i.pending { outline: 2px solid var(--brand); outline-offset: -2px; }
.heat-months { display: grid; grid-auto-flow: column; gap: 3px; font-size: 10.5px; color: var(--faint); margin-bottom: 3px; width: max-content; }
.heat-months span { width: 12px; white-space: nowrap; overflow: visible; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

.hgrid { display: grid; grid-template-columns: 34px repeat(24, minmax(0, 1fr)); gap: 2px; font-size: 10px; color: var(--faint); }
.hgrid i { aspect-ratio: 1; border-radius: 2px; background: var(--surface-2); display: block; }
.hgrid span { display: flex; align-items: center; }

/* ---------- Alışkanlık listesi / galeri ---------- */
.li { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); min-width: 0; }
.li:last-child { border-bottom: 0; }
.li .ico { width: 36px; height: 36px; flex: none; border-radius: 10px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.li .main { flex: 1; min-width: 0; cursor: pointer; }
.li .t1 { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .t2 { font-size: 12.5px; color: var(--muted); }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.tpl { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; cursor: pointer; background: var(--surface); text-align: left; display: flex; gap: 10px; align-items: center; }
.tpl:hover { border-color: var(--brand); }
.tpl.have { opacity: .5; }
.tpl .ti { font-size: 22px; }
.tpl b { display: block; font-size: 13.5px; }
.tpl small { color: var(--muted); font-size: 12px; }

.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.bdg { border: 1px solid var(--border); border-radius: 12px; padding: 12px; text-align: center; background: var(--surface); }
.bdg .bi { font-size: 30px; }
.bdg b { display: block; font-size: 13px; margin-top: 4px; }
.bdg small { color: var(--muted); font-size: 12px; }
.bdg.locked { opacity: .55; }
.bdg.locked .bi { filter: grayscale(1); }

/* ---------- Tablo ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 650; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 7px 8px; border-bottom: 1px solid var(--border); }
.tbl-wrap { overflow-x: auto; }

/* ---------- Modal + toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 10, 25, .45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px 12px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 480px; padding: 18px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal.wide { max-width: 760px; }
.modal h3 { margin: 0 0 14px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.modal h3 .icon-btn { margin-left: auto; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.modal .actions .left { margin-right: auto; }
@media (max-width: 560px) { .overlay { padding: 0; align-items: flex-end; } .modal { border-radius: 16px 16px 0 0; max-height: 92vh; overflow-y: auto; padding-bottom: calc(18px + env(safe-area-inset-bottom)); } }
#toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); background: #1c1b33; color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: calc(100vw - 32px); text-align: center; }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (max-width: 820px) { #toast { bottom: calc(84px + env(safe-area-inset-bottom)); } }
.menu-pop { position: absolute; right: 8px; top: 52px; z-index: 30; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .15); padding: 6px; display: flex; flex-direction: column; min-width: 190px; }
.menu-pop button { border: 0; background: transparent; text-align: left; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.menu-pop button:hover { background: var(--surface-2); }
.menu-pop button:disabled { opacity: .45; cursor: default; }

/* ---------- Giriş ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login .card { width: 100%; max-width: 360px; padding: 24px; }
.login h1 { font-size: 20px; margin: 10px 0 16px; text-align: center; }
.login img { display: block; margin: 0 auto; width: 56px; height: 56px; border-radius: 14px; }

svg text { font-family: inherit; }
.chart { width: 100%; height: auto; display: block; }

/* ---------- İyi / kötü ayrımı ---------- */
.score-card { flex-wrap: wrap; gap: 18px 28px; }
.sc-part { display: flex; align-items: center; gap: 12px; }
.sc-t { font-weight: 750; }
.pol-head { display: flex; align-items: baseline; gap: 10px; font-weight: 800; font-size: 15px; margin: 26px 2px 4px; padding-bottom: 6px; border-bottom: 2px solid; }
.pol-head span { font-size: 12.5px; font-weight: 550; color: var(--muted); }
.pol-head.good { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.pol-head.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.sec-sub { font-size: 12px; font-weight: 750; letter-spacing: .6px; text-transform: uppercase; color: var(--faint); margin: 12px 2px 8px; }
.hcard.pol-good { border-left: 3px solid color-mix(in srgb, var(--ok) 60%, var(--border)); }
.hcard.pol-bad { border-left: 3px solid color-mix(in srgb, var(--bad) 60%, var(--border)); }
.card h2.good-t { color: var(--ok); } .card h2.bad-t { color: var(--bad); }

/* ---------- Haftalık özet ---------- */
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; text-align: center; }
.wd { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.wd-n { font-size: 12.5px; font-weight: 700; }
.wd-bar { width: 26px; height: 70px; background: var(--surface-2); border-radius: 7px; display: flex; align-items: flex-end; overflow: hidden; }
.wd-bar i { display: block; width: 100%; background: var(--ok); border-radius: 7px; }
.hour-bars { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 2px; height: 60px; align-items: end; }
.hour-bars i { display: block; background: var(--bad); border-radius: 2px 2px 0 0; min-height: 1px; opacity: .85; }
.hour-lbl { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--faint); margin-top: 3px; }
@media (max-width: 420px) { .bottom-nav a { font-size: 10px; } }

/* Eğer… o zaman… planları (Ayarlar) */
.plans { display: flex; flex-direction: column; gap: 8px; }
.plan-row { display: grid; grid-template-columns: 210px minmax(0, 1fr) 190px; gap: 8px; align-items: center; }
.plan-if { font-size: 13.5px; color: var(--muted); }
@media (max-width: 720px) { .plan-row { grid-template-columns: minmax(0, 1fr); gap: 5px; padding-bottom: 8px; border-bottom: 1px solid var(--border); } }

/* Günü kapat */
.close-wrap { max-width: 720px; display: flex; flex-direction: column; gap: 14px; }
.close-wrap h2 .step { display: inline-flex; width: 24px; height: 24px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-size: 13px; align-items: center; justify-content: center; margin-right: 6px; }
.cl-ctl { display: flex; align-items: center; gap: 6px; flex: none; }
.close-wrap .cl-ctl input { width: 84px; text-align: right; }
@media (max-width: 520px) { .close-wrap .cl-ctl input { width: 64px; } .close-wrap .li { gap: 8px; } .close-wrap .li .ico { width: 30px; height: 30px; font-size: 16px; } }
.close-done { text-align: center; padding: 26px 16px; }
.close-done .big { font-size: 44px; }
@media (max-width: 640px) { .hide-sm { display: none; } }
