/* MyTask — v2 compact. Tiga warna sinyal saja: merah = telat, ungu = perlu review, kuning = nunggu orang. */
:root {
  --accent: #d6503c;
  --accent-soft: #fdf3f1;
  --ink: #202020;
  --ink-strong: #1f1f1f;
  --muted: #8a8a8a;
  --faint: #a8a8a8;
  --line: #f3f3f3;
  --border: #ededed;
  --panel: #fafafa;
  --red: #d1453b;
  --red-soft: #fdf1f0;
  --red-ink: #a4382f;
  --orange: #eb8909;
  --orange-soft: #fdf6ec;
  --blue: #4073d6;
  --blue-soft: #f0f4fc;
  --blue-ink: #3a5da8;
  --gray-ring: #c4c4c4;
  --purple: #6a4fc9;
  --purple-soft: #faf9fd;
  --purple-faint: #c9b8f0;
  --yellow-ink: #a1620a;
  --yellow-deep: #7a4e08;
  --yellow-soft: #fdf6ec;
  --green: #2e9e5b;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: #ffffff;
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }
svg { flex-shrink: 0; }
[hidden] { display: none !important; }

/* ---------- Kerangka ---------- */
#app { height: 100dvh; display: flex; overflow: hidden; }
.rail { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.side { display: none; }
.scroll { flex: 1; overflow-y: auto; padding: 0 20px 16px; -webkit-overflow-scrolling: touch; }

.head { padding: calc(20px + env(safe-area-inset-top)) 20px 10px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.head-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.head h1 { margin: 0; font-size: 24px; font-weight: 700; color: var(--ink-strong); }
.head-sub { font-size: 12px; color: var(--muted); white-space: nowrap; }
.health { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 4px; font-size: 11px; font-weight: 600; color: var(--red); }
.health-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.health.bad .health-dot { background: var(--red); }

/* ---------- Brief ---------- */
.brief { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.brief-top { display: flex; justify-content: space-between; align-items: center; width: 100%; min-height: 20px; }
.brief-label { font-size: 11px; font-weight: 600; color: var(--accent); letter-spacing: 0.4px; }
.brief-top svg { color: #b08078; transition: transform 0.15s; }
.brief.collapsed .brief-top svg { transform: rotate(-90deg); }
.brief.collapsed .stats, .brief.collapsed .brief-line { display: none; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 2px 0; }
.stat { background: #ffffff; border-radius: 10px; padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 1px; border: 1.5px solid transparent; min-height: 48px; }
.stat b { font-size: 17px; font-weight: 700; color: var(--ink-strong); }
.stat span { font-size: 9px; font-weight: 500; color: #7a7a7a; }
.stat.telat b { color: var(--red); } .stat.telat span { color: var(--red-ink); }
.stat.meeting b { color: var(--blue); } .stat.meeting span { color: var(--blue-ink); }
.stat.nunggu b, .stat.nunggu span { color: var(--yellow-ink); }
.stat[aria-pressed="true"] { border-color: var(--accent); }
.brief-line { font-size: 12px; color: #8a5a52; }

/* ---------- Bagian & baris ---------- */
.section-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 0 4px; font-size: 12px; font-weight: 600; color: var(--ink-strong); width: 100%; text-align: left; }
.section-head.telat { color: var(--red); }
.section-head.review { color: var(--purple); }
.section-head .hint { font-size: 10px; font-weight: 400; color: var(--faint); }
.section-head svg { color: var(--faint); transition: transform 0.15s; }
.section-head[aria-expanded="false"] svg { transform: rotate(-90deg); }

.row { display: flex; align-items: center; gap: 10px; height: 44px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom-color: transparent; }
.check { width: 44px; height: 44px; margin: 0 -13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ring { width: 18px; height: 18px; border: 2px solid var(--gray-ring); border-radius: 50%; display: block; transition: background 0.12s; }
.ring.urgent { border-color: var(--red); background: var(--red-soft); }
.ring.high { border-color: var(--orange); background: var(--orange-soft); }
.ring.event { border-color: var(--blue); background: var(--blue-soft); }
.check:hover .ring, .check:active .ring { background: #e9e9e9; }
.row-body { flex: 1; min-width: 0; height: 100%; display: flex; align-items: center; gap: 10px; text-align: left; }
.row-icon { color: #b8b8b8; }
.row-title { flex: 1; min-width: 0; font-size: 14px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { font-size: 11px; font-weight: 500; color: var(--muted); flex-shrink: 0; }
.row-meta.late { font-weight: 600; color: var(--red); }
.row-meta.time { color: var(--blue); }
.row-warn { width: 6px; height: 6px; border-radius: 50%; background: var(--red); flex-shrink: 0; }
.row.leaving { opacity: 0; transition: opacity 0.2s; }

/* Perlu review: baris ungu yang bisa digeser */
.review-slot { position: relative; margin-bottom: 6px; border-radius: 0 8px 8px 0; overflow: hidden; }
.review-under { position: absolute; inset: 0; display: flex; justify-content: space-between; align-items: center; padding: 0 12px; font-size: 11px; font-weight: 600; }
.review-under .add { color: var(--purple); }
.review-under .drop { color: var(--muted); }
.review-row { position: relative; display: flex; align-items: center; gap: 10px; padding: 0 10px; min-height: 44px; width: 100%; text-align: left; background: var(--purple-soft); border-left: 2px solid var(--purple); border-radius: 0 8px 8px 0; touch-action: pan-y; }
.review-row.maybe { border-left-color: var(--purple-faint); }
.review-row.maybe .row-title { color: #6a6a6a; }
.review-row .row-title { font-size: 13px; }
.review-row .row-icon { color: #9a9a9a; }
.badge-maybe { font-size: 9px; font-weight: 600; color: var(--yellow-ink); flex-shrink: 0; }
.review-row.snap { transition: transform 0.18s ease-out; }

.empty { padding: 28px 8px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.5; }
.empty b { display: block; color: var(--ink-strong); font-size: 14px; margin-bottom: 2px; }

/* ---------- Strip nunggu, FAB, nav bawah ---------- */
.waitstrip { margin: 0 20px 10px; display: flex; align-items: center; gap: 8px; padding: 0 12px; min-height: 44px; background: var(--yellow-soft); border-radius: 10px; text-align: left; color: var(--yellow-ink); }
.waitstrip span { flex: 1; min-width: 0; font-size: 12px; font-weight: 500; color: var(--yellow-deep); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fab { position: absolute; right: 20px; bottom: calc(76px + env(safe-area-inset-bottom)); width: 52px; height: 52px; border-radius: 50%; background: var(--accent); color: #ffffff; font-size: 25px; line-height: 1; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(0,0,0,0.18); z-index: 5; }
.main.has-strip .fab { bottom: calc(126px + env(safe-area-inset-bottom)); }
.bottomnav { height: calc(60px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--border); display: flex; align-items: stretch; background: #ffffff; flex-shrink: 0; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 10px; font-weight: 500; }
.tab[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* ---------- Memori ---------- */
.search { display: flex; align-items: center; gap: 8px; height: 44px; background: #f5f5f5; border-radius: 10px; padding: 0 12px; margin-bottom: 10px; color: #9a9a9a; }
.search input { border: none; background: transparent; outline: none; font-size: 13px; color: var(--ink); flex: 1; min-width: 0; height: 100%; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; font-weight: 500; color: #6a6a6a; background: #f1f1f1; border-radius: 16px; padding: 0 14px; min-height: 36px; }
.chip[aria-pressed="true"] { font-weight: 600; color: #ffffff; background: var(--accent); }
.group-label { font-size: 11px; font-weight: 600; color: #8a8a8a; letter-spacing: 0.4px; padding: 14px 0 4px; }
.mem { display: flex; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); align-items: flex-start; width: 100%; text-align: left; }
.tag { font-size: 10px; font-weight: 600; border-radius: 4px; padding: 2px 6px; flex-shrink: 0; margin-top: 1px; }
.tag.janji { color: var(--red-ink); background: var(--red-soft); }
.tag.catatan { color: var(--blue-ink); background: var(--blue-soft); }
.tag.orang { color: #2e7d4f; background: #f0faf4; }
.mem-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mem-text b { font-size: 13px; font-weight: 400; color: var(--ink); line-height: 1.4; }
.mem-text small { font-size: 11px; color: #8a8a8a; }
.note-box { margin-top: 14px; background: var(--panel); border: 1px solid #efefef; border-radius: 12px; padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; font-size: 12px; color: #7a7a7a; line-height: 1.5; }

/* ---------- Setelan ---------- */
.card { background: #ffffff; border: 1px solid #efefef; border-radius: 10px; padding: 12px; display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.card-main b { font-size: 13px; font-weight: 600; color: var(--ink-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-main small { font-size: 11px; color: var(--muted); line-height: 1.4; }
.card-main small.err { color: var(--red); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.dot.bad { background: var(--red); }
.dot.off { background: var(--gray-ring); }
.btn { min-height: 44px; padding: 0 16px; border-radius: 10px; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.btn.primary { background: var(--accent); color: #ffffff; }
.btn.ghost { background: #f3f3f3; color: var(--ink); }
.btn.text { color: var(--accent); padding: 0 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; }
.setelan-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.fine { font-size: 11px; color: var(--faint); line-height: 1.5; margin-top: 14px; }

/* ---------- Sheet & quick-add ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.32); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet { background: #ffffff; width: 100%; max-width: 520px; border-radius: 16px 16px 0 0; padding: 18px 20px calc(18px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; max-height: 88dvh; overflow-y: auto; }
.sheet-title { width: 100%; border: none; outline: none; font-family: inherit; font-size: 17px; font-weight: 600; line-height: 1.35; color: var(--ink-strong); padding: 6px 0; border-bottom: 1px solid transparent; resize: none; field-sizing: content; min-height: 36px; max-height: 120px; background: transparent; }
.sheet-title:focus { border-bottom-color: var(--border); }
.sheet-meta { font-size: 12px; color: var(--muted); line-height: 1.5; }
.sheet-note { font-size: 12px; color: #7a7a7a; background: var(--panel); border-radius: 10px; padding: 10px 12px; line-height: 1.5; }
.sheet-err { font-size: 12px; color: var(--red-ink); background: var(--red-soft); border-radius: 10px; padding: 10px 12px; line-height: 1.5; display: flex; align-items: center; gap: 8px; }
.sheet-err span { flex: 1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > span { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 0.3px; }
.field input[type="date"] { height: 44px; border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; background: #ffffff; min-width: 0; }
.field-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sheet-actions .btn { flex: 1; white-space: nowrap; }

.quick { background: #ffffff; width: 100%; max-width: 520px; border-radius: 16px 16px 0 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.quick form { display: flex; gap: 8px; }
.quick input { flex: 1; min-width: 0; height: 48px; border: 1px solid var(--border); border-radius: 12px; padding: 0 14px; font-size: 15px; outline: none; }
.quick input:focus { border-color: var(--accent); }
.quick small { font-size: 11px; color: var(--faint); padding: 0 2px; }

#toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; pointer-events: none; display: flex; flex-direction: column; gap: 6px; align-items: center; width: max-content; max-width: calc(100vw - 32px); }
.toast { pointer-events: auto; background: #2a2a2a; color: #ffffff; font-size: 13px; border-radius: 10px; padding: 0 6px 0 14px; min-height: 44px; display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 14px rgba(0,0,0,0.2); max-width: 100%; }
.toast span { padding: 10px 8px 10px 0; }
.toast button { color: #ffb4a6; font-weight: 600; min-height: 44px; padding: 0 10px; }

/* ---------- Login ---------- */
.login { margin: auto; width: 100%; max-width: 340px; padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.logo { width: 44px; height: 44px; border-radius: 13px; background: var(--accent); color: #ffffff; font-size: 20px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.login-form { display: flex; flex-direction: column; gap: 8px; }
.login h1 { margin: 4px 0 0; font-size: 22px; color: var(--ink-strong); }
.login p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.login input { height: 48px; border: 1px solid var(--border); border-radius: 12px; padding: 0 14px; font-size: 15px; outline: none; }
.login input:focus { border-color: var(--accent); }
.login .err { color: var(--red); font-size: 12px; min-height: 16px; }
.login code { background: #f3f3f3; border-radius: 4px; padding: 1px 5px; font-size: 12px; }

/* ---------- Layar dalam Fold / desktop: dua panel ---------- */
@media (min-width: 600px) {
  .rail { display: flex; width: 60px; border-right: 1px solid var(--border); flex-direction: column; align-items: center; padding: 20px 0; gap: 6px; flex-shrink: 0; }
  .rail .logo { width: 32px; height: 32px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; }
  .rail-tab { width: 44px; height: 44px; border-radius: 12px; color: var(--muted); display: flex; align-items: center; justify-content: center; }
  .rail-tab[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
  .rail-add { margin-top: auto; width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: #ffffff; font-size: 22px; line-height: 1; display: flex; align-items: center; justify-content: center; box-shadow: 0 3px 10px rgba(0,0,0,0.16); }
  .main { flex: 0 1 460px; min-width: 340px; border-right: 1px solid var(--border); }
  .main .head h1 { font-size: 22px; }
  .side { display: flex; flex: 1 1 320px; min-width: 0; flex-direction: column; gap: 14px; padding: 24px 20px 16px; background: var(--panel); overflow-y: auto; }
  .side .brief { margin-bottom: 0; }
  .side h2 { margin: 0 0 8px; font-size: 12px; font-weight: 600; color: var(--ink-strong); }
  .side .card { padding: 0 12px; min-height: 44px; width: 100%; text-align: left; }
  .side .card span.t { font-size: 12px; color: var(--ink); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side .mem-card { align-items: flex-start; padding: 10px 12px; }
  .side .mem-card span.t { white-space: normal; line-height: 1.45; }
  .days { font-size: 11px; font-weight: 600; color: #7a7a7a; background: #f1f1f1; border-radius: 4px; padding: 2px 6px; flex-shrink: 0; }
  .days.late { color: var(--red); background: var(--red-soft); }
  .bottomnav, .fab, .waitstrip, .main .brief { display: none; }
  .overlay { align-items: center; }
  .sheet, .quick { border-radius: 16px; }
  #toast { bottom: 24px; }
  /* Di layar lebar urutannya: Telat → Hari ini → Perlu review (sesuai desain FoldInner). */
  .today-sections { display: flex; flex-direction: column; }
  .today-sections .sec-review { order: 3; }
  .today-sections .sec-later { order: 4; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
