:root {
  --paper: #fbfaf7;
  --surface: #ffffff;
  --surface-soft: #f5f1ea;
  --ink: #25231f;
  --muted: #746f67;
  --line: rgba(37, 35, 31, 0.11);
  --coral: #df6c51;
  --coral-dark: #bd543d;
  --coral-soft: #fae6df;
  --sage: #4e816a;
  --sage-soft: #e1eee7;
  --gold: #a77420;
  --gold-soft: #f8edcf;
  --lilac: #765d91;
  --lilac-soft: #eee7f4;
  --danger: #b23b35;
  --shadow: 0 1px 2px rgba(38, 31, 20, .03), 0 9px 30px rgba(38, 31, 20, .055);
  --sidebar: 252px;
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button { color: inherit; }

.skip-link {
  position: fixed;
  z-index: 100;
  left: 16px;
  top: -60px;
  padding: 10px 14px;
  background: var(--ink);
  color: white;
  border-radius: 8px;
}
.skip-link:focus { top: 12px; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  padding: 28px 18px;
  background: #f2eee7;
  border-right: 1px solid var(--line);
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 28px;
  text-decoration: none;
}
.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: white;
  background: var(--coral);
  border-radius: 13px;
  font-weight: 700;
  box-shadow: 0 5px 14px rgba(223, 108, 81, .22);
}
.brand strong { display: block; font-size: 17px; letter-spacing: -.35px; }
.brand small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.25; }
.nav-list { display: grid; gap: 5px; }
.nav-list a,
.bottom-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 45px;
  padding: 10px 12px;
  border-radius: 11px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: .16s ease;
}
.nav-list a span:first-child { width: 24px; font-size: 18px; text-align: center; }
.nav-list a:hover { color: var(--ink); background: rgba(255, 255, 255, .55); }
.nav-list a.active { color: var(--ink); background: var(--surface); box-shadow: 0 1px 3px rgba(30, 25, 16, .06); }
.sidebar-foot {
  margin-top: auto;
  padding: 12px 9px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; background: var(--sage); border-radius: 50%; }

