/* Layout: one-screen phone app — header, scrolling screen, sheets that rise from the bottom, nav with a floating log button.
   Dark is the default look; Settings can switch to light. Fun mode adds motion and emoji. */
[hidden] { display: none !important; }
:root, :root[data-theme="dark"] {
  --bg: #160F1E;          /* page */
  --card: #231733;
  --card2: #2C1F3E;
  --line: #3A2B4F;
  --fg: #F5EDE0;          /* main text */
  --muted: #A493BC;
  --amber: #F2A03D;
  --amber-deep: #B8701C;
  --on-accent: #160F1E;   /* text on amber buttons */
  --coral: #E96A5C;
  --green: #7BC98F;
  --nav-bg: rgba(22, 15, 30, .96);
  --overlay: rgba(0, 0, 0, .6);
  --placeholder: #7d6f93;
  --display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --body: "Figtree", -apple-system, "Helvetica Neue", sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #FBF6EE;
  --card: #FFFFFF;
  --card2: #F3ECE1;
  --line: #E6DACB;
  --fg: #2A1F35;
  --muted: #76688A;
  --amber: #E08B24;
  --amber-deep: #A9620F;
  --on-accent: #1E1527;
  --coral: #CF4F3C;
  --green: #3E9A5A;
  --nav-bg: rgba(251, 246, 238, .96);
  --overlay: rgba(42, 31, 53, .45);
  --placeholder: #A497B4;
  color-scheme: light;
}
html, body { height: 100%; margin: 0; }
:root { padding-top: env(safe-area-inset-top, 0px); }
body {
  background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 15px;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
* { box-sizing: border-box; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
a { color: var(--amber); }
.app { height: 100%; display: flex; flex-direction: column; max-width: 480px; margin: 0 auto; position: relative; }
header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-block: 18px 10px;
  padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.header-actions { display: flex; align-items: center; gap: 8px; }
h1 { font-family: var(--display); font-weight: 800; font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h2 { font-family: var(--display); font-weight: 800; font-size: 22px; margin: 0; text-wrap: balance; }
.h3 { font-family: var(--display); font-weight: 700; font-size: 16px; margin: 0 0 12px; }
.ghost-btn { font-size: 12px; color: var(--muted); padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card2); }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); background: var(--card2); border: 1px solid var(--line); }
main {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-block: 4px 120px;
  padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.screen { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; min-width: 0; }
.card.alert { border-color: var(--coral); }
.card.warm { border-color: var(--amber); }
.label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.muted { color: var(--muted); font-size: 13px; margin: 0; line-height: 1.45; }
.small { font-size: 12px; }
.center { text-align: center; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.btn { flex: 1; padding: 11px 12px; border-radius: 12px; font-weight: 600; font-size: 14px; background: var(--card2); border: 1px solid var(--line); color: var(--fg); text-decoration: none; display: inline-block; }
.btn.primary { background: var(--amber); color: var(--on-accent); border-color: var(--amber); }
.btn.danger { color: var(--coral); border-color: var(--coral); background: transparent; }
.btn.ghostish { background: transparent; }
.btn:disabled { opacity: .45; cursor: default; }
.big { width: 100%; padding: 15px; font-size: 16px; flex: none; }
.link { color: var(--amber); font-weight: 600; text-decoration: underline; padding: 0; }
.accent-icon { color: var(--amber); }
.err { color: var(--coral); font-size: 13px; margin: 0; }
.hint { color: var(--amber); font-size: 13px; margin: 0; }

/* timer glass */
.timer { display: flex; flex-direction: column; align-items: center; padding-block: 6px; }
.glass { width: 150px; height: 170px; }
.glass-line { stroke: var(--muted); transition: stroke .5s; }
.glass.full .glass-line { stroke: var(--amber); }
.liquid { transition: transform 1s linear; }
.count { font-family: var(--display); font-weight: 800; font-size: 40px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.done-word { font-family: var(--display); font-weight: 800; font-size: 26px; color: var(--amber); margin-top: 2px; }
.ends { font-size: 13px; color: var(--muted); }
.empty-glass { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 4px; padding-block: 6px 10px; border-radius: 14px; text-align: center; }
.empty-glass .glass { width: 110px; height: 125px; }
.empty-glass:active { background: var(--card2); }
.empty-glass .glass-line { stroke: var(--muted); stroke-dasharray: 6 5; }
.empty-title { font-family: var(--display); font-size: 20px; font-weight: 700; }

/* roster */
.roster-head { display: flex; justify-content: space-between; align-items: baseline; }
.roster-head h3 { font-family: var(--display); font-size: 16px; font-weight: 700; margin: 0; }
.drink { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 11px 14px; }
.num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--card2); color: var(--amber); font-weight: 700; font-size: 12px; flex: none; font-variant-numeric: tabular-nums; }
.drink-main { flex: 1; min-width: 0; }
.drink-name { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.pill { font-size: 11px; font-weight: 600; padding: 4px 9px; border-radius: 999px; background: var(--card2); flex: none; white-space: nowrap; }
.muted-pill { color: var(--muted); }
.fast-pill { color: var(--coral); background: color-mix(in srgb, var(--coral) 15%, transparent); }
.steady-pill { color: var(--green); background: color-mix(in srgb, var(--green) 15%, transparent); }

/* nudge cards */
.nudge { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-color: var(--amber); font-weight: 600; }
.nudge .x { color: var(--muted); padding: 4px 8px; }

/* circle */
.friend { display: flex; align-items: flex-start; gap: 12px; }
.friend-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.friend-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--card2); color: var(--amber); font-family: var(--display); font-weight: 800; font-size: 18px; flex: none; }
.member.is-fast { border-color: color-mix(in srgb, var(--coral) 60%, var(--line)); }
.member-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--muted); }
.nudges { margin-top: 12px; }
.nudges .btn { padding: 9px 6px; font-size: 13px; }
.circle-head { display: flex; flex-direction: column; gap: 12px; }
.circle-title { display: flex; flex-direction: column; gap: 2px; }
.code-row { display: flex; align-items: baseline; justify-content: space-between; background: var(--card2); border-radius: 12px; padding: 10px 14px; }
.code { font-family: var(--display); font-size: 24px; letter-spacing: .18em; font-variant-numeric: tabular-nums; }
.circle-pick { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
.empty-circle { display: flex; flex-direction: column; gap: 12px; text-align: center; align-items: center; padding-block: 24px; }
.empty-circle .col { width: 100%; }
.circle-art { position: relative; width: 96px; height: 64px; }
.circle-art span { position: absolute; width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--amber); background: var(--card); }
.circle-art span:nth-child(1) { left: 0; top: 14px; }
.circle-art span:nth-child(2) { left: 26px; top: 0; border-color: var(--green); }
.circle-art span:nth-child(3) { left: 52px; top: 14px; border-color: var(--coral); }

