/* ===================== TOKENS ===================== */
:root {
  --ink: #5B4048;
  --ink-strong: #472F36;
  --ink-soft: #8C6F76;
  --paper: #FBF1EA;
  --surface: #FFFFFF;
  --border: #F1DED4;
  --amber: #E8917E;
  --amber-soft: #FBE3DA;
  --income: #6FA287;
  --income-soft: #E4EFE7;
  --expense: #DD7A82;
  --expense-soft: #FBE4E6;
  --text: #4A3439;
  --text-soft: #8C7278;
  --shadow: 0 8px 24px rgba(91, 64, 72, 0.12);

  --cat-kira: #C9998A;
  --cat-fatura: #E8917E;
  --cat-market: #94AE7E;
  --cat-ulasim: #7FA6C4;
  --cat-saglik: #C98AAE;
  --cat-giyim: #A38AC9;
  --cat-eglence: #E8A15C;
  --cat-kredi: #9C8B95;
  --cat-egitim: #6FB0B8;
  --cat-diger: #C7BDB0;
  --cat-maas: #6FA287;
  --cat-ekgelir: #7BC29A;

  --radius-s: 12px;
  --radius-m: 18px;
  --radius-l: 26px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #201A1D;
    --surface: #2B2226;
    --border: #3D3034;
    --text: #F5E9E4;
    --text-soft: #C7AFB2;
    --ink-soft: #C7AFB2;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    --amber-soft: #3D2C28;
    --income-soft: #22302A;
    --expense-soft: #3B252A;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  background: var(--paper);
  color: var(--text);
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3 { font-family: "Baloo 2", "Nunito", sans-serif; font-weight: 600; margin: 0; }

button { font-family: inherit; -webkit-appearance: none; appearance: none; }

.mono, .stat-value, .tx-amount, input[type="number"] {
  font-family: "Nunito", sans-serif;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ===================== BOOT ===================== */
.boot-screen {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: var(--paper); color: var(--ink-soft); z-index: 100;
}
.boot-mark { animation: pulse 1.6s ease-in-out infinite; }
.boot-mark img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; box-shadow: var(--shadow); }
@keyframes pulse { 0%,100%{opacity:.6} 50%{opacity:1} }

/* ===================== LOGIN ===================== */
.login-screen {
  position: fixed; inset: 0; z-index: 90; display: flex; align-items: center;
  justify-content: center; background: var(--ink);
  padding: 24px; padding-block: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-bottom));
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border-radius: var(--radius-l); padding: 32px 24px; box-shadow: var(--shadow);
}
.brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 10px; text-align: center; }
.brand h1 { font-size: 1.6rem; color: var(--ink); }
.brand-mark { width: 92px; height: 92px; border-radius: 50%; object-fit: cover; box-shadow: var(--shadow); }
@media (prefers-color-scheme: dark) { .brand h1 { color: var(--text); } }
.login-sub { color: var(--text-soft); margin: 0 0 22px; font-size: .92rem; text-align: center; }

.who-picker { display: flex; gap: 12px; }
.who-btn {
  flex: 1; padding: 22px 8px; border-radius: var(--radius-m); border: 2px solid var(--border);
  background: var(--paper); color: var(--text); font-family: "Baloo 2", "Nunito", sans-serif;
  font-weight: 600; font-size: 1.05rem; cursor: pointer; transition: transform .08s ease, border-color .15s ease;
}
.who-btn:active { transform: scale(0.96); }
.who-btn.selected { border-color: var(--amber); background: var(--amber-soft); }
.login-who { font-size: .92rem; color: var(--text-soft); margin: 0; }
.login-who strong { color: var(--text); font-family: "Baloo 2", "Nunito", sans-serif; }

