/* QuAc — styles. No framework, no webfonts. */

:root {
  --bg: #f3f2ee;
  --card: #fbfaf7;
  --sunk: #ebe9e3;
  --fg: #1d1d1b;
  --muted: #7f7d77;
  --faint: #b9b7b0;
  --line: #e2e0d9;
  --primary: #1d1d1b;
  --on-primary: #fbfaf7;
  --danger: #c4402f;
  --warn: #c98316;
  --shadow: 0 18px 50px rgba(30, 28, 20, .14), 0 2px 8px rgba(30, 28, 20, .06);
  --radius: 26px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --kb: 0px;

  --t-ink: #3a3a36;  --t-gray: #737a83; --t-green: #4c8a3a; --t-yellow: #c99a00; --t-blue: #3a72d4;
  --t-teal: #1d8c83; --t-orange: #dd741a; --t-red: #d0463a; --t-purple: #7559d2; --t-pink: #cf4f87;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11110f; --card: #1b1b19; --sunk: #232320; --fg: #eeede8; --muted: #8f8d86; --faint: #4d4c47;
    --line: #2b2b28; --primary: #eeede8; --on-primary: #151513; --danger: #ec6a59; --warn: #e6a640;
    --shadow: 0 18px 50px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .3);
    --t-ink: #d8d7d1; --t-gray: #a0a7b0; --t-green: #7dbd67; --t-yellow: #e6c23e; --t-blue: #6f9ef1;
    --t-teal: #4ec4b9; --t-orange: #f29a4b; --t-red: #ef7062; --t-purple: #a38cf1; --t-pink: #ee80b1;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11110f; --card: #1b1b19; --sunk: #232320; --fg: #eeede8; --muted: #8f8d86; --faint: #4d4c47;
  --line: #2b2b28; --primary: #eeede8; --on-primary: #151513; --danger: #ec6a59; --warn: #e6a640;
  --shadow: 0 18px 50px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .3);
  --t-ink: #d8d7d1; --t-gray: #a0a7b0; --t-green: #7dbd67; --t-yellow: #e6c23e; --t-blue: #6f9ef1;
  --t-teal: #4ec4b9; --t-orange: #f29a4b; --t-red: #ef7062; --t-purple: #a38cf1; --t-pink: #ee80b1;
  color-scheme: dark;
}

.tone-ink { --tone: var(--t-ink); }     .tone-gray { --tone: var(--t-gray); }   .tone-green { --tone: var(--t-green); }
.tone-yellow { --tone: var(--t-yellow); } .tone-blue { --tone: var(--t-blue); } .tone-teal { --tone: var(--t-teal); }
.tone-orange { --tone: var(--t-orange); } .tone-red { --tone: var(--t-red); }   .tone-purple { --tone: var(--t-purple); }
.tone-pink { --tone: var(--t-pink); }

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
body { overflow: hidden; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

.ic { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.flex { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------------ stage */

.stage {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.stage-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px 16px 0;
  min-height: 56px;
}
.today {
  border: 0;
  background: none;
  padding: 8px 12px;
  border-radius: 99px;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: .01em;
}
.status { font-size: 12px; color: var(--warn); }
.status.pending::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.status.offline::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); margin-right: 6px; vertical-align: 1px; }

.symbols {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  align-items: flex-start;
  gap: 18px 14px;
  padding: 12px 16px;
  overflow: hidden;
}

.sym {
  --s: 72px;
  --u: 0;
  border: 0;
  background: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: calc(var(--s) + 22px);
  transition: width .9s var(--ease), opacity .4s, transform .45s var(--ease);
}
.sym-dot {
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--tone);
  background: color-mix(in srgb, var(--tone) calc(13% + var(--u) * 24%), var(--card));
  box-shadow: 0 0 0 calc(var(--u) * 7px) color-mix(in srgb, var(--tone) 9%, transparent);
  transition: width .9s var(--ease), height .9s var(--ease), background .9s, box-shadow .9s;
}
.sym-dot .ic { width: calc(var(--s) * .44); height: calc(var(--s) * .44); stroke-width: 1.6; }
.sym-label {
  max-width: 100%;
  font-size: 13px;
  line-height: 1.25;
  color: var(--muted);
  text-align: center;
  hyphens: auto;
  -webkit-hyphens: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.sym:active .sym-dot { transform: scale(.94); }
.sym.enter { opacity: 0; transform: scale(.4); }
.sym.leave { opacity: 0; transform: scale(.6); pointer-events: none; }
.sym.ripe .sym-dot { animation: breathe 3.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.045); } }

