:root {
  --bg: #0f172a;
  --bg-elevated: #1a2436;
  --bg-card: #1e293b;
  --border: #2c3a52;
  --text: #f1f5f9;
  --text-dim: #93a3b8;
  --accent: #34d399;
  --accent-dim: #14532d;
  --danger: #f87171;
  --work: #60a5fa;
  --side: #fbbf24;
  --personal: #c084fc;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: none;
}

body { display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 14px) 18px 12px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.topbar-title {
  font-size: 22px;
  font-weight: 700;
  text-transform: capitalize;
}

.icon-btn {
  background: var(--bg-card);
  border: none;
  border-radius: 12px;
  width: 40px;
  height: 40px;
  font-size: 18px;
  color: var(--text);
}

#main {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px calc(90px + var(--safe-bottom));
}

.screen { animation: fadein .15s ease; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 20px 0 8px;
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0 14px;
}

.chip {
  flex: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
}

.chip.active {
  background: var(--accent);
  color: #06281a;
  border-color: var(--accent);
  font-weight: 700;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
}

.item-card.done { opacity: .45; }
.item-card.done .item-title { text-decoration: line-through; }

.checkbox {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--text-dim);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--bg);
}

.checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
}

.item-body { flex: 1; min-width: 0; }

.item-title {
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-meta {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.tag.work { background: rgba(96,165,250,.15); color: var(--work); }
.tag.side { background: rgba(251,191,36,.15); color: var(--side); }
.tag.personal { background: rgba(192,132,252,.15); color: var(--personal); }

.due-badge {
  font-size: 12px;
  color: var(--text-dim);
}

.due-badge.overdue { color: var(--danger); font-weight: 600; }

.delete-btn {
  flex: none;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  padding: 4px 6px;
}

.birthday-days {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

.empty-hint {
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 40px;
  display: none;
}

.meal-log {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.meal-log-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}

.meal-log-item.checked { border-color: var(--accent); }

.meal-log-emoji { font-size: 20px; }
.meal-log-label { font-size: 14px; font-weight: 600; }

.fab {
  position: fixed;
  right: 20px;
  bottom: calc(78px + var(--safe-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #06281a;
  font-size: 28px;
  font-weight: 700;
  border: none;
  box-shadow: 0 8px 20px rgba(52,211,153,.35);
  z-index: 20;
}

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: rgba(15,23,42,.92);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding: 8px 0 calc(6px + var(--safe-bottom));
  z-index: 15;
}

.tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 0;
}

.tab.active { color: var(--accent); }
.tab-icon { font-size: 22px; }

.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.sheet-overlay.visible { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-elevated);
  border-radius: 20px 20px 0 0;
  padding: 10px 20px calc(24px + var(--safe-bottom));
  z-index: 31;
  transform: translateY(110%);
  transition: transform .25s cubic-bezier(.32,.72,0,1);
  max-height: 85vh;
  overflow-y: auto;
}

.sheet.visible { transform: translateY(0); }

.sheet-handle {
  width: 36px;
  height: 5px;
  background: var(--border);
  border-radius: 999px;
  margin: 6px auto 14px;
}

.sheet h3 {
  margin: 0 0 16px;
  font-size: 18px;
}

.sheet input[type="text"],
.sheet input[type="date"],
.sheet input[type="time"] {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  margin-bottom: 12px;
}

.field-label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.segmented {
  display: flex;
  background: var(--bg-card);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 14px;
  gap: 4px;
}

.seg {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 8px 0;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
}

.seg.active { background: var(--accent); color: #06281a; }

.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.btn-primary, .btn-secondary {
  flex: 1;
  border: none;
  border-radius: 12px;
  padding: 13px 0;
  font-size: 15px;
  font-weight: 700;
}

.btn-primary { background: var(--accent); color: #06281a; }
.btn-secondary { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }

.btn-small { flex: none; padding: 8px 16px; font-size: 13px; }

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.settings-row-title { font-size: 15px; font-weight: 600; }
.settings-row-hint { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.settings-note {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 14px 0 4px;
}

.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  z-index: 100;
}

.login-box {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-box h1 {
  font-size: 22px;
  margin: 0 0 8px;
}

.login-hint {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0 0 20px;
}

.login-box input[type="password"] {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 16px;
  margin-bottom: 14px;
  text-align: center;
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin: -6px 0 14px;
}

.login-box .btn-primary { width: 100%; }