.login-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--text-soft); }
.field span { font-weight: 600; }
input[type="email"], input[type="password"], input[type="number"], input[type="text"],
input[type="date"], select, textarea {
  font-size: 1rem; padding: 11px 12px; border-radius: var(--radius-s);
  border: 1.5px solid var(--border); background: var(--paper); color: var(--text);
  font-family: inherit; width: 100%;
}
textarea { font-family: inherit; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--amber); outline-offset: 1px; }
.remember { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--text-soft); }
.btn {
  border: none; border-radius: var(--radius-s); padding: 12px 18px; font-size: .95rem;
  font-weight: 600; cursor: pointer; transition: transform .08s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--ink); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-primary { background: var(--amber); color: #201406; } }
.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-danger-ghost { background: transparent; color: var(--expense); border: 1.5px solid var(--expense); }
.btn-block { width: 100%; }
.login-error {
  background: var(--expense-soft); color: var(--expense); padding: 10px 12px;
  border-radius: var(--radius-s); font-size: .85rem; margin: 0;
}
.setup-warning {
  margin-top: 18px; padding: 12px 14px; border-radius: var(--radius-s);
  background: var(--amber-soft); color: var(--ink-strong); font-size: .82rem;
}
@media (prefers-color-scheme: dark) { .setup-warning { color: var(--text); } }
.setup-warning strong { display: block; margin-bottom: 4px; }

/* ===================== APP SHELL ===================== */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center;
  justify-content: space-between; padding: 14px 18px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: var(--ink); color: #fff;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; font-family: "Baloo 2", "Nunito", sans-serif; font-weight: 600; font-size: 1.05rem; }
.topbar-mark { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  background: transparent; border: none; color: inherit; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
}
.icon-btn:active { background: rgba(255,255,255,.12); }

.views { flex: 1; max-width: 640px; width: 100%; margin: 0 auto; padding: 16px 16px 96px; }
.view[hidden] { display: none; }

.month-row {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin-bottom: 16px; color: var(--text);
}
.month-label { font-weight: 600; min-width: 140px; text-align: center; }
.month-row .icon-btn { background: var(--surface); border: 1px solid var(--border); color: var(--text); }

/* ===================== STAT TILES ===================== */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.stat-tile {
  background: var(--surface); border-radius: var(--radius-m); padding: 14px 10px;
  display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow);
  border-top: 3px solid var(--border);
}
.stat-income { border-top-color: var(--income); }
.stat-expense { border-top-color: var(--expense); }
.stat-net { border-top-color: var(--amber); }
.stat-label { font-size: .72rem; color: var(--text-soft); text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.05rem; font-weight: 600; }
.stat-income .stat-value { color: var(--income); }
.stat-expense .stat-value { color: var(--expense); }

/* ===================== CARDS ===================== */
.card {
  background: var(--surface); border-radius: var(--radius-m); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 16px;
}
.card-title { font-size: .95rem; margin-bottom: 12px; color: var(--text); }
.empty-hint { color: var(--text-soft); font-size: .88rem; text-align: center; padding: 18px 8px; }

