/* Cherga — iOS-style decision queue + inbox (Fizzy 1488).
   Source of truth for layout: ~/Work/design/cherga/v2-*.png (macet v2, approved 13.11). */

/* Fixel (MacPaw, SIL OFL 1.1, web/fonts/OFL-Fixel.txt): Text for reading sizes, Display for large titles.
   Shipped with the app so a screenshot and the phone show the same letters (v3, 13.11). */
@font-face { font-family: "Fixel Text"; src: url(fonts/FixelText-Regular.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Fixel Text"; src: url(fonts/FixelText-Medium.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Fixel Text"; src: url(fonts/FixelText-SemiBold.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Fixel Text"; src: url(fonts/FixelText-Bold.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Fixel Display"; src: url(fonts/FixelDisplay-Bold.woff2) format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bg: #fff;
  --bg-2: #f2f2f7;            /* systemGroupedBackground */
  --fill: rgba(118,118,128,.12);
  --label: #000;
  --label-2: rgba(60,60,67,.6);
  --label-3: rgba(60,60,67,.3);
  --sep: rgba(60,60,67,.29);
  --blue: #007aff;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --yellow: #ffcc00;
  --purple: #af52de;
  --omar: #2a9d8f;
  --kas: #c97a2b;
  --rin: #8e6cc9;
  --sheet: #fff;
  --dim: rgba(0,0,0,.25);
  --font: "Fixel Text", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-display: "Fixel Display", var(--font);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --bg-2: #1c1c1e;
    --fill: rgba(118,118,128,.24);
    --label: #fff;
    --label-2: rgba(235,235,245,.6);
    --label-3: rgba(235,235,245,.3);
    --sep: rgba(84,84,88,.65);
    --blue: #0a84ff;
    --green: #30d158;
    --red: #ff453a;
    --orange: #ff9f0a;
    --yellow: #ffd60a;
    --purple: #bf5af2;
    --sheet: #1c1c1e;
    --dim: rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--label);
  font: 20px/1.3 var(--font); letter-spacing: -.005em;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none; user-select: none; -webkit-user-select: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; letter-spacing: inherit; }
input { font: inherit; letter-spacing: inherit; }
a { color: var(--blue); text-decoration: none; }

.large, .sheet h2, .tile b, .login h1, .empty b, .receipt { font-family: var(--font-display); }

/* ---------- screens (iOS push navigation) ---------- */
#app { position: fixed; inset: 0; overflow: hidden; }
.screen {
  position: absolute; inset: 0; background: var(--bg);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-top) + 8px) 0 calc(var(--safe-bottom) + 110px);
  transition: transform .35s cubic-bezier(.2,.8,.2,1), opacity .35s;
  will-change: transform;
}
.screen.enter { transform: translateX(100%); }
.screen.under { transform: translateX(-30%); opacity: .6; }
.screen.leave { transform: translateX(100%); }

/* nav bar: back + more; small title fades in when large title scrolls away */
.nav {
  position: sticky; top: calc(-1 * var(--safe-top) - 8px); z-index: 3;
  display: flex; align-items: center; justify-content: space-between;
  height: 44px; padding: 0 8px; margin-top: calc(-1 * var(--safe-top) - 8px);
  padding-top: var(--safe-top); box-sizing: content-box;
  background: transparent; transition: background .2s, border-color .2s;
  border-bottom: .5px solid transparent;
}
.nav.solid { background: color-mix(in srgb, var(--bg) 82%, transparent); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-bottom-color: var(--sep); }
.nav .back { display: flex; align-items: center; gap: 2px; color: var(--blue); height: 44px; padding: 0 8px 0 0; }
.nav .back svg { width: 13px; height: 21px; margin: 0 4px 0 2px; }
.nav .mini { position: absolute; left: 50%; transform: translateX(-50%); font-weight: 600; opacity: 0; transition: opacity .2s; white-space: nowrap; pointer-events: none; }
.nav.solid .mini { opacity: 1; }
.nav .more { color: var(--blue); width: 44px; height: 44px; display: grid; place-items: center; }

.large { display: flex; align-items: center; gap: 12px; padding: 4px 20px 2px; font-size: 36px; line-height: 43px; font-weight: 700; letter-spacing: -.01em; }
.large svg { width: 30px; height: 30px; flex: none; }
.lead { color: var(--label-2); font-size: 17px; line-height: 23px; padding: 2px 20px 6px; }