/* stats */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { font-family: var(--display); font-weight: 800; font-size: 32px; margin: 2px 0; font-variant-numeric: tabular-nums; }
.insight { background: var(--card2); border-radius: 12px; padding: 12px; font-size: 14px; line-height: 1.5; }
.bar-row { display: grid; grid-template-columns: minmax(0, 120px) 1fr 28px; gap: 10px; align-items: center; font-size: 13px; margin-bottom: 8px; }
.track { background: var(--card2); border-radius: 6px; height: 10px; overflow: hidden; }
.fill { height: 100%; background: var(--amber); border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; }
.bar-row .num { background: none; width: auto; height: auto; color: var(--muted); text-align: right; display: block; }

/* nav */
nav {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-around;
  background: var(--nav-bg); border-top: 1px solid var(--line); backdrop-filter: blur(8px);
  padding-top: 8px; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 64px; font-size: 10.5px; color: var(--muted); padding: 4px 0; }
.tab[aria-current="page"] { color: var(--amber); }
.tab svg { width: 22px; height: 22px; }
.fab { width: 58px; height: 58px; border-radius: 50%; background: var(--amber); color: var(--on-accent); display: grid; place-items: center; margin-top: -26px; box-shadow: 0 8px 24px color-mix(in srgb, var(--amber) 35%, transparent); }
.fab svg { width: 28px; height: 28px; }