/* ===================== CATEGORY CHART ===================== */
.category-chart { display: flex; flex-direction: column; gap: 10px; }
.chart-row { display: grid; grid-template-columns: 84px 1fr 64px; align-items: center; gap: 10px; font-size: .82rem; }
.chart-row-label { color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-track { height: 10px; border-radius: 6px; background: var(--paper); overflow: hidden; }
.chart-fill { height: 100%; border-radius: 6px; min-width: 3px; }
.chart-row-value { text-align: right; font-weight: 600; }

/* ===================== AVATAR ROZETİ ===================== */
.avatar-badge {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; color: #fff; font-family: "Baloo 2", "Nunito", sans-serif;
  font-weight: 700; flex-shrink: 0; line-height: 1;
}
.avatar-s { width: 28px; height: 28px; font-size: .78rem; }
.avatar-m { width: 34px; height: 34px; font-size: .9rem; }
.avatar-l { width: 44px; height: 44px; font-size: 1.1rem; }
.avatar-photo { object-fit: cover; border: 2px solid var(--surface); }

/* ===================== TX LIST ===================== */
.filter-row { display: flex; gap: 8px; margin-bottom: 14px; }
.chip {
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text-soft);
  border-radius: 999px; padding: 7px 14px; font-size: .82rem; font-weight: 600; cursor: pointer;
}
.chip-active { background: var(--ink); color: #fff; border-color: var(--ink); }
@media (prefers-color-scheme: dark) { .chip-active { background: var(--amber); color: #201406; border-color: var(--amber); } }

.tx-list { display: flex; flex-direction: column; gap: 8px; }
.tx-row {
  background: var(--surface); border-radius: var(--radius-m); padding: 12px 14px;
  display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow);
}
.tx-main { flex: 1; min-width: 0; }
.tx-cat { font-weight: 600; font-size: .92rem; }
.tx-meta { font-size: .78rem; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-amount { font-weight: 600; font-size: .95rem; white-space: nowrap; }
.tx-amount.income { color: var(--income); }
.tx-amount.expense { color: var(--expense); }
.tx-del {
  background: transparent; border: none; color: var(--text-soft); opacity: .0;
  width: 28px; height: 28px; cursor: pointer; flex-shrink: 0;
}
.tx-row:hover .tx-del, .tx-row:focus-within .tx-del { opacity: 1; }
.tx-del { opacity: 1; } /* touch devices have no hover; keep visible but subtle */

/* ===================== NOTES ===================== */
.notes-list { display: flex; flex-direction: column; gap: 10px; }
.note-card { background: var(--surface); border-radius: var(--radius-m); padding: 14px 16px; box-shadow: var(--shadow); }
.note-card.pinned { border-left: 4px solid var(--amber); }
.note-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.note-head-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.note-pin { flex-shrink: 0; }
.note-title { font-family: "Baloo 2", "Nunito", sans-serif; font-weight: 600; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-body { white-space: pre-wrap; color: var(--text); font-size: .9rem; line-height: 1.5; margin: 6px 0 8px; }
.note-meta { font-size: .74rem; color: var(--text-soft); display: flex; justify-content: space-between; align-items: center; }
.note-del { background: transparent; border: none; color: var(--text-soft); cursor: pointer; font-size: .78rem; }

/* ===================== LİSTELER (market / film-mekan) ===================== */
.shopping-list { display: flex; flex-direction: column; gap: 8px; }
.shopping-row {
  background: var(--surface); border-radius: var(--radius-m); padding: 10px 14px;
  display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow);
}
.shopping-row.checked { opacity: .55; }
.shopping-row.checked .shopping-text { text-decoration: line-through; }
.shopping-check {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border);
  background: var(--paper); color: #fff; font-weight: 700; font-size: .85rem;
  display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.shopping-row.checked .shopping-check { background: var(--income); border-color: var(--income); }
.shopping-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }

.mealplan-table { display: flex; flex-direction: column; gap: 8px; }
.meal-row {
  background: var(--surface); border-radius: var(--radius-m); padding: 10px 14px;
  display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 10px; box-shadow: var(--shadow);
}
.meal-day { font-weight: 600; font-size: .82rem; color: var(--text-soft); }
.meal-row input {
  border: none; background: transparent; padding: 4px 0; font-size: .9rem; color: var(--text); font-family: inherit;
}
.meal-row input:focus { outline: none; border-bottom: 1.5px solid var(--amber); }

/* ===================== MOOD TRACKER ===================== */
.mood-row { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.mood-pill {
  -webkit-appearance: none; appearance: none;
  display: flex; align-items: center; gap: 10px; background: var(--surface); color: var(--text);
  border: 1.5px solid var(--border); border-radius: var(--radius-l); padding: 8px 14px;
  box-shadow: var(--shadow); text-align: left; cursor: default; width: 100%; opacity: 1;
}
.mood-pill-mine { cursor: pointer; border-color: var(--amber); }
.mood-pill-mine:active { transform: scale(0.98); }
.mood-pill:disabled { cursor: default; opacity: .7; -webkit-text-fill-color: var(--text); }
.mood-text { font-size: .86rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mood-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0; }
.mood-option {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 6px;
  border: 1.5px solid var(--border); border-radius: var(--radius-m); background: var(--paper); cursor: pointer;
}
.mood-option:active { background: var(--amber-soft); border-color: var(--amber); }
.mood-option-emoji { font-size: 1.6rem; }
.mood-option-label { font-size: .68rem; color: var(--text-soft); text-align: center; }

/* ===================== POKE (Seni düşünüyorum) ===================== */
.poke-btn { position: relative; }
@keyframes poke-glow-anim {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 0 8px var(--amber-soft); }
}
.poke-glow { animation: poke-glow-anim 0.7s ease-in-out 2; color: var(--amber); }

/* ===================== PHOTOS ===================== */
.photos-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photo-thumb-btn { position: relative; aspect-ratio: 1; border-radius: var(--radius-s); overflow: hidden; border: none; padding: 0; cursor: pointer; background: var(--border); }
.photo-thumb-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-author {
  position: absolute; bottom: 4px; left: 4px; background: rgba(0,0,0,.55); color: #fff;
  font-size: .62rem; padding: 2px 6px; border-radius: 999px;
}
.upload-progress { text-align: center; color: var(--text-soft); font-size: .85rem; margin-top: 10px; }

/* ===================== FAB ===================== */
.fab {
  position: fixed; right: 20px; bottom: calc(78px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%; background: var(--amber); color: #fff;
  border: none; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 15;
}
.fab:active { transform: scale(0.94); }

/* ===================== BOTTOM NAV ===================== */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  background: transparent; border: none; color: var(--text-soft); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 4px 8px; font-size: .68rem; font-weight: 600;
}
.tab-active { color: var(--ink); }
@media (prefers-color-scheme: dark) { .tab-active { color: var(--amber); } }

/* ===================== SHEET / MODAL ===================== */
.sheet-overlay {
  position: fixed; inset: 0; background: rgba(15, 22, 26, .5); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-overlay[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 480px; background: var(--surface);
  border-radius: 22px 22px 0 0; padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px; max-height: 88vh; overflow-y: auto;
  animation: sheet-up .22s ease-out;
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: .4; } to { transform: translateY(0); opacity: 1; } }
.sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: var(--border); margin: 6px auto 0; }
.sheet-title { font-size: 1.15rem; margin-bottom: 4px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 4px; }
.sheet-actions .btn { flex: 1; }
.checkline { display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--text-soft); }

