@font-face {
  font-family: "Bricolage";
  src: url(fonts/bricolage.woff2) format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --paper: #EEF1F7;
  --card: #FFFFFF;
  --ink: #1C2340;
  --muted: #5F6782;
  --line: #D5DAE6;
  --a: #E39B2D;
  --a-soft: #FBEBD2;
  --b: #2F7D6D;
  --b-soft: #D6EBE5;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.45 "Bricolage", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; border-radius: 6px; }

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px calc(110px + env(safe-area-inset-bottom));
}
h2 { font-size: 1.15rem; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
section { margin-top: 28px; }
.head { display: flex; justify-content: space-between; align-items: baseline; }
.text-btn { background: none; border: 0; padding: 6px 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }

/* ---- The pair: two overlapping progress rings ---- */
.pair { text-align: center; padding-top: 8px; }
.rings svg { width: 100%; max-width: 300px; display: block; margin: 0 auto; overflow: visible; }
.track { fill: none; stroke: var(--line); stroke-width: 10; }
.arc {
  fill: none; stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 0 100;
  transform: rotate(-90deg); transform-box: fill-box; transform-origin: center;
  transition: stroke-dasharray .6s cubic-bezier(.3,.7,.2,1);
  mix-blend-mode: multiply;
}
.arc.a { stroke: var(--a); }
.arc.b { stroke: var(--b); }
.names { display: flex; justify-content: center; gap: 12px; margin-top: 10px; }
.name {
  background: none; border: 0; padding: 4px 10px;
  display: flex; flex-direction: column; align-items: center;
  font-size: 1.6rem; font-weight: 750; line-height: 1.1; letter-spacing: -0.02em;
  min-width: 0; max-width: 50%;
}
.name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.name.a span { color: #B3740F; }
.name.b span { color: var(--b); }
.name small { font-size: .85rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.today { color: var(--muted); margin: 6px 0 0; font-size: .95rem; }

/* ---- Habit rows: one check column per partner ---- */
.cols, .habit { display: grid; grid-template-columns: 1fr 52px 52px; align-items: center; gap: 6px; }
.cols { margin-top: 12px; padding: 0 12px; font-size: .8rem; font-weight: 600; color: var(--muted); }
.cols span { text-align: center; font-size: .9rem; font-weight: 700; }
#colA { color: #B3740F; }
#colB { color: var(--b); }
#habits { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 8px; }
.habit { background: var(--card); border-radius: 16px; padding: 10px 12px; min-height: 64px; }
.habit .what { display: flex; align-items: center; gap: 10px; min-width: 0; }
.habit .emoji { font-size: 1.5rem; width: 1.8rem; text-align: center; flex: none; }
.habit .label { min-width: 0; }
.habit .title { font-weight: 600; overflow-wrap: anywhere; }
.timer-btn {
  display: inline-block; margin-top: 2px; padding: 2px 10px;
  border: 1.5px solid var(--line); border-radius: 99px; background: none;
  font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums;
}
.timer-btn.running { border-color: var(--ink); color: var(--ink); font-weight: 600; }
.del { background: none; border: 0; color: #B3261E; font-size: .85rem; padding: 2px 0; text-decoration: underline; }

.check {
  width: 44px; height: 44px; margin: 0 auto; border-radius: 50%;
  border: 2.5px solid var(--line); background: none;
  display: grid; place-items: center; padding: 0;
}
.check svg { width: 22px; height: 22px; stroke: #fff; stroke-width: 3.5; fill: none; opacity: 0; }
.check.on svg { opacity: 1; }
.check.a.on { background: var(--a); border-color: var(--a); }
.check.b.on { background: var(--b); border-color: var(--b); }
.check.on { animation: pop .28s ease-out; }
.check:disabled { cursor: default; border-style: dashed; }
.check.on:disabled { border-style: solid; }
@keyframes pop { 50% { transform: scale(1.15); } }

#addHabit { display: grid; grid-template-columns: 52px 1fr 64px auto; gap: 6px; margin-top: 10px; }
#addHabit[hidden] { display: none; }
#addHabit input { min-width: 0; padding: 10px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--card); }
#addHabit input[name=emoji] { text-align: center; }
#addHabit button { border: 0; border-radius: 12px; background: var(--ink); color: #fff; padding: 0 14px; font-weight: 600; }

/* ---- Fasting ---- */
.fasts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.fast { border-radius: 16px; padding: 14px; min-width: 0; }
.fast.a { background: var(--a-soft); }
.fast.b { background: var(--b-soft); }
.fast .who { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fast .clock { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; margin: 2px 0; }
.fast .sub { font-size: .8rem; color: var(--muted); min-height: 1.2em; }
.fast .bar { height: 6px; border-radius: 3px; background: rgba(28,35,64,.1); margin: 8px 0 10px; overflow: hidden; }
.fast .bar i { display: block; height: 100%; width: 0; }
.fast.a .bar i { background: var(--a); }
.fast.b .bar i { background: var(--b); }
.fast button { width: 100%; border: 0; border-radius: 10px; padding: 9px; background: var(--ink); color: #fff; font-weight: 600; font-size: .9rem; }

.switch { text-align: center; margin-top: 28px; }

/* ---- Nudge dock ---- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--paper) 35%);
}
.nudge {
  display: block; width: 100%; max-width: 448px; margin: 0 auto;
  border: 0; border-radius: 99px; padding: 16px;
  font-weight: 700; font-size: 1.05rem; color: #fff; background: var(--ink);
}
.nudge:active { transform: scale(.98); }

#toast {
  position: fixed; left: 16px; right: 16px; top: calc(12px + env(safe-area-inset-top));
  max-width: 448px; margin: 0 auto; padding: 14px 16px; border-radius: 14px;
  background: var(--ink); color: #fff; font-weight: 500;
  transform: translateY(-150%); transition: transform .3s ease;
}
#toast.show { transform: none; }

/* ---- Who dialog ---- */
dialog { border: 0; border-radius: 20px; padding: 24px; width: min(92vw, 380px); color: var(--ink); }
dialog::backdrop { background: rgba(28,35,64,.45); }
dialog p { color: var(--muted); margin: 6px 0 16px; }
.who-options { display: grid; gap: 10px; }
.pick { border: 0; border-radius: 14px; padding: 16px; font-weight: 700; font-size: 1.2rem; color: #fff; }
.pick.a { background: var(--a); color: var(--ink); }
.pick.b { background: var(--b); }

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