/* ================= Tema ================= */
:root {
  --bg: #f3f4fa;
  --bg-glow-1: rgba(129, 140, 248, .18);
  --bg-glow-2: rgba(232, 121, 249, .12);
  --side: rgba(255, 255, 255, .7);
  --surface: #ffffff;
  --surface-2: #f6f7fc;
  --text: #1a1d2e;
  --muted: #6b7190;
  --border: #e4e6f0;
  --shadow: 0 1px 2px rgba(20, 24, 50, .04), 0 6px 20px rgba(20, 24, 50, .06);
  --shadow-hover: 0 2px 4px rgba(20, 24, 50, .06), 0 12px 32px rgba(20, 24, 50, .10);
  --grad: linear-gradient(135deg, #6366f1, #d946ef);
  --danger: #e11d48;
  --radius: 16px;
}

[data-theme="dark"] {
  --bg: #0b0d1a;
  --bg-glow-1: rgba(99, 102, 241, .22);
  --bg-glow-2: rgba(217, 70, 239, .14);
  --side: rgba(17, 20, 38, .75);
  --surface: #151933;
  --surface-2: #1b2040;
  --text: #e8eaf6;
  --muted: #8d93b8;
  --border: rgba(148, 158, 230, .12);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --shadow-hover: 0 2px 6px rgba(0, 0, 0, .35), 0 14px 36px rgba(0, 0, 0, .35);
  --grad: linear-gradient(135deg, #818cf8, #e879f9);
  --danger: #fb7185;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }

body {
  font: 14.5px/1.5 "Plus Jakarta Sans", system-ui, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 600px at 85% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(700px 500px at 10% 110%, var(--bg-glow-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }
svg { flex: none; }

/* ================= Layout ================= */
.app {
  display: grid;
  grid-template-columns: 290px 1fr;
  height: 100vh;
}

/* ================= Sidebar ================= */
.sidebar {
  display: flex; flex-direction: column;
  padding: 22px 16px 16px;
  background: var(--side);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 20px; }
.logo {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--grad);
  box-shadow: 0 6px 18px rgba(99, 102, 241, .35);
}
.logo svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.brand-name { font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; color: var(--muted); }

.overall {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  padding: 14px;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.ring { width: 56px; height: 56px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring-bg { stroke: var(--surface-2); }
.ring-fg {
  stroke: url(#ringGrad); stroke-linecap: round;
  stroke-dasharray: 163.36; stroke-dashoffset: 163.36;
  transition: stroke-dashoffset .5s cubic-bezier(.4, 0, .2, 1);
}
.ring-label {
  position: absolute; left: 14px; width: 56px;
  text-align: center; font-size: 13px; font-weight: 800;
}
.overall-title { font-weight: 700; }
.overall-sub { font-size: 12.5px; color: var(--muted); }

.nav-label {
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
  padding: 10px 10px 6px;
}
.nav-item {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin-bottom: 2px;
  border: 0; border-radius: 10px; background: none;
  text-align: left; font-weight: 500; font-size: 13.5px;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--surface); color: var(--text); font-weight: 650;
  box-shadow: var(--shadow);
}
.nav-icon {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--c) 16%, transparent);
  color: var(--c);
}
.nav-icon svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.nav-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-count {
  font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums;
  padding: 1px 8px; border-radius: 99px;
  background: var(--surface-2); color: var(--muted);
}
.nav-count.full { background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--c); }

.side-foot { margin-top: auto; padding-top: 16px; display: grid; gap: 10px; }

.theme-switch {
  position: relative;
  display: grid; grid-template-columns: 1fr 1fr;
  padding: 4px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-2);
}
.theme-switch::before {
  content: ""; position: absolute; top: 4px; bottom: 4px; left: 4px;
  width: calc(50% - 4px); border-radius: 9px;
  background: var(--surface); box-shadow: var(--shadow);
  transition: transform .25s cubic-bezier(.4, 0, .2, 1);
}
[data-theme="dark"] .theme-switch::before { transform: translateX(100%); }
.ts-opt {
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.ts-opt svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
[data-theme="light"] .ts-light,
[data-theme="dark"] .ts-dark { color: var(--text); }

.link-btn {
  border: 0; background: none; padding: 4px;
  font-size: 12px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { color: var(--danger); }

/* ================= Main ================= */
.main {
  overflow-y: auto;
  padding: 32px 40px 40px;
}
.main-inner { max-width: 1200px; margin: 0 auto; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  margin-bottom: 22px;
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--c, var(--muted));
}
.page-title { margin: 4px 0 0; font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.page-sub { margin: 4px 0 0; color: var(--muted); }

.head-actions { display: flex; gap: 10px; align-items: center; }

.seg {
  display: inline-flex; padding: 4px; gap: 2px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
}
.seg button {
  border: 0; background: none; padding: 6px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--muted);
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--c, #6366f1); color: #fff; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow);
}
.btn:hover { box-shadow: var(--shadow-hover); }
.btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.gbar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-bottom: 22px; border: 1px solid var(--border); }
.gbar > div {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--c), color-mix(in srgb, var(--c) 55%, #e879f9));
  transition: width .4s cubic-bezier(.4, 0, .2, 1);
}

/* ================= Input tambah ================= */
.add {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 6px 4px 16px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.add:focus-within {
  border-color: var(--c);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 18%, transparent);
}
.add > svg { width: 18px; height: 18px; fill: none; stroke: var(--c); stroke-width: 2.4; stroke-linecap: round; }
.add input {
  flex: 1; border: 0; outline: none; background: none;
  font: inherit; color: var(--text); padding: 10px 0;
}
.add input::placeholder { color: var(--muted); }
.add button {
  border: 0; padding: 8px 16px; border-radius: 10px;
  background: var(--c); color: #fff; font-weight: 700; font-size: 13px;
}

/* ================= Tugas (grid) ================= */
.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 10px;
}

.task {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 14px 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s, opacity .2s;
}
.task:hover { transform: translateY(-1px); box-shadow: var(--shadow-hover); }
.task.done { opacity: .6; }

.check { position: relative; flex: none; cursor: pointer; margin-top: 1px; }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check span {
  display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--c) 55%, var(--border));
  transition: background .15s, border-color .15s, transform .15s;
}
.check:hover span { background: color-mix(in srgb, var(--c) 12%, transparent); }
.check span svg { width: 12px; height: 12px; fill: none; stroke: #fff; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transform: scale(.5); transition: .15s; }
.check input:checked + span { background: var(--c); border-color: var(--c); transform: scale(1.05); }
.check input:checked + span svg { opacity: 1; transform: none; }
.check input:focus-visible + span { outline: 2px solid var(--c); outline-offset: 3px; }

.body { flex: 1; min-width: 0; }
.num { font-size: 11px; font-weight: 700; color: var(--c); margin-bottom: 1px; }
.text { font-weight: 600; outline: none; word-wrap: break-word; }
.text[contenteditable="true"] {
  background: color-mix(in srgb, var(--c) 14%, transparent);
  border-radius: 6px; padding: 1px 6px; margin: -1px -6px;
}
.task.done .text { text-decoration: line-through; text-decoration-color: var(--muted); }
.note { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.45; }

.del {
  flex: none; width: 28px; height: 28px; margin: -4px -4px 0 0;
  display: grid; place-items: center;
  border: 0; border-radius: 8px; background: none;
  color: var(--muted); opacity: 0; transition: .15s;
}
.del svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.task:hover .del, .del:focus-visible { opacity: 1; }
.del:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }

