:root {
  --cream: #F4E9D6;
  --card: #FBF6EC;
  --olive: #3E4630;
  --olive2: #4C5540;
  --terra: #B95826;
  --muted: #5A5F4A;
  --line: #E6D7BC;
  --line2: #CDBB9C;
  --serif: 'Lora', Georgia, serif;
  --sans: 'DM Sans', system-ui, -apple-system, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--cream); color: var(--olive); font-family: var(--sans); font-size: 16px; -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; }
a { color: var(--olive); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
h1, h2, h3 { margin: 0; }
h1 { font-family: var(--serif); font-weight: 600; font-size: 32px; line-height: 1.15; }
h1 em, h2 em { color: var(--terra); font-style: italic; }
h2.sec { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.serif { font-family: var(--serif); }
.xl { font-size: 24px; line-height: 1.25; font-weight: 500; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 12px; }
.eyebrow { font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; font-weight: 600; }
.row { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack-lg { display: flex; flex-direction: column; gap: 18px; }
.grow { flex: 1; min-width: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.splash { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--olive); }

/* screens */
.screen { max-width: 560px; margin: 0 auto; padding: calc(20px + var(--safe-t)) 20px calc(110px + var(--safe-b)); display: flex; flex-direction: column; gap: 18px; }
.screen.nonav { padding-bottom: calc(32px + var(--safe-b)); }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; }
.topbar img.logo { height: 40px; width: auto; }
.avatar { width: 44px; height: 44px; border-radius: 22px; background: var(--olive); color: var(--cream); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; text-decoration: none; flex-shrink: 0; }
.iconbtn { width: 44px; height: 44px; border-radius: 22px; border: 1.5px solid var(--olive); background: transparent; display: inline-flex; align-items: center; justify-content: center; color: var(--olive); text-decoration: none; flex-shrink: 0; }
.iconbtn.soft { border: 0; background: var(--card); }

/* cards */
.card { background: var(--card); border-radius: 20px; padding: 16px 18px; }
.card.olive { background: var(--olive); color: var(--cream); padding: 20px; }
.card.terra { background: var(--terra); color: #fff; padding: 18px 20px; }
.card.olive a, .card.terra a { color: inherit; }
.quote blockquote { margin: 6px 0 4px; font-family: var(--serif); font-style: italic; font-weight: 500; font-size: 21px; line-height: 1.35; }
.quote figcaption { font-size: 13px; font-weight: 500; }
.steps { list-style: none; margin: 12px 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 15px; }
.steps li { display: flex; gap: 10px; align-items: baseline; }
.steps .dot { width: 8px; height: 8px; border-radius: 4px; background: var(--cream); flex-shrink: 0; transform: translateY(-1px); }
.steps .dot.terra { background: var(--terra); }
.donemsg { display: flex; gap: 8px; align-items: center; font-weight: 700; }
.note-card { display: flex; gap: 12px; align-items: flex-start; }
.badge-s { flex-shrink: 0; width: 36px; height: 36px; border-radius: 18px; background: var(--terra); color: #fff; display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-weight: 600; }
.note-text { font-family: var(--serif); font-style: italic; font-size: 16px; line-height: 1.45; white-space: pre-line; }

/* buttons */
.btn { min-height: 50px; padding: 0 22px; border-radius: 25px; border: 2px solid var(--olive); background: var(--olive); color: var(--cream); font-weight: 700; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; width: 100%; }
.btn.cream { background: var(--cream); color: var(--olive); border-color: var(--cream); }
.btn.ghost { background: transparent; color: var(--olive); }
.btn.small { min-height: 44px; font-size: 14px; width: auto; padding: 0 16px; }
.btn.danger { background: transparent; color: #8E3A12; border-color: #8E3A12; }
.btn[disabled] { opacity: .55; cursor: default; }
.linkbtn { background: none; border: 0; padding: 10px 0; min-height: 44px; font-weight: 700; text-decoration: underline; color: inherit; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 16px; border-radius: 22px; border: 2px solid var(--line); background: var(--card); color: var(--olive); font-weight: 500; font-size: 15px; }
.chip[aria-pressed="true"] { background: var(--olive); color: var(--cream); border-color: var(--olive); }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grid5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.grid7 { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.feel { min-height: 72px; border-radius: 16px; border: 2px solid var(--line); background: var(--card); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 8px 4px; }
.feel b { font-family: var(--serif); font-size: 18px; font-weight: 600; }
.feel span { font-size: 12px; }
.feel[aria-pressed="true"] { background: var(--olive); color: var(--cream); border-color: var(--olive); }
.energy { min-height: 48px; border-radius: 24px; border: 2px solid var(--line); background: var(--card); font-weight: 700; font-size: 17px; }
.energy[aria-pressed="true"] { background: var(--terra); color: #fff; border-color: var(--terra); }
.lang { display: flex; background: var(--line); border-radius: 22px; padding: 3px; gap: 2px; }
.lang button { min-width: 44px; min-height: 38px; border: 0; border-radius: 19px; background: transparent; font-weight: 700; font-size: 13px; }
.lang button[aria-pressed="true"] { background: var(--olive); color: var(--cream); }
.onolive .lang { background: var(--olive2); }
.onolive .lang button { color: var(--cream); }
.onolive .lang button[aria-pressed="true"] { background: var(--cream); color: var(--olive); }

/* week strip */
.wd { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.wd span { font-size: 12px; font-weight: 500; color: var(--muted); }
.wd i { width: 30px; height: 30px; border-radius: 15px; background: var(--line); display: block; }
.wd i.done { background: var(--olive); }
.wd i.planned { background: transparent; border: 2px dashed var(--muted); }
.wd i.today { border: 2px solid var(--terra); background: var(--card); }
.wd i.today.done { background: var(--olive); }
.progress { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
.progress > div { height: 10px; border-radius: 5px; background: var(--terra); }

/* plan list */
.dayrow { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 8px; border-radius: 16px; background: var(--card); border: 2px solid transparent; }
.dayrow.today { border-color: var(--terra); }
.dayrow.empty { opacity: .7; }
.daydate { width: 44px; display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.daydate span { font-size: 12px; font-weight: 500; color: var(--muted); }
.daydate b { font-family: var(--serif); font-size: 20px; }
.kind { font-size: 12px; letter-spacing: 1px; text-transform: uppercase; font-weight: 700; color: #9A4519; }
.check { width: 44px; height: 44px; border-radius: 22px; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.check i { width: 28px; height: 28px; border-radius: 14px; border: 2px solid var(--muted); display: flex; align-items: center; justify-content: center; }
.check[aria-pressed="true"] i { background: var(--olive); border-color: var(--olive); }

/* forms */
label.f { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 700; }
input.t, select.t, textarea.t { width: 100%; min-height: 48px; border-radius: 14px; border: 1.5px solid var(--line2); background: var(--card); padding: 10px 14px; font-size: 16px; font-weight: 400; color: var(--olive); }
textarea.t { min-height: 80px; resize: vertical; line-height: 1.4; }
.onolive input.t { background: var(--cream); border-color: var(--cream); }
.codeinput { letter-spacing: 6px; font-size: 22px !important; text-align: center; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 10px; font-family: var(--serif); font-size: 19px; font-weight: 600; }

/* lessons */
.lesson { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 16px; background: var(--card); text-decoration: none; color: var(--olive); }
.lesson .ic { width: 48px; height: 48px; border-radius: 12px; background: var(--olive); color: var(--cream); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.lesson b { font-size: 16px; line-height: 1.3; }
.body p { font-size: 17px; line-height: 1.6; margin: 0 0 14px; }

/* group */
.datebox { width: 58px; height: 62px; border-radius: 14px; background: var(--cream); color: var(--olive); display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; }
.datebox span { font-size: 12px; font-weight: 700; color: #9A4519; text-transform: uppercase; }
.datebox b { font-family: var(--serif); font-size: 24px; line-height: 1; }
.slots { display: grid; gap: 4px; }
.slots i { height: 10px; border-radius: 5px; background: var(--line); display: block; }
.slots i.on { background: var(--terra); }
.post { display: flex; flex-direction: column; gap: 10px; }
.post p { margin: 0; font-size: 15px; line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; }
.mini { width: 36px; height: 36px; border-radius: 18px; background: var(--olive); color: var(--cream); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.pillbtn { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1.5px solid var(--line2); background: transparent; font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.pillbtn[aria-pressed="true"] { background: var(--terra); color: #fff; border-color: var(--terra); }

/* coach */
.coachhead { background: var(--olive); color: var(--cream); margin: calc(-20px - var(--safe-t)) -20px 0; padding: calc(24px + var(--safe-t)) 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.coachhead a { color: var(--cream); }
.tile { background: var(--olive2); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.tile b { font-family: var(--serif); font-size: 28px; font-weight: 600; }
.tile span { font-size: 13px; line-height: 1.3; }
.tile.warn { background: var(--terra); color: #fff; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--line); padding: 4px; border-radius: 24px; }
.seg button { min-height: 44px; border-radius: 22px; border: 0; background: transparent; font-size: 14px; font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--olive); color: var(--cream); font-weight: 700; }
.tabs4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; background: var(--line); padding: 4px; border-radius: 24px; }
.tabs4 a { min-height: 44px; border-radius: 20px; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 13px; font-weight: 500; text-decoration: none; padding: 0 4px; }
.tabs4 a[aria-current="page"] { background: var(--olive); color: var(--cream); font-weight: 700; }
.status { flex-shrink: 0; font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 12px; background: var(--olive); color: var(--cream); }
.status.warn { background: var(--terra); color: #fff; }
.status.quiet { background: var(--line); color: var(--olive); }
.dayedit { display: grid; grid-template-columns: 88px 1fr; gap: 8px; align-items: start; padding: 12px; background: var(--card); border-radius: 16px; }
.dayedit .when { font-weight: 700; font-size: 14px; padding-top: 12px; }
.dayedit .when span { display: block; font-weight: 500; color: var(--muted); font-size: 13px; }
.listitem { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; padding: 12px 14px; background: var(--card); border-radius: 14px; }
hr.soft { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }

/* tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); display: grid; padding-bottom: var(--safe-b); z-index: 10; }
.tabbar { max-width: 560px; margin: 0 auto; }
@media (min-width: 561px) { .tabbar { border-left: 1px solid var(--line); border-right: 1px solid var(--line); border-radius: 18px 18px 0 0; } }
.tab { min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 500; border-top: 3px solid transparent; }
.tab.on { color: var(--olive); font-weight: 700; border-top-color: var(--terra); }

/* login / full olive screens */
.olivepage { min-height: 100vh; background: var(--olive); color: var(--cream); }
.olivepage .screen { padding-top: calc(28px + var(--safe-t)); }
.olivepage a, .olivepage .linkbtn { color: var(--cream); }
.olivepage .msg { font-size: 16px; line-height: 1.5; }
.err { background: #F7D9C8; color: #6E2A0A; padding: 12px 14px; border-radius: 12px; font-size: 15px; font-weight: 500; }

.toast { position: fixed; left: 50%; top: calc(16px + var(--safe-t)); transform: translateX(-50%); background: var(--olive); color: var(--cream); padding: 12px 18px; border-radius: 14px; font-weight: 700; font-size: 15px; z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.18); max-width: calc(100% - 32px); }
.spinner { padding: 40px 0; text-align: center; color: var(--muted); }
:focus-visible { outline: 3px solid var(--terra); outline-offset: 2px; }