.handle {
  align-self: center;
  border: 0;
  background: none;
  padding: 14px 40px calc(14px + 4px);
}
.handle span { display: block; width: 44px; height: 5px; border-radius: 9px; background: var(--faint); }

/* ------------------------------------------------------------------ layers */

.layers { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
.layer { position: absolute; inset: 0; pointer-events: none; }
.layer.open, .layer.dragging { pointer-events: auto; }
.scrim {
  position: absolute; inset: 0;
  background: rgba(10, 10, 8, .28);
  opacity: 0;
  transition: opacity .38s var(--ease);
}
.layer.open .scrim { opacity: 1; }
.layer.dragging .scrim, .layer.dragging .sheet { transition: none !important; }

.sheet {
  position: absolute;
  background: var(--card);
  box-shadow: var(--shadow);
  transition: transform .4s var(--ease);
  display: flex;
  flex-direction: column;
  max-width: 640px;
  margin: 0 auto;
}

.layer--bottom .sheet {
  left: 0; right: 0; bottom: var(--kb);
  max-height: calc(100% - 48px - var(--kb));
  border-radius: var(--radius) var(--radius) 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  transform: translateY(105%);
  touch-action: none;
}
.layer--top .sheet {
  left: 0; right: 0; top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  padding-top: env(safe-area-inset-top);
  transform: translateY(-105%);
  touch-action: none;
}
.layer--right .sheet, .layer--left .sheet {
  top: 0; bottom: 0; left: 0; right: 0;
  max-width: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
.layer--right .sheet { transform: translateX(104%); }
.layer--left .sheet { transform: translateX(-104%); }
.layer.open .sheet { transform: none; }

@media (min-width: 720px) {
  .layer--right .sheet, .layer--left .sheet { max-width: 560px; }
  .layer--right .sheet { left: auto; border-radius: var(--radius) 0 0 var(--radius); }
  .layer--left .sheet { right: auto; border-radius: 0 var(--radius) var(--radius) 0; }
  .layer--bottom .sheet, .layer--top .sheet { max-width: 560px; }
}

.sheet > * { min-height: 0; }
.detail.scrolly { touch-action: pan-y; }
.detail.scrolly .grip, .detail.scrolly .detail-top { touch-action: none; }
.grip { display: grid; place-items: center; padding: 10px 0 6px; cursor: grab; touch-action: none; }
.grip span { width: 40px; height: 5px; border-radius: 9px; background: var(--line); }

/* ------------------------------------------------------------------ screens */

.screen { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.sheet-head {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 8px 10px 6px;
  touch-action: pan-y;
  user-select: none;
}
.layer--right .sheet-head, .layer--left .sheet-head { touch-action: none; }
.sheet-head h2 { flex: 1; font-size: 22px; font-weight: 650; letter-spacing: -.01em; padding-left: 4px; }
.head-actions { display: flex; gap: 2px; }
.screen-body {
  flex: 1;
  min-height: 0;
  padding: 4px 16px calc(24px + env(safe-area-inset-bottom));
}
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.form { display: flex; flex-direction: column; gap: 16px; }

.icon-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: none;
  color: var(--fg);
  flex: none;
}
.icon-btn:active { background: var(--sunk); }
.icon-btn.sm { width: 36px; height: 36px; color: var(--muted); }
.icon-btn.sm .ic { width: 20px; height: 20px; }
.icon-btn.filled { background: var(--primary); color: var(--on-primary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 99px;
  font-weight: 560;
  text-decoration: none;
  white-space: nowrap;
  transition: transform .15s, background .2s;
}
.btn:active { transform: scale(.97); }
.btn .ic { width: 20px; height: 20px; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:disabled { opacity: .35; }
.btn-soft { background: var(--sunk); color: var(--fg); }
.btn-wide { width: 100%; }
.btn-row { display: flex; gap: 8px; }
.btn-row > * { flex: 1; }
.link { border: 0; background: none; padding: 6px 4px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }

.field {
  width: 100%;
  border: 1.5px solid transparent;
  border-radius: 16px;
  background: var(--sunk);
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
  transition: border-color .2s, background .2s;
}
.field:focus { border-color: var(--line); background: var(--card); }
.field.invalid { border-color: var(--danger); }
.field-lg { font-size: 20px; font-weight: 560; padding: 14px 16px; }
.field-sm { width: auto; max-width: 150px; padding: 8px 10px; font-size: 14px; border-radius: 12px; }
textarea.field { resize: none; line-height: 1.45; }
select.field { appearance: none; -webkit-appearance: none; background-image: none; }
.field-wrap { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; color: var(--muted); padding-left: 4px; }
.field-help { font-size: 13px; color: var(--muted); padding-left: 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dated { display: flex; flex-direction: column; gap: 16px; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  border: 0; border-radius: 99px;
  padding: 9px 14px;
  background: var(--sunk);
  font-size: 14px;
}
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }

.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.icon-pick {
  aspect-ratio: 1;
  border: 0; border-radius: 14px;
  display: grid; place-items: center;
  background: none;
  color: var(--tone);
}
.icon-pick[aria-checked="true"] { background: color-mix(in srgb, var(--tone) 20%, var(--card)); box-shadow: inset 0 0 0 1.5px var(--tone); }

.badge {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--tone);
  background: color-mix(in srgb, var(--tone) 16%, var(--card));
  flex: none;
}
.badge-lg { width: 60px; height: 60px; }
.badge-lg .ic { width: 28px; height: 28px; }
.badge-sm { width: 38px; height: 38px; }
.badge-sm .ic { width: 20px; height: 20px; }

.section { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 22px 4px 8px; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin: 22px 4px 6px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.section-head .link { text-transform: none; letter-spacing: 0; font-weight: 400; }
.empty { color: var(--muted); padding: 28px 8px; text-align: center; }
.empty-block { text-align: center; padding: 40px 12px; display: grid; gap: 6px; }

.row { display: flex; align-items: center; }
.row-main {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 12px;
  border: 0; background: none; text-align: left;
  padding: 8px 4px;
  border-radius: 16px;
}
.row-main:active { background: var(--sunk); }
.row-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.row-title { font-weight: 540; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.more { margin-top: 14px; }

.searchrow { display: flex; align-items: center; gap: 8px; background: var(--sunk); border-radius: 16px; padding-left: 12px; color: var(--muted); margin-bottom: 8px; }
.searchrow .field { background: none; padding-left: 0; }
.searchrow .field:focus { background: none; border-color: transparent; }

.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--sunk); color: var(--muted);
  font-size: 14px; font-weight: 600; flex: none;
}

/* ------------------------------------------------------------------ composer */

.composer { display: flex; flex-direction: column; gap: 12px; padding: 0 16px 16px; }
.composer-input {
  border: 0; outline: none; background: none;
  font-size: 19px; line-height: 1.45;
  min-height: 120px; resize: none;
  padding: 6px 2px;
  touch-action: auto;
}
.composer-input::placeholder { color: var(--faint); }
.composer-foot { display: flex; gap: 10px; align-items: center; }
.hint { font-size: 13px; color: var(--muted); }

/* ------------------------------------------------------------------ menu */

.menu { padding: 12px 16px 0; display: flex; flex-direction: column; gap: 12px; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  border: 0; border-radius: 22px;
  background: var(--sunk);
  padding: 16px;
  display: grid; justify-items: start; gap: 2px;
  text-align: left;
  min-height: 108px;
}
.tile .ic { width: 26px; height: 26px; margin-bottom: 10px; }
.tile-title { font-weight: 620; font-size: 17px; }
.tile-sub { font-size: 14px; color: var(--muted); }
.tile:active { transform: scale(.98); }
.menu-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.menu-foot { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); padding: 4px 4px 0; }
.sync-state { font-size: 12px; }

/* ------------------------------------------------------------------ detail */

.detail { display: flex; flex-direction: column; gap: 16px; padding: 0 20px 18px; overflow-y: auto; }
.detail-top { display: flex; align-items: center; gap: 16px; padding-top: 4px; }
.detail-title { font-size: 24px; font-weight: 650; letter-spacing: -.01em; line-height: 1.2; }
.detail-when { color: var(--muted); margin-top: 2px; }
.detail-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1.5px solid var(--line); background: none; border-radius: 99px; padding: 9px 14px; font-size: 15px; }
.chip:active { background: var(--sunk); }
.meta { font-size: 13px; color: var(--muted); }

.contact-card { background: var(--sunk); border-radius: 20px; padding: 6px; display: flex; flex-direction: column; }
.contact-name, .contact-line {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 14px;
  border: 0; background: none; text-align: left; text-decoration: none;
}
.contact-name { font-weight: 600; }
.contact-line .ic, .contact-name .ic { width: 20px; height: 20px; color: var(--muted); }
.contact-line:active, .contact-name:active { background: var(--line); }
.quick { display: flex; gap: 8px; flex-wrap: wrap; }
.quick .btn { flex: 1; }

/* ------------------------------------------------------------------ groceries */

.addrow { display: flex; gap: 8px; align-items: center; position: sticky; top: 0; background: var(--card); padding: 4px 0 10px; z-index: 1; }
.glist { list-style: none; margin: 0; padding: 0; }
.grow-row { display: flex; align-items: center; }
.gcheck {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 14px;
  border: 0; background: none; text-align: left;
  padding: 12px 4px; font-size: 17px;
}
.box {
  width: 26px; height: 26px; border-radius: 50%;
  border: 1.8px solid var(--faint);
  display: grid; place-items: center; flex: none;
  transition: background .2s, border-color .2s;
}
.box .ic { width: 16px; height: 16px; stroke-width: 2.4; }
.gtext { flex: 1; overflow-wrap: anywhere; }
.by { font-size: 12px; color: var(--muted); }
.grow-row.checked .gtext { color: var(--muted); text-decoration: line-through; }
.grow-row.checked .box { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* ------------------------------------------------------------------ notes */

.notes { display: flex; flex-direction: column; gap: 10px; }
.note { background: var(--sunk); border-radius: 20px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.note.open .note-text { -webkit-line-clamp: unset; display: block; }
.note-summary { display: flex; gap: 8px; font-size: 14px; color: var(--muted); }
.note-summary .ic { width: 16px; height: 16px; margin-top: 2px; color: var(--t-purple); }
.note-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 13px; color: var(--muted); }
.pill { background: var(--primary); color: var(--on-primary); border-radius: 99px; padding: 1px 8px; font-size: 12px; font-weight: 600; }
.tag { color: var(--muted); }
.note-actions { display: flex; gap: 8px; }
.note-actions .btn { min-height: 40px; flex: 1; }
.contact-row { margin-bottom: 4px; }

/* ------------------------------------------------------------------ import */

.lead-text { color: var(--muted); }
.import-row { display: flex; align-items: center; gap: 10px; }
.import-row.off { opacity: .4; }

/* ------------------------------------------------------------------ toast */

.toast {
  position: fixed;
  left: 0; right: 0; bottom: calc(24px + env(safe-area-inset-bottom) + var(--kb));
  margin: 0 auto;
  width: max-content;
  max-width: calc(100% - 32px);
  transform: translateY(30px);
  opacity: 0;
  pointer-events: none;
  z-index: 50;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px 12px 20px;
  border-radius: 24px;
  background: var(--primary); color: var(--on-primary);
  box-shadow: var(--shadow);
  font-size: 15px;
  transition: transform .35s var(--ease), opacity .25s;
}
.toast.show { transform: none; opacity: 1; pointer-events: auto; }
.toast-btn { border: 0; background: none; color: inherit; font-weight: 650; padding: 4px 6px; text-decoration: underline; text-underline-offset: 3px; }

/* ------------------------------------------------------------------ login & coach */

.login {
  position: fixed; inset: 0; z-index: 60;
  background: var(--bg);
  display: grid; place-items: center;
  padding: 24px;
  transition: opacity .35s;
}
.login.leaving { opacity: 0; }
.login-form { width: min(360px, 100%); display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.logo { width: 72px; height: 72px; align-self: center; fill: var(--fg); }
.logo circle:last-child { fill: var(--t-orange); }
.login-title { text-align: center; font-size: 30px; font-weight: 680; letter-spacing: -.02em; margin-bottom: 18px; }
.login-err { color: var(--danger); min-height: 1.4em; text-align: center; font-size: 15px; }

.coach {
  position: fixed; inset: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: grid;
  grid-template: "a a a" auto "l m r" 1fr "b b b" auto / 1fr minmax(0, 260px) 1fr;
  padding: calc(28px + env(safe-area-inset-top)) 12px calc(28px + env(safe-area-inset-bottom));
  transition: opacity .3s;
  animation: fade .4s;
}
.coach.leaving { opacity: 0; }
@keyframes fade { from { opacity: 0; } }
.coach-dir { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 14px; color: var(--muted); text-align: center; }
.coach-dir b { color: var(--fg); font-size: 16px; }
.coach-dir .arrow { font-size: 26px; color: var(--fg); line-height: 1; }
.coach-dir.up { grid-area: b; }
.coach-dir.down { grid-area: a; }
.coach-dir.left { grid-area: r; align-self: center; }
.coach-dir.right { grid-area: l; align-self: center; }
.coach-mid { grid-area: m; align-self: center; display: flex; flex-direction: column; gap: 10px; text-align: center; }
.coach-mid .btn { margin-top: 10px; }

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