.empty-state {
  grid-column: 1 / -1;
  padding: 40px; text-align: center; color: var(--muted);
  border: 1.5px dashed var(--border); border-radius: var(--radius);
}

/* ================= Ringkasan ================= */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.stat {
  padding: 18px 20px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.stat.hero { background: var(--grad); color: #fff; border: 0; }
.stat.hero .stat-label { color: rgba(255, 255, 255, .8); }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }
.stat-value small { font-size: 14px; font-weight: 600; opacity: .7; }

.overview { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.ov-card {
  display: flex; flex-direction: column; gap: 12px;
  padding: 18px; text-align: left;
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.ov-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: color-mix(in srgb, var(--c) 45%, var(--border)); }
.ov-top { display: flex; align-items: center; gap: 10px; }
.ov-title { flex: 1; font-weight: 700; font-size: 15px; }
.ov-pct { font-weight: 800; color: var(--c); font-size: 13px; }
.ov-bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.ov-bar > div { height: 100%; border-radius: 99px; background: var(--c); }
.ov-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.ov-list li { display: flex; gap: 8px; font-size: 13px; color: var(--muted); }
.ov-list li::before { content: ""; flex: none; width: 6px; height: 6px; margin-top: 7px; border-radius: 50%; border: 1.5px solid var(--c); }
.ov-done { font-size: 13px; font-weight: 600; color: var(--c); }

/* ================= Catatan ================= */
.notes { columns: 3 300px; column-gap: 14px; }
.note-card {
  break-inside: avoid; margin-bottom: 14px;
  padding: 18px 20px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  border-top: 3px solid var(--c);
}
.note-card h3 { margin: 0 0 8px; font-size: 15px; font-weight: 750; }
.note-card h4 {
  margin: 12px 0 4px; font-size: 11px; font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase; color: var(--c);
}
.note-card ul { margin: 0; padding-left: 18px; font-size: 13.5px; }
.note-card li { margin: 3px 0; }
.note-card li::marker { color: var(--c); }
.quote {
  padding: 12px 14px; margin: 4px 0 12px;
  border-radius: 12px; font-size: 13.5px;
  background: color-mix(in srgb, var(--c) 10%, transparent);
  border-left: 3px solid var(--c);
}

/* ================= Sinkron ================= */
.sync-box {
  padding: 12px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  display: grid; gap: 10px;
}
.sync-row { display: flex; align-items: center; gap: 8px; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.sync-dot.ok { background: #10b981; box-shadow: 0 0 0 4px rgba(16, 185, 129, .18); }
.sync-dot.busy { background: #f59e0b; animation: pulse 1s infinite; }
.sync-dot.err { background: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 18%, transparent); }
@keyframes pulse { 50% { opacity: .35; } }
.sync-text { flex: 1; font-size: 12.5px; font-weight: 600; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.mini-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 5px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: 12px; font-weight: 600; color: var(--text);
}
.mini-btn:hover { border-color: #6366f1; }
.mini-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 24px; border: 1px solid var(--border); border-radius: 20px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-hover);
}
.dialog::backdrop { background: rgba(10, 12, 30, .55); backdrop-filter: blur(4px); }
.dialog h2 { margin: 0 0 6px; font-size: 18px; font-weight: 800; }
.dialog-sub { margin: 0 0 16px; font-size: 13.5px; color: var(--muted); }
.dialog code { font-size: 12.5px; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); color: var(--text); }
.dialog input {
  width: 100%; padding: 11px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2);
  font: inherit; color: var(--text); outline: none;
}
.dialog input:focus { border-color: #6366f1; box-shadow: 0 0 0 4px rgba(99, 102, 241, .18); }
.dialog-err { min-height: 18px; margin: 8px 0 12px; font-size: 12.5px; color: var(--danger); }
.dialog-actions { display: flex; align-items: center; gap: 8px; }
.btn.primary { background: var(--grad); color: #fff; border: 0; }

/* ================= Responsif ================= */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; height: auto; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .main { padding: 24px 18px; overflow: visible; }
  .stats { grid-template-columns: 1fr; }
  .task-grid { grid-template-columns: 1fr; }
  .del { opacity: 1; }
}
