:root {
  --bg: #0b1020;
  --panel: #121933;
  --panel-2: #182241;
  --text: #edf2ff;
  --muted: #a8b3cf;
  --accent: #78e08f;
  --accent-2: #7aa2ff;
  --danger: #ff7a90;
  --border: rgba(255,255,255,0.08);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(122,162,255,0.14), transparent 30%),
    linear-gradient(180deg, #0b1020, #0f1530);
  color: var(--text);
}

body, input, select, textarea, button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px calc(92px + env(safe-area-inset-bottom)) 14px;
}

.topbar, .section-header, .row { display: flex; gap: 12px; align-items: center; }
.topbar {
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}
.topbar > div:first-child { max-width: 260px; }
.topbar-chip {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  white-space: nowrap;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 30px; line-height: 0.95; letter-spacing: -0.03em; }
h2 { font-size: 18px; }
.muted { color: var(--muted); }
.section-header { align-items: baseline; flex-wrap: wrap; justify-content: space-between; }
.section-header .muted { font-size: 14px; }

.tabs {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin: 0 -2px 14px;
  padding: 10px 2px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(11,16,32,0), rgba(11,16,32,0.98) 28%);
}
.tab {
  width: 100%;
  min-width: 0;
  min-height: 54px;
  padding: 8px 4px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-size: 11px;
  line-height: 1.1;
  font-weight: 750;
  white-space: normal;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-wrap: anywhere;
}
.tab-add {
  background: linear-gradient(180deg, rgba(120,224,143,0.85), rgba(120,224,143,0.65));
  color: #09111f;
}
.tab.active {
  background: var(--accent-2);
  color: white;
  border-color: rgba(122,162,255,0.55);
  box-shadow: 0 8px 20px rgba(122,162,255,0.25);
}
@media (max-width: 360px) {
  .tab { font-size: 10px; padding: 8px 2px; }
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }
.grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.card {
  background: rgba(18, 25, 51, 0.88);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 16px;
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.16);
}
.hero-card {
  background: linear-gradient(180deg, rgba(122,162,255,0.14), rgba(18,25,51,0.92));
}
.timeline-card {
  border-left: 3px solid rgba(122,162,255,0.35);
}
.add-card {
  background: linear-gradient(180deg, rgba(120,224,143,0.12), rgba(18,25,51,0.92));
}
.insights-hero {
  background: linear-gradient(180deg, rgba(186,146,255,0.12), rgba(18,25,51,0.92));
}
.soft-card { background: rgba(18, 25, 51, 0.72); }
.span-2 { grid-column: span 1; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.small { gap: 8px; }
.wrap { flex-wrap: wrap; }
.end { justify-content: flex-end; }

.today-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.metric-pill {
  padding: 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
}
.metric-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}
.metric-pill strong {
  font-size: 22px;
}

.quick-form { gap: 14px; }
.field-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.compact-grid { grid-template-columns: 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { color: var(--muted); font-size: 12px; font-weight: 600; }
.small-field { max-width: 220px; }
.interval-wrap { align-items: start; }
.action-row { justify-content: stretch; }
.mood-field input[type="range"] { width: 100%; }

input, select, textarea, button, .import-label {
  width: 100%;
  font: inherit;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 13px 14px;
}
input, select, textarea { min-width: 0; }
textarea { resize: vertical; }
button, .import-label {
  cursor: pointer;
  background: var(--accent);
  color: #0b1020;
  font-weight: 800;
  text-align: center;
}
button.secondary, .import-label.secondary {
  background: rgba(255,255,255,0.02);
  color: var(--text);
}
button:disabled { opacity: 0.55; cursor: not-allowed; }

.utility-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.utility-grid button, .utility-grid .import-label { min-height: 52px; }

.list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.item {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.item.done { opacity: 0.65; }
.item-main { display: flex; flex-direction: column; gap: 4px; }
.timeline-list .item {
  position: relative;
  padding-left: 18px;
}
.timeline-list .item::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 16px;
  bottom: 16px;
  width: 2px;
  border-radius: 999px;
  background: rgba(122,162,255,0.32);
}
.badges { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(122,162,255,0.16);
  color: #cdd9ff;
  font-size: 12px;
}
.badge.due { background: rgba(255, 190, 92, 0.18); color: #ffd797; }
.badge.overdue { background: rgba(255, 122, 144, 0.18); color: #ffb2bf; }
.badge.today { background: rgba(120, 224, 143, 0.18); color: #b9f5c5; }
.badge.snoozed { background: rgba(199, 146, 234, 0.18); color: #e6c8ff; }
.actions-compact {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}
.actions-compact button { min-width: 0; padding: 10px; }

.calendar-card { gap: 0; }
.calendar-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.calendar-nav { display: flex; align-items: center; gap: 8px; }
.calendar-nav button { width: 42px; min-width: 42px; padding: 10px 0; }
.calendar-month-label { min-width: 124px; text-align: center; color: var(--text); font-weight: 700; }
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0,1fr));
  gap: 6px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0,1fr));
  gap: 6px;
}
.day {
  min-height: 92px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px;
  background: rgba(255,255,255,0.025);
  text-align: left;
}
button.day { color: var(--text); cursor: pointer; }
.day.filler { background: transparent; border-style: dashed; opacity: 0.3; }
.day.today { outline: 2px solid var(--accent-2); }
.day.selected { border-color: rgba(120,224,143,0.55); background: rgba(120,224,143,0.09); }
.day-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.day-number { font-size: 12px; color: var(--muted); }
.day-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(122,162,255,0.18);
  color: #cdd9ff;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.day-preview { display: flex; flex-direction: column; gap: 4px; }
.day-entry { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-focus-card { background: linear-gradient(180deg, rgba(122,162,255,0.08), rgba(18,25,51,0.88)); }
.day-detail-list { margin-top: 10px; }
.day-detail-item { background: rgba(255,255,255,0.04); }

.metric-row { display: flex; justify-content: space-between; gap: 8px; }
.bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
}
.notice {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
}

dialog {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  color: var(--text);
  width: min(540px, calc(100vw - 32px));
}

@media (min-width: 700px) {
  .app-shell {
    max-width: 1100px;
    padding: max(18px, env(safe-area-inset-top)) 20px 28px;
  }
  .tabs {
    position: static;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    background: transparent;
    padding: 0 0 10px;
    margin: 0 0 14px;
  }
  .tab {
    width: auto;
    min-width: 96px;
    min-height: 46px;
    padding: 10px 12px;
    font-size: 14px;
    white-space: nowrap;
  }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .span-2 { grid-column: span 2; }
  .compact-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .item { flex-direction: row; justify-content: space-between; }
  .actions-compact { width: auto; grid-template-columns: repeat(2, auto); }
  .utility-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
