/* Butterfly. Light theme only; dark is not designed yet (PRD Decision #23).
   Tokens are from the Design Spec "Global look". */
:root {
  --bg: #F3F5F7;
  --card: #FFFFFF;
  --ink: #1F2A37;
  --ink-soft: #3D4855;
  --muted: #5B6675;
  --line: #E3E7EC;
  --field: #D5DBE2;
  --teal: #2F6F73;
  --teal-hover: #235457;
  --teal-tint: #DCEDEE;
  --lilac: #4B3D86;
  --lilac-tint: #EDE9F7;
  --lilac-page: #F5F3FA;
  --danger: #9B2C1F;
  --danger-line: #E6C3BE;
  --font: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 15px/1.45 var(--font);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
}
h1 { font-size: 26px; font-weight: 700; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 700; margin: 0 0 10px; }
p { margin: 0 0 10px; }
a { color: var(--teal); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.screen { padding: 22px 16px 16px; max-width: 560px; margin: 0 auto; }
.screen.narrow { padding-top: 48px; }
.lilac-page { background: var(--lilac-page); min-height: 100vh; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row > label, .row > div { flex: 1; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.head-actions { display: flex; gap: 8px; align-items: center; }

label { display: block; font-weight: 600; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; color: var(--ink); }
input[type="text"], input[type="email"], input[type="password"], input[type="time"], input[type="tel"], input[type="text"], textarea, input[inputmode] {
  width: 100%; font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--field); border-radius: 12px; padding: 12px 14px; min-height: 46px;
}
textarea { resize: vertical; }
input:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

button { font: inherit; cursor: pointer; }
.pill {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px;
  border-radius: 999px; border: 1px solid var(--field); background: var(--card); color: var(--ink);
  font-weight: 600; text-decoration: none;
}
.pill.teal { background: var(--teal); border-color: var(--teal); color: #fff; }
.pill.teal:hover { background: var(--teal-hover); }
.pill.lilac { background: var(--lilac); border-color: var(--lilac); color: #fff; }
.pill.lilac-tint { background: var(--lilac-tint); border-color: transparent; color: var(--lilac); }
.pill.white { background: #fff; border-color: #fff; color: var(--teal); }
.pill.wide { width: 100%; }
.pill:disabled { opacity: .45; }
.link { background: none; border: 0; padding: 8px 0; color: var(--teal); font-weight: 600; }
.link.light { color: #fff; opacity: .9; text-decoration: underline; }
.link.danger { color: var(--danger); }
.icon-btn {
  width: 44px; height: 44px; border-radius: 999px; background: var(--card); border: 1px solid var(--field);
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink);
}
.back { display: inline-block; margin-bottom: 8px; font-weight: 600; text-decoration: none; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin-bottom: 12px; }
.hero { background: var(--teal); color: #fff; border-radius: 22px; padding: 20px; margin-bottom: 14px; }
.hero-title { font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.hero-sub { margin: 0 0 12px; opacity: .92; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.teal-card { background: var(--teal); color: #fff; }

.capture { display: block; text-align: center; background: var(--lilac); color: #fff; border-radius: 16px; padding: 16px; font-weight: 700; text-decoration: none; }

/* Mood swatches */
.mood-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.swatch { aspect-ratio: 1; border-radius: 999px; border: 0; background: var(--c); min-height: 40px; }
.swatch.on { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--ink); }
.scale-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Choice pills and segments */
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill-choice, .seg, .chip-btn {
  min-height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--field);
  background: var(--card); color: var(--ink); font-weight: 600;
}
.pill-choice.on, .seg.on, .chip-btn.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.segs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
.seg { padding: 0 6px; font-size: 13px; }
.chip-btn { min-height: 36px; font-size: 13px; padding: 0 12px; }
.chip { display: inline-block; font-size: 12px; background: #EEF1F4; color: var(--muted); border-radius: 10px; padding: 2px 8px; }
.sticky { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom, 0px)); background: var(--bg); padding: 10px 0; }

/* Thoughts */
.capture-row { display: flex; gap: 8px; margin-bottom: 12px; }
.capture-row input { flex: 1; }
.add-btn { width: 48px; height: 48px; border-radius: 14px; border: 0; background: var(--lilac); color: #fff; font-size: 24px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.filter { min-height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--field); background: var(--card); font-weight: 600; font-size: 13px; }
.filter.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.cards .thought { padding: 0; overflow: hidden; }
.card-open { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 16px; color: inherit; }
.thought-text { display: block; font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.faded .thought-text { color: var(--ink-soft); font-weight: 500; }
.meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--muted); }
.card-actions { border-top: 1px solid var(--line); padding: 12px 16px 16px; }
.card-actions p { margin: 10px 0 6px; }
.weight { letter-spacing: 1px; }

/* Lists and misc */
.row-link { display: flex; justify-content: space-between; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin: 12px 0; text-decoration: none; color: var(--ink); font-weight: 600; }
.plan-text { white-space: pre-wrap; }

/* Locked cupboard */
.pin-dots { display: flex; gap: 14px; justify-content: center; margin: 24px 0 8px; }
.dot { width: 14px; height: 14px; border-radius: 999px; border: 2px solid var(--lilac); }
.dot.on { background: var(--lilac); }
.pin-dots.shake { animation: shake .4s; }
@keyframes shake { 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 300px; margin: 16px auto 0; }
.key { min-height: 64px; border-radius: 999px; border: 1px solid var(--field); background: var(--card); font-size: 24px; font-weight: 600; color: var(--ink); }
.key:disabled { opacity: .4; }
.secret { font: 22px ui-monospace, Menlo, monospace; background: #fff; border-radius: 14px; padding: 16px; word-break: break-word; }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding: 8px 0 calc(26px + env(safe-area-inset-bottom, 0px));
}
.tabbar a { flex: 1; text-align: center; min-height: 44px; line-height: 44px; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 500; }
.tabbar a.on { color: var(--teal); font-weight: 700; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  max-width: 520px; margin: 0 auto; background: var(--ink); color: #fff; border-radius: 14px;
  padding: 12px 16px; display: flex; justify-content: space-between; gap: 12px; align-items: center;
}
.toast-undo { background: none; border: 0; color: #fff; font-weight: 700; text-decoration: underline; min-height: 44px; }
[hidden] { display: none !important; }
