:root {
  --bg: #F4F2F8;
  --surface: #FFFFFF;
  --ink: #1D1A2B;
  --ink-2: #3A3648;
  --muted: #5E5A6E;
  --line: #E3E0EA;
  --field: #C9C5D6;
  --coral: #C8432B;
  --coral-ink: #8E2A17;
  --coral-tint: #FBE7E2;
  --indigo: #3D4BB8;
  --indigo-ink: #2C3890;
  --indigo-tint: #E6E8F8;
  --green-ink: #1F5E3A;
  --green-tint: #E3F2E8;
  --radius: 18px;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'Figtree', system-ui, sans-serif;
  --nav-h: 72px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 16px; -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--indigo); }
a:hover { color: var(--indigo-ink); }
:focus-visible { outline: 3px solid var(--indigo); outline-offset: 2px; }
[hidden] { display: none !important; }

.splash { min-height: 100dvh; display: flex; align-items: center; justify-content: center; }
.brand { font-family: var(--display); font-size: 40px; font-weight: 700; letter-spacing: -0.03em; }

.screen {
  max-width: 480px; margin: 0 auto;
  padding: calc(24px + env(safe-area-inset-top)) 20px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}
.screen.no-nav { padding-bottom: calc(28px + env(safe-area-inset-bottom)); }

h1, .h1 { margin: 0; font-family: var(--display); font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.12; }
h2, .h2 { margin: 0; font-size: 17px; font-weight: 600; }
p { margin: 0; line-height: 1.5; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.lead { font-size: 16px; color: var(--ink-2); line-height: 1.5; }

.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack.tight { gap: 4px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grow { flex: 1; min-width: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.card.dark .label { color: #C9C5D6; }
.card.coral { background: var(--coral-tint); border-color: var(--coral-tint); }
.card.flush { padding: 0; gap: 0; }
a.card { text-decoration: none; color: inherit; }
a.card.dark { color: #fff; }

.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 48px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
a.list-row { text-decoration: none; color: inherit; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 14px; border: 1.5px solid transparent;
  background: var(--coral); color: #fff; font-weight: 600; font-size: 16px; text-decoration: none; cursor: pointer;
}
.btn:hover { color: #fff; filter: brightness(0.95); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.block { width: 100%; }
.btn.dark { background: var(--ink); }
.btn.outline { background: transparent; border-color: var(--indigo); color: var(--indigo); }
.btn.outline:hover { color: var(--indigo-ink); }
.btn.danger { background: transparent; border-color: var(--coral); color: #A8341D; }
.btn.ghost { background: transparent; color: var(--indigo); min-height: 40px; padding: 0 8px; }
.btn.small { min-height: 40px; font-size: 14px; padding: 0 12px; }

.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--ink); border-radius: 12px; cursor: pointer; text-decoration: none; }
.back { margin-left: -10px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--bg); color: var(--ink-2); }
.chip-btn { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 500; cursor: pointer; }
.chip-btn[aria-pressed="true"], .chip-btn[aria-checked="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

.badge { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge.coral { background: var(--coral-tint); color: var(--coral-ink); }
.badge.indigo { background: var(--indigo-tint); color: var(--indigo-ink); }
.badge.green { background: var(--green-tint); color: var(--green-ink); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; background: #E6E3EE; border-radius: 12px; padding: 4px; }
.seg button { min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(29, 26, 43, 0.08); }

.moods { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.mood { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 0 10px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; }
.mood b { font-family: var(--display); font-size: 22px; }
.mood span { font-size: 12px; font-weight: 500; }
.mood[aria-checked="true"] { background: var(--coral); border-color: var(--coral); color: #fff; }

.mood-tile { width: 56px; height: 56px; flex-shrink: 0; border-radius: 16px; background: var(--indigo-tint); color: var(--indigo); display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: var(--display); font-size: 22px; font-weight: 700; line-height: 1; }
.mood-tile small { font-family: var(--body); font-size: 11px; font-weight: 500; margin-top: 2px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field-label { font-size: 15px; font-weight: 600; }
.input, textarea.input, select.input {
  width: 100%; min-height: 48px; border-radius: 14px; border: 1px solid var(--field); background: var(--surface);
  padding: 12px 14px; font-size: 16px; line-height: 1.45; color: var(--ink);
}
textarea.input { resize: vertical; min-height: 96px; }
.hint { font-size: 13px; color: var(--muted); }
.error { font-size: 14px; color: #A8341D; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.switch-row + .switch-row { border-top: 1px solid var(--line); }
.switch { width: 52px; height: 32px; flex-shrink: 0; border-radius: 999px; border: 0; padding: 3px; display: flex; background: #B9B5C6; cursor: pointer; }
.switch::after { content: ""; width: 26px; height: 26px; border-radius: 50%; background: #fff; }
.switch[aria-checked="true"] { background: var(--coral); justify-content: flex-end; }
.switch.indigo[aria-checked="true"] { background: var(--indigo); }

.avatar { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; color: #fff; background: var(--coral); flex-shrink: 0; }
.avatar.b { background: var(--indigo); }
.avatar.sm { width: 28px; height: 28px; font-size: 13px; }
.avatar.xs { width: 24px; height: 24px; font-size: 12px; }
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }
.avatars { display: flex; }
.avatars .avatar { border: 2px solid var(--bg); }
.avatars .avatar + .avatar { margin-left: -10px; }

.alert { display: flex; align-items: center; gap: 8px; background: var(--coral-tint); color: var(--coral-ink); border-radius: 12px; padding: 10px 12px; font-size: 14px; font-weight: 600; }

.code-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.code-grid span { height: 44px; border-radius: 10px; background: var(--bg); display: flex; align-items: center; justify-content: center; font-family: var(--display); font-size: 22px; font-weight: 700; }

.locked { position: relative; overflow: hidden; }
.locked .bar { height: 12px; border-radius: 6px; background: #E9E6F0; }
.locked .veil { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 8px; background: rgba(255, 255, 255, 0.72); font-size: 14px; font-weight: 600; color: var(--ink-2); }

.bubbles { display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 84%; padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; }
.bubble .kind { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.bubble.me { align-self: flex-end; background: var(--coral-tint); border-radius: 16px 16px 4px 16px; }
.bubble.me .kind { color: var(--coral-ink); }
.bubble.other { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; }
.bubble.other .kind { color: var(--indigo-ink); }
.bubble p { font-size: 15px; line-height: 1.45; white-space: pre-wrap; }

.date-col { width: 44px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.date-col small { font-size: 11px; font-weight: 600; color: var(--coral); text-transform: uppercase; }
.date-col b { font-family: var(--display); font-size: 20px; }

.task { display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 48px; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--coral); margin: 0; flex-shrink: 0; }
.task.done .t { text-decoration: line-through; color: var(--muted); }

.photo-strip { display: flex; gap: 8px; overflow-x: auto; }
.photo-strip img { width: 96px; height: 96px; object-fit: cover; border-radius: 12px; flex-shrink: 0; background: var(--line); }

.empty { text-align: center; color: var(--muted); padding: 20px 8px; font-size: 15px; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 8px 8px calc(10px + env(safe-area-inset-bottom));
}
.nav-inner { max-width: 480px; margin: 0 auto; display: flex; justify-content: space-around; }
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 64px; min-height: 48px; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 500; }
.nav a[aria-current="page"] { color: var(--coral); font-weight: 600; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 40px); z-index: 20;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

dialog { border: 0; border-radius: 20px; padding: 20px; max-width: 420px; width: calc(100% - 40px); }
dialog::backdrop { background: rgba(29, 26, 43, 0.45); }