/* ---------- home: lists ---------- */
.search { margin: 6px 16px 14px; display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 8px; border-radius: 10px; background: var(--fill); color: var(--label-2); }
.search svg { width: 16px; height: 16px; flex: none; }
.search input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--label); font-size: 20px; user-select: text; -webkit-user-select: text; }
.search input::placeholder { color: var(--label-2); }
.group { margin: 0 0 22px; }
.lrow { display: flex; align-items: center; gap: 16px; min-height: 44px; padding: 0 20px; font-weight: 600; width: 100%; text-align: left; }
.lrow:active { background: var(--fill); }
.lrow .ic { width: 26px; height: 26px; display: grid; place-items: center; flex: none; }
.lrow .ic svg { width: 26px; height: 26px; }
.lrow .t { flex: 1; }
.lrow .n { color: var(--label-2); font-weight: 400; font-variant-numeric: tabular-nums; }
.lrow.person { font-weight: 400; }
.badge { min-width: 24px; height: 24px; padding: 0 7px; border-radius: 12px; background: var(--red); color: #fff; font-size: 17px; font-weight: 600; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.avatar { width: 26px; height: 26px; border-radius: 50%; color: #fff; font-size: 14px; font-weight: 700; display: grid; place-items: center; }

/* ---------- sections + item rows ---------- */
.section { color: var(--blue); font-weight: 700; font-size: 20px; padding: 18px 20px 6px; margin: 0 20px; padding-left: 0; padding-right: 0; border-bottom: .5px solid var(--sep); }
.list { position: relative; }
.item { position: relative; overflow: hidden; transition: height .3s ease, opacity .3s; }
.item .face {
  position: relative; z-index: 1; display: flex; gap: 14px; align-items: flex-start;
  padding: 12px 20px; background: var(--bg); touch-action: pan-y;
}
.item .face:active { background: var(--fill); }
.item .mark { flex: none; width: 26px; height: 26px; margin-top: 1px; display: grid; place-items: center; }
.item .q { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--orange); color: var(--orange); font-weight: 700; font-size: 17px; display: grid; place-items: center; }
.item .box { width: 24px; height: 24px; border-radius: 6px; border: 1.5px solid var(--label-3); display: grid; place-items: center; transition: background .15s, border-color .15s; }
.item .box svg { width: 15px; height: 15px; opacity: 0; transform: scale(.4); transition: all .2s; }
.item.done .box { background: var(--blue); border-color: var(--blue); }
.item.done .box svg { opacity: 1; transform: none; }
.item.done .title { color: var(--label-2); }
.item .body { flex: 1; min-width: 0; }
.item .title { font-size: 20px; line-height: 26px; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 5px; color: var(--label-2); font-size: 17px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 7px; background: var(--fill); color: var(--label-2); font-weight: 600; font-size: 17px; }
.chip i { width: 7px; height: 7px; border-radius: 50%; display: block; }