/* sheets */
.overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 30; display: flex; flex-direction: column; justify-content: flex-end; }
.sheet {
  background: var(--card); border-radius: 24px 24px 0 0; max-width: 480px; width: 100%; margin: 0 auto;
  max-height: 92%; overflow-y: auto;
  padding-block: 20px calc(26px + env(safe-area-inset-bottom, 0px));
  padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 16px;
  animation: rise .22s ease-out;
}
@keyframes rise { from { transform: translateY(30px); opacity: .6; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 9px 15px; border-radius: 999px; font-size: 14px; font-weight: 500; background: var(--card2); border: 1px solid var(--line); flex: none; }
.chip[aria-pressed="true"] { background: var(--amber); color: var(--on-accent); border-color: var(--amber); }
input[type=text], input[type=email], input[type=password], input:not([type]), input[inputmode] {
  width: 100%; padding: 13px 14px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line); color: var(--fg); font: inherit; font-size: 16px;
}
input::placeholder { color: var(--placeholder); }
.feel { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.feel button { padding: 10px 2px; border-radius: 12px; background: var(--card2); border: 2px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.feel b { font-family: var(--display); font-size: 17px; }
.feel span { font-size: 10px; color: var(--muted); }
.feel button[aria-pressed="true"] span { color: var(--fg); }
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.consent { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.45; }
.consent input { width: 20px; height: 20px; accent-color: var(--amber); flex: none; margin-top: 1px; }
.inline-form { display: flex; gap: 8px; }
.inline-form .btn { flex: none; }
.set { display: flex; flex-direction: column; gap: 10px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--card2); border-radius: 12px; padding: 4px; }
.seg button { padding: 9px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toggle input { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 999px; background: var(--line); position: relative; flex: none; transition: background .2s; cursor: pointer; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.toggle input:checked { background: var(--amber); }
.toggle input:checked::after { transform: translateX(20px); }
.wellness { display: flex; flex-direction: column; gap: 10px; text-align: center; align-items: center; }
.wellness p { margin: 0; line-height: 1.5; }
.well-emoji { font-size: 40px; }

/* sign in */
.auth { position: fixed; inset: 0; z-index: 55; background: var(--bg); overflow-y: auto;
  padding-block: max(24px, env(safe-area-inset-top, 0px)) calc(32px + env(safe-area-inset-bottom, 0px));
  padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); }
.auth-inner { max-width: 420px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.auth-brand { display: flex; align-items: center; gap: 12px; font-family: var(--display); font-weight: 800; font-size: 18px; }
.auth-brand img { border-radius: 14px; }
.auth h2 { font-size: 28px; }
.switch { text-align: center; font-size: 14px; color: var(--muted); margin: 4px 0 0; }

/* gate + toast */
.gate { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding-block: 32px; padding-left: max(32px, env(safe-area-inset-left, 0px)); padding-right: max(32px, env(safe-area-inset-right, 0px)); gap: 14px; }
.gate h2 { font-size: 40px; line-height: 1; letter-spacing: -0.02em; }
.gate .btn { flex: none; padding: 15px 34px; border-radius: 999px; font-size: 16px; margin-top: 12px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(100px + env(safe-area-inset-bottom, 0px)); z-index: 60; background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; max-width: 88%; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.banner { display: flex; gap: 12px; align-items: flex-start; }
.banner svg { flex: none; margin-top: 2px; }
.banner p { margin: 0; font-size: 13px; line-height: 1.45; }
.update { top: calc(12px + env(safe-area-inset-top, 0px)); bottom: auto; }

/* fun mode */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px; animation: drop 1.8s ease-in forwards; }
@keyframes drop { to { transform: translate(var(--drift), 105vh) rotate(540deg); opacity: .9; } }
[data-fun] .bub { animation: rise-bub 2.4s ease-in infinite; }
[data-fun] .bub.b2 { animation-delay: .8s; }
[data-fun] .bub.b3 { animation-delay: 1.6s; }
@keyframes rise-bub { from { transform: translateY(40px); opacity: 0; } 30% { opacity: .7; } to { transform: translateY(-10px); opacity: 0; } }
[data-fun] .fab { animation: wobble 4s ease-in-out infinite; }
@keyframes wobble { 0%, 90%, 100% { transform: rotate(0); } 93% { transform: rotate(-8deg); } 96% { transform: rotate(8deg); } }

@media (prefers-reduced-motion: reduce) {
  .liquid, .sheet, [data-fun] .bub, [data-fun] .fab { transition: none; animation: none; }
}