.type-toggle { display: flex; gap: 8px; }
.type-btn {
  flex: 1; padding: 10px; border-radius: var(--radius-s); border: 1.5px solid var(--border);
  background: var(--paper); color: var(--text-soft); font-weight: 600; cursor: pointer;
}
.type-btn.active.type-gider { background: var(--expense-soft); color: var(--expense); border-color: var(--expense); }
.type-btn.active.type-gelir { background: var(--income-soft); color: var(--income); border-color: var(--income); }
.type-btn.active.wtype-btn { background: var(--amber-soft); color: var(--amber); border-color: var(--amber); }

.photo-picker {
  display: flex; align-items: center; justify-content: center; height: 120px;
  border: 2px dashed var(--border); border-radius: var(--radius-m); color: var(--text-soft);
  cursor: pointer; font-size: .88rem; text-align: center; padding: 8px;
}
.photo-preview { width: 100%; max-height: 240px; object-fit: contain; border-radius: var(--radius-m); background: var(--paper); }

/* ===================== LIGHTBOX ===================== */
.lightbox {
  position: fixed; inset: 0; background: rgba(10, 14, 16, .94); z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 20px; padding-top: max(20px, env(safe-area-inset-top));
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 70vh; border-radius: var(--radius-m); object-fit: contain; }
.lightbox-close {
  position: absolute; top: max(16px, env(safe-area-inset-top)); right: 16px; background: rgba(255,255,255,.12);
  color: #fff; border: none; width: 36px; height: 36px; border-radius: 50%; font-size: 1rem; cursor: pointer;
}
.lightbox-info { display: flex; align-items: center; gap: 14px; color: #fff; text-align: center; flex-direction: column; }

/* ===================== TOAST ===================== */
.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink-strong); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: .85rem; z-index: 80; box-shadow: var(--shadow);
}
.toast[hidden] { display: none; }

/* ===================== RESPONSIVE (wider screens) ===================== */
@media (min-width: 480px) {
  .stat-value { font-size: 1.15rem; }
}