/* swipe backgrounds */
.item .act { position: absolute; top: 0; bottom: 0; display: flex; z-index: 0; }
.item .act.left { left: 0; right: 0; background: var(--green); justify-content: flex-start; }
.item .act.right { left: 0; right: 0; justify-content: flex-end; background: var(--orange); }
.item .act button { color: #fff; font-size: 17px; font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 88px; padding: 0 12px; }
.item .act button svg { width: 24px; height: 24px; }
.item .act .no { background: var(--red); }
.item .act .later { background: var(--orange); }

.empty { color: var(--label-2); text-align: center; padding: 60px 40px; font-size: 17px; line-height: 23px; }
.empty b { display: block; color: var(--label); font-size: 22px; margin-bottom: 6px; }

/* inbox rows */
.note { display: flex; gap: 14px; padding: 12px 20px; }
.note .wave { flex: none; width: 26px; height: 26px; margin-top: 1px; color: var(--label-2); }
.note.fresh .wave { color: var(--blue); }
.note .st { margin-top: 6px; display: flex; align-items: center; gap: 6px; font-size: 17px; color: var(--label-2); }
.note .st.busy { color: var(--blue); font-weight: 600; }
.note .st svg { width: 18px; height: 18px; flex: none; }
.note.priv .title { color: var(--label-2); }

/* answered */
.ans { font-weight: 600; }
.ans.yes { color: var(--green); } .ans.no { color: var(--red); } .ans.later { color: var(--orange); } .ans.done { color: var(--blue); }

/* week */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px 16px; }
.tile { background: var(--bg-2); border-radius: 14px; padding: 14px; }
.tile b { display: block; font-size: 36px; line-height: 42px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile span { color: var(--label-2); font-size: 17px; line-height: 22px; }
.foot { color: var(--label-2); font-size: 15px; padding: 8px 20px; line-height: 21px; }

/* ---------- mic FAB ---------- */
.fab {
  position: fixed; right: 20px; bottom: calc(var(--safe-bottom) + 24px); z-index: 20;
  width: 60px; height: 60px; border-radius: 50%; background: var(--blue); color: #fff;
  display: grid; place-items: center; box-shadow: 0 6px 18px rgba(0,122,255,.35);
  transition: transform .15s, background .2s; touch-action: none;
}
.fab svg { width: 26px; height: 26px; }
.fab:active, .fab.rec { transform: scale(1.08); }
.fab.rec { background: var(--red); box-shadow: 0 0 0 10px color-mix(in srgb, var(--red) 25%, transparent); }

/* ---------- bottom sheet ---------- */
.dim { position: fixed; inset: 0; z-index: 30; background: var(--dim); opacity: 0; transition: opacity .3s; }
.dim.on { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  max-height: calc(100% - var(--safe-top) - 40px); overflow-y: auto;
  background: var(--sheet); border-radius: 14px 14px 0 0;
  padding: 0 20px calc(var(--safe-bottom) + 16px);
  transform: translateY(100%); transition: transform .35s cubic-bezier(.2,.8,.2,1);
  user-select: text; -webkit-user-select: text;
}
.sheet.on { transform: none; }
.sheet .grab { width: 36px; height: 5px; border-radius: 3px; background: var(--label-3); margin: 6px auto 14px; }
.sheet h2 { font-size: 30px; line-height: 36px; font-weight: 700; margin: 12px 0 14px; }
.sheet .cap { color: var(--label-2); font-size: 15px; font-weight: 600; text-transform: uppercase; margin: 16px 0 6px; }
.sheet p { margin: 0; font-size: 20px; line-height: 27px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 9px; font-weight: 600; margin-bottom: 8px; }
.pill.yes { background: color-mix(in srgb, var(--green) 15%, transparent); color: color-mix(in srgb, var(--green) 75%, var(--label)); }
.pill.no { background: color-mix(in srgb, var(--red) 13%, transparent); color: var(--red); }
.pill svg { width: 16px; height: 16px; }
.sheet .more-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 18px; font-size: 20px; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 28px; }
.btn { height: 52px; border-radius: 14px; font-weight: 600; font-size: 20px; display: grid; place-items: center; }
.btn.gray { background: var(--fill); color: var(--red); }
.btn.gray.blue { color: var(--blue); }
.btn.green { background: var(--green); color: #fff; }
.btn.primary { background: var(--blue); color: #fff; }
.btn:active { opacity: .7; }
.voice-link { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 14px auto 0; color: var(--blue); font-size: 20px; }
.voice-link svg { width: 18px; height: 18px; }

.receipt { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 700; margin-top: 4px; }
.receipt svg { width: 24px; height: 24px; color: var(--green); }
.receipt span { color: var(--label-2); font-weight: 400; }
.quote { background: var(--fill); border-radius: 12px; padding: 12px 14px; margin-top: 14px; font-size: 20px; line-height: 27px; }
.quote.wait { color: var(--label-2); }
.und { display: flex; gap: 14px; align-items: flex-start; padding: 8px 0; }
.und svg { width: 24px; height: 24px; flex: none; margin-top: 1px; }
.und small { display: block; color: var(--label-2); font-size: 17px; margin-top: 2px; }

/* recording sheet */
.rec-ui { text-align: center; padding: 6px 0 4px; }
.rec-ui .time { font-size: 44px; font-weight: 300; font-variant-numeric: tabular-nums; margin: 4px 0 10px; }
.rec-ui .bars { display: flex; justify-content: center; align-items: center; gap: 3px; height: 48px; }
.rec-ui .bars i { width: 4px; border-radius: 2px; background: var(--red); height: 4px; transition: height .08s; }
.rec-ui .hint { color: var(--label-2); font-size: 17px; margin-top: 10px; }
.stop { width: 68px; height: 68px; border-radius: 50%; border: 4px solid var(--label-3); display: grid; place-items: center; margin: 18px auto 0; }
.stop i { width: 26px; height: 26px; border-radius: 6px; background: var(--red); display: block; }

/* toast with undo (Things-style) */
.toast {
  position: fixed; left: 16px; right: 92px; bottom: calc(var(--safe-bottom) + 30px); z-index: 25;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: color-mix(in srgb, var(--label) 88%, transparent); color: var(--bg);
  border-radius: 14px; padding: 12px 16px; font-size: 17px; line-height: 23px;
  transform: translateY(calc(100% + 60px)); visibility: hidden; transition: transform .3s cubic-bezier(.2,.8,.2,1), visibility 0s .3s;
}
.toast.on { transform: none; visibility: visible; transition: transform .3s cubic-bezier(.2,.8,.2,1); }
.toast button { color: var(--blue); font-weight: 600; filter: brightness(1.4); }

/* pull to refresh */
.ptr { height: 0; overflow: hidden; display: grid; place-items: center; color: var(--label-2); transition: height .2s; }
.ptr svg { width: 22px; height: 22px; }
.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* login */
.login { padding: calc(var(--safe-top) + 80px) 28px 40px; text-align: center; }
.login .logo { width: 84px; height: 84px; border-radius: 20px; margin: 0 auto 18px; display: block; }
.login h1 { font-size: 30px; margin: 0 0 8px; }
.login p { color: var(--label-2); font-size: 17px; line-height: 23px; margin: 0 0 26px; }
.login input { width: 100%; height: 52px; border-radius: 12px; border: 0; background: var(--fill); color: var(--label); text-align: center; font-size: 30px; outline: 0; user-select: text; -webkit-user-select: text; }
.login .btn { width: 100%; margin-top: 14px; }
.login .err { color: var(--red); font-size: 17px; margin-top: 12px; min-height: 20px; }

@media (min-width: 700px) {
  #app { max-width: 430px; margin: 0 auto; left: 0; right: 0; box-shadow: 0 0 0 .5px var(--sep); }
  .fab { right: calc(50% - 215px + 20px); }
  .toast { left: calc(50% - 215px + 16px); right: calc(50% - 215px + 92px); }
  .sheet { max-width: 430px; margin: 0 auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