.main { min-height: 100vh; margin-left: var(--sidebar); padding: 38px clamp(26px, 5vw, 72px) 80px; }
.topbar,
#page { width: min(1120px, 100%); margin-inline: auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 32px; }
.topbar h1 { margin: 4px 0 0; font-size: clamp(29px, 4vw, 40px); letter-spacing: -1.4px; line-height: 1.05; }
.eyebrow { margin: 0; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.install-button,
.primary {
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-radius: 11px;
  background: var(--coral);
  color: white;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 5px 15px rgba(223, 108, 81, .18);
  transition: transform .15s ease, background .15s ease;
}
.install-button:hover, .primary:hover { background: var(--coral-dark); transform: translateY(-1px); }
.install-button:active, .primary:active { transform: translateY(0); }

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: clamp(24px, 4vw, 42px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(135deg, #fff 0%, #fbf2e8 100%);
  box-shadow: var(--shadow);
}
.hero h2 { margin: 8px 0 9px; font-size: clamp(27px, 4vw, 43px); line-height: 1.08; letter-spacing: -1.6px; }
.hero p:last-child { margin: 0; color: var(--muted); font-size: 15px; }
.day-score {
  width: 118px;
  height: 118px;
  display: grid;
  place-content: center;
  flex: 0 0 auto;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: var(--shadow);
}
.day-score strong { font-size: 26px; letter-spacing: -1px; }
.day-score span { margin-top: 3px; color: var(--muted); font-size: 10px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 20px 0; }
.stat-card { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 17px; background: var(--surface); border: 1px solid var(--line); border-radius: 15px; }
.stat-icon { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 11px; font-size: 17px; }
.stat-icon.coral { color: var(--coral); background: var(--coral-soft); }
.stat-icon.sage { color: var(--sage); background: var(--sage-soft); }
.stat-icon.gold { color: var(--gold); background: var(--gold-soft); }
.stat-icon.lilac { color: var(--lilac); background: var(--lilac-soft); }
.stat-card strong, .stat-card span { display: block; }
.stat-card strong { font-size: 20px; letter-spacing: -.6px; }
.stat-card div > span { margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

.dashboard-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 20px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.dashboard-grid > .panel { min-height: 310px; padding: 22px; }
.panel-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.panel-head h2 { margin: 5px 0 0; font-size: 20px; letter-spacing: -.5px; }
.panel-head a, .text-button { color: var(--coral-dark); font-size: 12px; font-weight: 700; text-decoration: none; }
.panel-head a:hover, .text-button:hover { text-decoration: underline; }

.item-list, .habit-grid { padding: 0; margin: 0; list-style: none; }
.item-list { display: grid; }
.item-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--line); }
.item-row:last-child { border-bottom: 0; }
.item-row > span { min-width: 0; overflow-wrap: anywhere; font-size: 14px; }
.item-row.is-done > span { color: var(--muted); text-decoration: line-through; }
.check {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1.5px solid #b7b1a8;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}
.is-done .check { color: white; background: var(--sage); border-color: var(--sage); }
.icon-button { width: 35px; height: 35px; padding: 0; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-button:hover { background: var(--surface-soft); }
.icon-button.danger:hover { color: var(--danger); background: #fbe8e6; }

.habit-grid { display: grid; gap: 9px; }
.habit-grid.large { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.habit-row { display: grid; grid-template-columns: 1fr auto; align-items: center; min-width: 0; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.habit-row.is-done { background: #f3f8f5; border-color: rgba(78, 129, 106, .25); }
.habit-check { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; width: 100%; min-width: 0; padding: 13px; text-align: left; border: 0; background: transparent; cursor: pointer; }
.habit-check > span { grid-row: 1 / 3; align-self: center; color: var(--sage); font-size: 22px; }
.habit-check strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.habit-check small { margin-top: 2px; color: var(--muted); font-size: 10px; }

.composer { padding: 22px; margin-bottom: 22px; }
.composer form > label { display: block; margin-bottom: 10px; font-size: 13px; font-weight: 700; }
.form-row { display: flex; gap: 10px; }
input, textarea {
  width: 100%;
  padding: 12px 14px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(223, 108, 81, .25); outline-offset: 2px; }
.form-row input { flex: 1; }
.helper, .section-meta { color: var(--muted); font-size: 12px; }
.helper { margin: 4px 0 16px; }
.section-meta { display: flex; gap: 15px; margin: 0 2px 12px; }
.item-list.large { padding: 4px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

.goal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.goal-card { padding: 20px; }
.goal-title { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; }
.goal-title h3 { margin: 0; overflow-wrap: anywhere; font-size: 15px; }
.goal-icon { width: 34px; height: 34px; display: grid; place-items: center; color: var(--gold); background: var(--gold-soft); border-radius: 10px; }
.progress-label { display: flex; justify-content: space-between; margin: 20px 0 8px; color: var(--muted); font-size: 11px; }
.progress-label strong { color: var(--ink); }
.progress { height: 8px; overflow: hidden; background: var(--surface-soft); border-radius: 99px; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--coral), #e9a458); border-radius: inherit; }
.range-label { display: grid; gap: 7px; margin-top: 15px; color: var(--muted); font-size: 10px; }
.range-label input { accent-color: var(--coral); padding: 0; }

.notes-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.note-card { min-height: 180px; display: flex; flex-direction: column; padding: 15px; background: #fff8dc; border: 1px solid rgba(167, 116, 32, .16); border-radius: 16px; box-shadow: 0 7px 22px rgba(95, 69, 25, .055); }
.note-card:nth-child(3n+2) { background: #eef5f0; border-color: rgba(78, 129, 106, .15); }
.note-card:nth-child(3n) { background: #f3edf7; border-color: rgba(118, 93, 145, .15); }
.note-card textarea { min-height: 110px; flex: 1; padding: 0; background: transparent; border: 0; resize: none; }
.note-card footer { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 10px; }

.empty { display: grid; justify-items: center; align-content: center; min-height: 220px; padding: 28px; text-align: center; }
.empty > span { width: 48px; height: 48px; display: grid; place-items: center; color: var(--coral); background: var(--coral-soft); border-radius: 15px; font-size: 21px; }
.empty h3 { margin: 13px 0 5px; font-size: 15px; }
.empty p { max-width: 320px; margin: 0 0 11px; color: var(--muted); font-size: 12px; line-height: 1.5; }

.bottom-nav { display: none; }
.toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: 24px;
  padding: 11px 16px;
  color: white;
  background: var(--ink);
  border-radius: 99px;
  box-shadow: var(--shadow);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .notes-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  body { background: var(--paper); }
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 24px 16px calc(105px + env(safe-area-inset-bottom)); }
  .topbar { margin-bottom: 22px; }
  .topbar h1 { font-size: 30px; }
  .install-button { min-height: 40px; padding: 8px 11px; font-size: 11px; }
  .hero { padding: 24px 20px; border-radius: 20px; }
  .day-score { width: 88px; height: 88px; }
  .day-score strong { font-size: 21px; }
  .stats { gap: 10px; }
  .stat-card { padding: 13px; }
  .stat-icon { width: 34px; height: 34px; }
  .dashboard-grid > .panel { padding: 18px; }
  .habit-grid.large, .goal-grid { grid-template-columns: 1fr; }
  .bottom-nav {
    position: fixed;
    z-index: 30;
    inset: auto 10px calc(10px + env(safe-area-inset-bottom)) 10px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 7px;
    background: rgba(255, 255, 255, .92);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 12px 38px rgba(37, 35, 31, .16);
    backdrop-filter: blur(16px);
  }
  .bottom-nav a { justify-content: center; flex-direction: column; gap: 3px; min-width: 0; min-height: 52px; padding: 5px 2px; font-size: 10px; }
  .bottom-nav a span:first-child { font-size: 18px; }
  .bottom-nav a.active { color: var(--coral-dark); background: var(--coral-soft); }
  .check, .icon-button { width: 44px; height: 44px; }
  .toast { bottom: calc(87px + env(safe-area-inset-bottom)); }
}

@media (max-width: 480px) {
  .hero { align-items: flex-start; }
  .hero h2 { font-size: 27px; }
  .hero p:last-child { max-width: 190px; font-size: 12px; }
  .day-score { width: 76px; height: 76px; }
  .day-score strong { font-size: 18px; }
  .day-score span { font-size: 8px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat-card { gap: 9px; }
  .stat-card strong { font-size: 17px; }
  .form-row { flex-direction: column; }
  .form-row .primary { width: 100%; }
  .notes-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

/* Auth, vault and selectively encrypted remote quick notes */
.account { margin-bottom: 1rem; }
.account form, .vault { display: grid; gap: .75rem; }
.account label { display: grid; gap: .35rem; font-weight: 650; }
.account input { width: 100%; padding: .75rem; border: 1px solid var(--line); border-radius: .65rem; font: inherit; }
.vault { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 1rem; }
.vault-status { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.vault-change { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.vault-change summary { width: fit-content; color: var(--coral-dark); font-size: .85rem; font-weight: 700; cursor: pointer; }
.vault-change[open] summary { margin-bottom: .75rem; }
.vault-change .vault { margin-top: 0; }
.sensitive { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: .45rem; font-size: .9rem; font-weight: 650; margin-top: .65rem; }
.sensitive input { width: 1.15rem; height: 1.15rem; }
.note-card form { display: grid; gap: .5rem; height: 100%; }
.note-card form footer { margin-top: auto; }
.note-card.locked { display: grid; place-items: center; min-height: 10rem; color: var(--muted); }
.local-notes { margin-top: 1.5rem; padding: 1.25rem; }
