/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f5f5f3;
  --surface:   #ffffff;
  --border:    #e5e5e2;
  --text:      #1a1a1a;
  --muted:     #6b6b6b;
  --hint:      #aaaaaa;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
}

/* ── Top Bar ── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.topbar-title { font-size: 17px; font-weight: 600; }
.topbar-sub   { font-size: 12px; color: var(--muted); margin-top: 2px; }
.today-pill   { font-size: 11px; background: #EBF2FF; color: #1a56db; padding: 4px 10px; border-radius: 20px; font-weight: 500; white-space: nowrap; }

/* ── Summary Strip ── */
.summary-strip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 14px 16px 10px;
  flex-shrink: 0;
}
.scard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px 14px; }
.scard-num { font-size: 24px; font-weight: 600; }
.scard-lbl { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── Brand Scroll ── */
.brand-scroll {
  display: flex;
  gap: 8px;
  padding: 0 16px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.brand-scroll::-webkit-scrollbar { display: none; }

.brand-chip {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 2px solid transparent;
  color: #fff;
  opacity: 0.6;
  transition: opacity .15s, transform .15s;
  user-select: none;
}
.brand-chip.active { opacity: 1; transform: scale(1.06); }

/* ── Filter Row ── */
.section-hdr { padding: 2px 18px 6px; font-size: 12px; font-weight: 500; color: var(--muted); flex-shrink: 0; }
.filter-row  { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; padding: 0 16px 10px; flex-shrink: 0; }
.filter-row::-webkit-scrollbar { display: none; }

.fchip {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  transition: all .15s;
  user-select: none;
}
.fchip.on { background: #1a1a1a; color: #fff; border-color: #1a1a1a; }

/* ── Tasks Area ── */
.tasks-area {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px;
  -webkit-overflow-scrolling: touch;
}

.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px 12px 18px;
  margin-bottom: 10px;
  position: relative;
  overflow: hidden;
  transition: border-color .15s;
}
.task-card:active { opacity: 0.9; }
.task-card-accent { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; border-radius: 4px 0 0 4px; }

.tc-top   { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.tc-title { font-size: 14px; font-weight: 500; line-height: 1.45; flex: 1; }
.tc-title.done { text-decoration: line-through; color: var(--hint); }

.pri-badge { flex-shrink: 0; font-size: 10px; font-weight: 500; padding: 3px 8px; border-radius: 10px; }
.pri-high  { background: #FEE2E2; color: #991b1b; }
.pri-med   { background: #FEF3C7; color: #92400e; }
.pri-low   { background: #D1FAE5; color: #065f46; }

.tc-note { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.5; }

.tc-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.brand-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.meta-txt  { font-size: 11px; color: var(--hint); }
.overdue   { color: #991b1b !important; font-weight: 500 !important; }

.status-chip { font-size: 10px; padding: 2px 8px; border-radius: 10px; font-weight: 500; }
.s-todo   { background: #f3f4f6; color: #6b7280; }
.s-inprog { background: #EBF2FF; color: #1a56db; }
.s-done   { background: #D1FAE5; color: #065f46; }

.tc-actions { display: flex; gap: 6px; margin-top: 10px; border-top: 1px solid var(--border); padding-top: 9px; }
.act-btn {
  flex: 1; padding: 7px 4px; font-size: 11px; font-weight: 500;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: #f9f9f7; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  font-family: 'DM Sans', sans-serif; transition: background .12s;
}
.act-btn:active { background: #eee; }
.act-btn.danger { color: #991b1b; }

/* ── Empty State ── */
.empty-state { text-align: center; padding: 50px 20px; color: var(--hint); }
.empty-state i { font-size: 44px; display: block; margin-bottom: 14px; }

/* ── FAB ── */
.add-fab { display: flex; justify-content: center; padding: 10px 0 6px; flex-shrink: 0; }
.fab-btn {
  background: #1a1a1a; color: #fff;
  border: none; border-radius: 30px;
  padding: 14px 28px; font-size: 15px; font-weight: 500;
  cursor: pointer; display: flex; align-items: center; gap: 8px;
  font-family: 'DM Sans', sans-serif;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  transition: transform .15s;
}
.fab-btn:active { transform: scale(0.97); }

/* ── Bottom Nav ── */
.bottom-nav {
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  flex-shrink: 0;
}
.bnav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 3px; padding: 4px; cursor: pointer;
  color: var(--hint); font-size: 10px; font-weight: 500;
  transition: color .15s; user-select: none;
}
.bnav-item.active { color: #1a1a1a; }
.bnav-item i { font-size: 22px; }

/* ── Modal ── */
.modal-bg {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.45); z-index: 100;
  align-items: flex-end; justify-content: center;
}
.modal-bg.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 22px 18px max(24px, env(safe-area-inset-bottom));
  width: 100%; max-width: 480px;
  max-height: 90dvh; overflow-y: auto;
  animation: slideup .22s ease;
}
@keyframes slideup {
  from { transform: translateY(50px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-hdr span { font-size: 17px; font-weight: 600; }
.close-btn { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--muted); padding: 4px 8px; }

.field { margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 500; display: block; margin-bottom: 5px; }
.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  outline: none;
  transition: border-color .15s;
}
.field input:focus,
.field textarea:focus { border-color: #1a1a1a; }
.field textarea { resize: none; height: 76px; }

.seg-row { display: flex; gap: 7px; flex-wrap: wrap; }
.seg {
  padding: 7px 14px; border-radius: 20px; font-size: 12px;
  cursor: pointer; border: 1px solid var(--border);
  background: #f9f9f7; color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  transition: all .15s; user-select: none;
}
.seg.sel { background: #1a1a1a; color: #fff; border-color: #1a1a1a; }

.save-btn {
  width: 100%; padding: 14px;
  background: #1a1a1a; color: #fff;
  border: none; border-radius: var(--radius-md);
  font-size: 15px; font-weight: 600;
  cursor: pointer; margin-top: 8px;
  font-family: 'DM Sans', sans-serif;
  transition: opacity .15s;
}
.save-btn:active { opacity: 0.85; }
