/* ============================================================
   LEDGER — Design Tokens (Vibrant Edition)
============================================================ */
:root{
  /* brand gradient duo */
  --violet:#7C5CFC;
  --violet-deep:#5B3DE0;
  --coral:#FF6584;
  --teal:#00C2A8;
  --amber:#FFB020;
  --red:#FF4D6D;

  --ink:#171332;
  --ink-soft:#241D4A;

  --bg:#F6F4FF;
  --surface:#FFFFFF;
  --surface-2:#EFEBFF;
  --text:#1E1B2E;
  --text-soft:#6B6789;
  --border:rgba(30,27,46,0.09);
  --hairline: rgba(30,27,46,0.09);

  --accent:#7C5CFC;
  --accent-2:#FF6584;
  --gradient-brand: linear-gradient(135deg, var(--violet) 0%, var(--coral) 100%);
  --gradient-hero: linear-gradient(135deg, #241D4A 0%, #4B3A9E 55%, #7C5CFC 100%);
  --shadow-soft: 0 4px 14px rgba(124,92,252,0.14);
  --shadow-card: 0 2px 10px rgba(30,27,46,0.06);
  --glow-accent: 0 8px 22px rgba(124,92,252,0.38);
  --glow-coral: 0 8px 20px rgba(255,101,132,0.4);

  --font-display:'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body:'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 24px;
  --nav-h: 68px;
  --topbar-h: 76px;
}

html[data-theme="dark"]{
  --bg:#100C26;
  --surface:#1C1740;
  --surface-2:#251E4E;
  --text:#F1EEFF;
  --text-soft:#A9A2CE;
  --border:rgba(241,238,255,0.1);
  --hairline: rgba(241,238,255,0.1);
  --accent:#9B82FF;
  --accent-2:#FF7C97;
  --gradient-brand: linear-gradient(135deg, #9B82FF 0%, #FF7C97 100%);
  --gradient-hero: linear-gradient(135deg, #1C1740 0%, #3B2E86 55%, #7C5CFC 100%);
  --shadow-soft: 0 4px 14px rgba(0,0,0,0.35);
  --shadow-card: 0 2px 10px rgba(0,0,0,0.3);
  --glow-accent: 0 8px 24px rgba(155,130,255,0.45);
  --glow-coral: 0 8px 22px rgba(255,124,151,0.42);
}

*,*::before,*::after{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family:var(--font-body);
  background:var(--bg);
  color:var(--text);
  overflow:hidden;
  -webkit-tap-highlight-color: transparent;
  user-select:none;
  width:100vw;
  overflow-x:hidden;
}
h1,h2,h3{ font-family:var(--font-display); margin:0; }
p{ margin:0; }
button{ font-family:inherit; border:none; background:none; cursor:pointer; color:inherit; }
input,select,textarea{ font-family:inherit; }
::-webkit-scrollbar{ width:0; height:0; }

button, .ripple, .nav-item, .note-card, .task-check, .calc-btn, .fab{
  transition: transform .15s cubic-bezier(.3,.7,.4,1), box-shadow .2s ease, background .2s ease, color .2s ease;
}
button:active, .ripple:active{ transform:scale(0.94); }
.fab:active{ transform:scale(0.90); }

/* ============================================================
   SPLASH
============================================================ */
#splash{
  position:fixed; inset:0; z-index:999;
  background:var(--gradient-hero);
  display:flex; align-items:center; justify-content:center;
  transition:opacity .5s ease, visibility .5s ease;
}
#splash.hide{ opacity:0; visibility:hidden; pointer-events:none; }
.splash-mark{ display:flex; flex-direction:column; align-items:center; gap:14px; animation:splashIn .7s ease; }
.splash-word{ font-family:var(--font-display); color:#fff; font-size:24px; letter-spacing:0.01em; font-weight:700; }
@keyframes splashIn{ from{ opacity:0; transform:scale(.85);} to{opacity:1; transform:scale(1);} }

/* ============================================================
   APP SHELL
============================================================ */
#app{ height:100%; width:100%; display:flex; flex-direction:column; max-width:520px; margin:0 auto; position:relative; background:var(--bg); overflow:hidden; }

.topbar{
  height:var(--topbar-h);
  flex-shrink:0;
  display:flex; align-items:flex-end; justify-content:space-between;
  padding:0 20px 14px;
  background:var(--bg);
}
.topbar-title h1{ font-size:26px; font-weight:700; color:var(--text); line-height:1.1; letter-spacing:-0.01em; }
.topbar-title p{ font-size:13px; color:var(--text-soft); margin-top:3px; min-height:16px; font-weight:500; }

.icon-btn{
  width:42px; height:42px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  color:#fff; background:var(--gradient-brand); border:none;
  position:relative; overflow:hidden; flex-shrink:0;
  box-shadow:var(--glow-accent);
}

.page-content{
  flex:1; overflow-y:auto; overflow-x:hidden; width:100%;
  padding:4px 20px calc(var(--nav-h) + 24px);
  -webkit-overflow-scrolling:touch;
}

/* page transition */
.page-enter{ animation:pageIn .32s cubic-bezier(.2,.8,.3,1); }
@keyframes pageIn{ from{ opacity:0; transform:translateY(14px) scale(.99);} to{opacity:1; transform:translateY(0) scale(1);} }

/* ============================================================
   BOTTOM NAV
============================================================ */
.bottom-nav{
  position:absolute; left:0; right:0; bottom:0; height:var(--nav-h);
  background:var(--surface); border-top:1px solid var(--border);
  display:flex; align-items:stretch;
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow:0 -4px 20px rgba(30,27,46,0.06);
}
.nav-item{
  flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:4px;
  color:var(--text-soft); position:relative; z-index:2;
}
.nav-item span{ font-size:11px; font-weight:600; }
.nav-item.active{ color:var(--accent); }
.nav-item.active span{ font-weight:700; }
.nav-item.active svg{ transform:translateY(-2px) scale(1.08); }
.nav-item svg{ transition:transform .25s ease; }

.nav-indicator{
  position:absolute; top:0; height:3px; width:20%;
  background:var(--gradient-brand); border-radius:0 0 4px 4px;
  transition:transform .32s cubic-bezier(.3,.8,.3,1);
  z-index:1; box-shadow:0 2px 8px rgba(124,92,252,0.5);
}

/* ripple */
.ripple{ position:relative; overflow:hidden; }
.ripple-dot{
  position:absolute; border-radius:50%; transform:scale(0);
  background:currentColor; opacity:.25; animation:rippleAnim .55s ease-out forwards;
  pointer-events:none;
}
@keyframes rippleAnim{ to{ transform:scale(2.6); opacity:0; } }

/* ============================================================
   SHARED COMPONENTS
============================================================ */
.section-label{
  font-size:12.5px; font-weight:700; letter-spacing:.01em;
  color:var(--text); margin:22px 0 10px; opacity:.85;
}
.section-label:first-child{ margin-top:6px; }

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

/* --- Home --- */
.hero-card{
  background:var(--gradient-hero);
  border-radius:var(--radius-l);
  padding:24px 22px;
  color:#fff;
  position:relative; overflow:hidden;
  margin-top:8px;
  box-shadow:var(--glow-accent);
}
.hero-card .hero-date{ font-size:13px; opacity:.85; font-weight:600; }
.hero-card h2{ font-size:23px; font-weight:700; margin-top:6px; max-width:85%; line-height:1.3; letter-spacing:-0.01em; }
.hero-ring{ position:absolute; right:-36px; top:-36px; width:150px; height:150px; border-radius:50%; border:24px solid rgba(255,255,255,0.12); }
.hero-ring2{ position:absolute; right:20px; bottom:-50px; width:100px; height:100px; border-radius:50%; background:rgba(255,101,132,0.25); filter:blur(4px); }

.stat-row{ display:flex; gap:12px; margin-top:16px; }
.stat-box{
  flex:1; border-radius:var(--radius-m);
  padding:14px 12px; display:flex; flex-direction:column; gap:2px;
  color:#fff; position:relative; overflow:hidden;
}
.stat-box .stat-num{ font-family:var(--font-display); font-size:25px; font-weight:700; }
.stat-box .stat-label{ font-size:11px; font-weight:600; opacity:.92; }
.stat-box.stat-purple{ background:linear-gradient(145deg, #7C5CFC, #5B3DE0); box-shadow:0 6px 16px rgba(124,92,252,0.35); }
.stat-box.stat-coral{ background:linear-gradient(145deg, #FF6584, #E8456A); box-shadow:0 6px 16px rgba(255,101,132,0.35); }
.stat-box.stat-teal{ background:linear-gradient(145deg, #00C2A8, #009985); box-shadow:0 6px 16px rgba(0,194,168,0.3); }

.quick-row{ display:flex; gap:12px; margin-top:14px; }
.quick-btn{
  flex:1; display:flex; align-items:center; justify-content:center; gap:8px;
  padding:15px; border-radius:var(--radius-m); background:var(--surface); border:1px solid var(--border);
  font-weight:700; font-size:14px; position:relative; overflow:hidden; color:var(--text);
  box-shadow:var(--shadow-card);
}
.quick-btn.primary{ background:var(--gradient-brand); color:#fff; border-color:transparent; box-shadow:var(--glow-accent); }

.preview-row{
  display:flex; align-items:center; justify-content:space-between; padding:13px 2px;
  border-bottom:1px solid var(--hairline);
}
.preview-row:last-child{ border-bottom:none; }
.preview-title{ font-size:14.5px; font-weight:600; }
.preview-sub{ font-size:12.5px; color:var(--text-soft); margin-top:2px; font-weight:500; }
.chev{ color:var(--accent); opacity:.8; }

/* --- Notes --- */
.search-wrap{ position:relative; margin:8px 0 4px; }
.search-wrap input{
  width:100%; padding:13px 14px 13px 42px; border-radius:var(--radius-m);
  border:1px solid var(--border); background:var(--surface); color:var(--text); font-size:14.5px;
  box-shadow:var(--shadow-card);
}
.search-wrap input:focus{ outline:2px solid var(--accent); outline-offset:1px; }
.search-wrap svg{ position:absolute; left:14px; top:50%; transform:translateY(-50%); color:var(--accent); }

.notes-grid{ display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-top:14px; }
.note-card{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-m);
  padding:15px; min-height:120px; display:flex; flex-direction:column; position:relative;
  border-top:4px solid var(--note-color, var(--accent));
  box-shadow:var(--shadow-card);
}
.note-card h3{ font-size:14.5px; font-weight:700; margin-bottom:6px; line-height:1.3; }
.note-card p{ font-size:12.5px; color:var(--text-soft); line-height:1.5; flex:1; overflow:hidden; display:-webkit-box; -webkit-line-clamp:4; -webkit-box-orient:vertical; }
.note-card .note-date{ font-size:10.5px; color:var(--note-color, var(--accent)); margin-top:8px; font-weight:700; }

.fab{
  position:absolute; right:20px; bottom:calc(var(--nav-h) + 20px);
  width:58px; height:58px; border-radius:50%; background:var(--gradient-brand); color:#fff;
  display:flex; align-items:center; justify-content:center; box-shadow:var(--glow-coral);
  z-index:5;
}

.empty-state{ text-align:center; padding:60px 20px 20px; color:var(--text-soft); }
.empty-state svg{ margin-bottom:14px; opacity:.6; color:var(--accent); }
.empty-state h3{ font-size:16px; color:var(--text); margin-bottom:6px; font-weight:700; }
.empty-state p{ font-size:13px; line-height:1.5; font-weight:500; }

/* --- Tasks --- */
.progress-card{ display:flex; align-items:center; gap:16px; padding:18px; margin-top:8px; background:var(--gradient-hero); border:none; width:100%; }
.progress-ring{ position:relative; width:64px; height:64px; flex-shrink:0; }
.progress-ring svg{ transform:rotate(-90deg); }
.progress-ring-bg{ stroke:rgba(255,255,255,0.2); }
.progress-ring-fg{ stroke:#FF6584; stroke-linecap:round; transition:stroke-dashoffset .5s ease; }
.progress-ring-text{ position:absolute; inset:0; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:14px; font-family:var(--font-display); color:#fff; }
.progress-info{ min-width:0; }
.progress-info h3{ font-size:15px; font-weight:700; color:#fff; }
.progress-info p{ font-size:12.5px; color:rgba(255,255,255,0.75); margin-top:2px; font-weight:500; }

.filter-tabs{ display:flex; gap:6px; margin:16px 0 6px; background:var(--surface-2); padding:5px; border-radius:16px; }
.filter-tab{
  flex:1; min-width:0; padding:9px 6px; border-radius:12px; font-size:12.5px; font-weight:700;
  background:transparent; border:none; color:var(--text-soft); text-align:center; white-space:nowrap;
}
.filter-tab.active{ background:var(--gradient-brand); color:#fff; border-color:transparent; box-shadow:var(--shadow-soft); }

.task-input-card{ margin:14px 0; display:flex; flex-direction:column; gap:8px; }
.add-task-row{ display:flex; gap:8px; width:100%; }
.add-task-row input{
  flex:1; min-width:0; padding:13px 14px; border-radius:var(--radius-m); border:1px solid var(--border);
  background:var(--surface); color:var(--text); font-size:14px; box-shadow:var(--shadow-card);
}
.add-task-row input:focus{ outline:2px solid var(--accent); outline-offset:1px; }
.add-task-row button{
  width:46px; flex-shrink:0; border-radius:var(--radius-m); background:var(--gradient-brand); color:#fff; display:flex; align-items:center; justify-content:center;
  box-shadow:var(--glow-accent);
}
.priority-picker{ display:flex; gap:6px; width:100%; }
.priority-pill{
  flex:1; min-width:0; padding:9px 4px; border-radius:12px; font-size:12px; font-weight:700;
  background:var(--surface); border:1px solid var(--border); color:var(--text-soft); text-align:center;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.priority-pill[data-p="low"].active{ background:rgba(0,194,168,0.16); color:#00907D; border-color:rgba(0,194,168,0.4); }
.priority-pill[data-p="medium"].active{ background:rgba(255,176,32,0.18); color:#C77E00; border-color:rgba(255,176,32,0.45); }
.priority-pill[data-p="high"].active{ background:rgba(255,77,109,0.16); color:var(--red); border-color:rgba(255,77,109,0.4); }
html[data-theme="dark"] .priority-pill[data-p="medium"].active{ color:var(--amber); }
html[data-theme="dark"] .priority-pill[data-p="low"].active{ color:var(--teal); }

.task-list{ display:flex; flex-direction:column; gap:9px; margin-top:8px; width:100%; }
.task-item{
  display:flex; align-items:center; gap:10px; padding:14px; background:var(--surface);
  border:1px solid var(--border); border-radius:var(--radius-m); box-shadow:var(--shadow-card); width:100%;
}
.task-num{ font-size:11px; font-weight:700; color:var(--text-soft); width:16px; flex-shrink:0; }
.task-check{
  width:24px; height:24px; border-radius:50%; border:2px solid var(--border); flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
}
.task-check.done{ background:linear-gradient(135deg, var(--teal), #009985); border-color:transparent; box-shadow:0 3px 10px rgba(0,194,168,0.4); }
.task-body{ flex:1; min-width:0; }
.task-text{ font-size:14px; font-weight:600; transition:all .2s ease; overflow-wrap:anywhere; }
.task-item.done{ opacity:0.6; }
.task-item.done .task-text{ color:var(--text-soft); text-decoration:line-through; }
.task-meta{ display:flex; gap:6px; margin-top:5px; align-items:center; flex-wrap:wrap; }
.priority-chip{ font-size:10px; font-weight:700; padding:3px 9px; border-radius:20px; text-transform:uppercase; letter-spacing:.03em; flex-shrink:0; }
.priority-high{ background:rgba(255,77,109,0.14); color:var(--red); }
.priority-medium{ background:rgba(255,176,32,0.16); color:#C77E00; }
.priority-low{ background:rgba(0,194,168,0.14); color:#00907D; }
html[data-theme="dark"] .priority-medium{ color:var(--amber); }
html[data-theme="dark"] .priority-low{ color:var(--teal); }
.task-del{ color:var(--text-soft); flex-shrink:0; padding:4px; }

/* --- Calculator --- */
.calc-display{
  margin-top:10px; padding:28px 22px 22px; border-radius:var(--radius-l);
  background:var(--gradient-hero); color:#fff; text-align:right; min-height:124px;
  display:flex; flex-direction:column; justify-content:flex-end; overflow:hidden;
  box-shadow:var(--glow-accent); position:relative;
}
.calc-expr{ font-size:14px; color:rgba(255,255,255,0.6); min-height:18px; word-break:break-all; font-weight:500; }
.calc-result{ font-family:var(--font-display); font-size:42px; font-weight:700; margin-top:4px; word-break:break-all; line-height:1.1; }

.calc-grid{ display:grid; grid-template-columns:repeat(4,1fr); gap:11px; margin-top:16px; }
.calc-btn{
  aspect-ratio:1; border-radius:50%; background:var(--surface); border:1px solid var(--border);
  font-size:19px; font-weight:600; display:flex; align-items:center; justify-content:center;
  position:relative; overflow:hidden; color:var(--text); box-shadow:var(--shadow-card);
}
.calc-btn.op{ background:var(--surface-2); color:var(--accent); font-weight:700; }
.calc-btn.equal{ background:var(--gradient-brand); color:#fff; box-shadow:var(--glow-coral); }
.calc-btn.func{ color:var(--red); font-size:15px; font-weight:700; }

/* --- Profile / Settings --- */
.profile-header{ display:flex; flex-direction:column; align-items:center; text-align:center; padding:22px 0 8px; }
.avatar{
  width:88px; height:88px; border-radius:50%; background:var(--gradient-brand);
  display:flex; align-items:center; justify-content:center; font-family:var(--font-display); font-size:30px; font-weight:700; color:#fff;
  box-shadow:var(--glow-accent);
}
.profile-header h2{ margin-top:14px; font-size:20px; font-weight:700; }
.profile-header p{ font-size:13px; color:var(--text-soft); margin-top:2px; font-weight:500; }

.badge-row{ display:flex; gap:8px; margin-top:12px; flex-wrap:wrap; justify-content:center; }
.badge{ font-size:11.5px; font-weight:700; padding:6px 13px; border-radius:20px; background:var(--surface-2); color:var(--accent); border:1px solid var(--border); }

.info-list{ margin-top:10px; }
.info-row{ display:flex; justify-content:space-between; align-items:center; padding:13px 2px; border-bottom:1px solid var(--hairline); }
.info-row:last-child{ border-bottom:none; }
.info-label{ font-size:13.5px; color:var(--text-soft); font-weight:600; }
.info-value{ font-size:13.5px; font-weight:700; text-align:right; }

.settings-row{ display:flex; justify-content:space-between; align-items:center; padding:14px 2px; border-bottom:1px solid var(--hairline); }
.settings-row:last-child{ border-bottom:none; }
.settings-label{ font-size:14.5px; font-weight:600; }
.settings-sub{ font-size:12px; color:var(--text-soft); margin-top:2px; font-weight:500; }

.switch{ width:48px; height:27px; border-radius:20px; background:var(--border); position:relative; flex-shrink:0; }
.switch.on{ background:var(--gradient-brand); box-shadow:var(--shadow-soft); }
.switch-knob{ position:absolute; top:3px; left:3px; width:21px; height:21px; border-radius:50%; background:#fff; transition:transform .25s cubic-bezier(.3,.9,.3,1); box-shadow:0 1px 4px rgba(0,0,0,0.3); }
.switch.on .switch-knob{ transform:translateX(21px); }

.danger-btn{
  width:100%; padding:15px; border-radius:var(--radius-m); background:rgba(255,77,109,0.1); color:var(--red);
  font-weight:700; font-size:14px; margin-top:16px; border:1px solid rgba(255,77,109,0.25);
}

.tech-chip-row{ display:flex; gap:8px; flex-wrap:wrap; margin-top:10px; }
.tech-chip{ font-size:11.5px; font-weight:700; padding:7px 12px; border-radius:10px; background:var(--surface-2); border:1px solid var(--border); color:var(--accent); }

.footer-credit{ text-align:center; padding:28px 0 6px; color:var(--text-soft); font-size:11.5px; line-height:1.6; font-weight:500; }

/* ============================================================
   MODAL
============================================================ */
.modal-backdrop{
  position:fixed; inset:0; background:rgba(16,12,38,0.55); z-index:100;
  display:flex; align-items:flex-end; justify-content:center;
  opacity:0; transition:opacity .25s ease;
}
.modal-backdrop.show{ opacity:1; }
.modal-sheet{
  background:var(--bg); width:100%; max-width:520px; border-radius:26px 26px 0 0;
  padding:20px 20px calc(20px + env(safe-area-inset-bottom,0));
  transform:translateY(100%); transition:transform .32s cubic-bezier(.2,.85,.3,1);
  max-height:85vh; overflow-y:auto;
  box-shadow:0 -10px 40px rgba(30,27,46,0.2);
}
.modal-backdrop.show .modal-sheet{ transform:translateY(0); }
.modal-handle{ width:38px; height:4px; background:var(--border); border-radius:4px; margin:0 auto 16px; }
.modal-sheet h2{ font-size:19px; font-weight:700; margin-bottom:16px; }
.modal-sheet input, .modal-sheet textarea{
  width:100%; padding:13px 14px; border-radius:var(--radius-m); border:1px solid var(--border);
  background:var(--surface); color:var(--text); font-size:14.5px; margin-bottom:12px;
}
.modal-sheet input:focus, .modal-sheet textarea:focus{ outline:2px solid var(--accent); outline-offset:1px; }
.modal-sheet textarea{ min-height:110px; resize:none; font-family:inherit; }
.color-picker{ display:flex; gap:12px; margin-bottom:18px; }
.color-dot{ width:32px; height:32px; border-radius:50%; border:2px solid transparent; box-shadow:0 2px 8px rgba(0,0,0,0.15); }
.color-dot.selected{ border-color:var(--text); transform:scale(1.12); }
.modal-actions{ display:flex; gap:10px; }
.modal-btn{ flex:1; padding:15px; border-radius:var(--radius-m); font-weight:700; font-size:14.5px; text-align:center; }
.modal-btn.ghost{ background:var(--surface-2); color:var(--text); }
.modal-btn.solid{ background:var(--gradient-brand); color:#fff; box-shadow:var(--glow-accent); }
.modal-btn.danger{ background:var(--red); color:#fff; box-shadow:0 8px 20px rgba(255,77,109,0.35); }

/* ============================================================
   TOAST
============================================================ */
.toast{
  position:fixed; left:50%; bottom:calc(var(--nav-h) + 22px); transform:translateX(-50%) translateY(20px);
  background:var(--gradient-hero); color:#fff; padding:13px 22px; border-radius:30px; font-size:13.5px; font-weight:600;
  box-shadow:0 10px 26px rgba(30,27,46,0.3); z-index:200; opacity:0; transition:all .3s cubic-bezier(.2,.85,.3,1);
  max-width:88%; text-align:center;
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }

/* ============================================================
   RESPONSIVE
============================================================ */
@media (max-width:340px){
  .notes-grid{ grid-template-columns:1fr; }
}

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