:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --text: #1f1a16;
  --muted: #6f655c;
  --border: #e4ddd3;
  --accent: #7a4a2b;
  --accent-text: #ffffff;
  --accent-soft: #f3e8df;
  --note: #b97d00;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --warn: #a15c00;
  --warn-soft: #fff1dc;
  --ok: #2e6b3a;
  --ok-soft: #e4f2e6;
  --info: #285a8a;
  --info-soft: #e3eef8;
  --shadow: 0 1px 2px rgba(40, 25, 10, .06), 0 4px 16px rgba(40, 25, 10, .06);
  --radius: 12px;
  color-scheme: light;
}

/* Fallbacks only: themes.css (loaded after) sets every colour per palette through
   <html data-palette data-mode>. The :not() keeps a forced light mode on a dark computer
   from picking up this dark --shadow, which the light palettes don't override. */
@media (prefers-color-scheme: dark) {
  :root:not([data-mode="light"]) {
    --bg: #151210;
    --surface: #1f1b18;
    --surface-2: #26211d;
    --text: #f1ebe4;
    --muted: #a99d91;
    --border: #3a332d;
    --accent: #d39a6a;
    --accent-text: #1a120c;
    --accent-soft: #3a2a1f;
    --note: #f2c94c;
    --danger: #f2827a;
    --danger-soft: #3d1f1c;
    --warn: #f0b35a;
    --warn-soft: #3a2b15;
    --ok: #86c995;
    --ok-soft: #1d3322;
    --info: #8cbdf0;
    --info-soft: #1a2c3d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

/* ---------- top bar & nav ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; min-width: 0; }
.brand span:not(.sync) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo { width: 30px; height: 30px; border-radius: 9px; object-fit: cover; box-shadow: 0 1px 4px color-mix(in srgb, var(--text) 18%, transparent); }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav button {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); cursor: pointer; font-weight: 500;
}
.nav button:hover { background: var(--surface-2); color: var(--text); }
.nav button.active { background: var(--accent-soft); color: var(--accent); }

main { max-width: 1040px; margin: 0 auto; padding: 24px 24px 120px; }

.fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 14px 20px; border: 0; border-radius: 999px;
  background: var(--accent); color: var(--accent-text);
  font-weight: 600; box-shadow: var(--shadow); cursor: pointer;
}
.fab:hover { filter: brightness(1.08); }

@media (max-width: 760px) {
  .topbar { padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
  .brand { flex: 1; } /* the sync icon sits at the right end, as in the Android app */
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    justify-content: space-around; gap: 0;
    padding: 6px 4px max(6px, env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--border);
  }
  .nav button { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 11px; flex: 1; }
  main { padding: 16px 16px 160px; }
  .fab { right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); padding: 14px; }
  .fab span { display: none; }
}

/* ---------- page header ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 24px; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
h2 { font-size: 15px; margin: 28px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
h2 .count { color: var(--text); margin-left: 6px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat {
  padding: 14px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); text-align: left; cursor: pointer;
}
.stat:hover { border-color: var(--accent); }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat.alert .value { color: var(--danger); }
.stat.good .value { color: var(--ok); }

/* ---------- today ---------- */
.today-hero {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  margin-bottom: 14px; padding: 22px 24px; border-radius: 18px;
  background: linear-gradient(135deg, var(--accent-soft), var(--surface)); border: 1px solid var(--border);
}
.today-kicker { margin-bottom: 3px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.today-hero h1 { margin: 0; font-size: clamp(24px, 4vw, 34px); line-height: 1.15; }
.today-hero p { margin: 6px 0 0; color: var(--muted); }
.today-new { min-height: 44px; }
.today-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(145px, 1.35fr); gap: 9px; margin-bottom: 24px; }
.today-stat {
  display: flex; flex-direction: column; gap: 5px; min-width: 0; padding: 13px 14px;
  text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; cursor: pointer;
}
.today-stat:hover { border-color: var(--accent); }
.today-stat span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.today-stat strong { overflow: hidden; color: var(--text); font-size: 22px; line-height: 1.1; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.today-stat.alert strong { color: var(--danger); }
.today-stat.good strong { color: var(--ok); }
.today-stat.balance strong { font-size: 18px; }
.today-section { margin-top: 20px; }
.today-section-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.today-section-head h2 { margin: 0; color: var(--text); font-size: 14px; }
.today-section-head span { display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 700; }
.today-section.urgent .today-section-head h2, .today-section.urgent .today-section-head span { color: var(--danger); }
.today-clear { display: flex; align-items: center; gap: 14px; padding: 22px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.today-clear > span { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 20px; font-weight: 800; }
.today-clear strong { font-size: 16px; }
.today-clear p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

@media (max-width: 700px) {
  .today-hero { padding: 18px; border-radius: 15px; }
  .today-new { display: none; }
  .today-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
  .today-stat { padding: 11px 8px; }
  .today-stat span { font-size: 11px; }
  .today-stat strong { font-size: 20px; }
  .today-stat.balance { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; padding: 11px 13px; }
  .today-stat.balance strong { font-size: 17px; }
}

/* ---------- cards / banners ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px;
  background: var(--warn-soft); color: var(--text); border: 1px solid transparent;
}
.banner.welcome { background: var(--accent-soft); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

/* ---------- list rows ---------- */
.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 16px; border: 0; border-bottom: 1px solid var(--border);
  background: transparent; text-align: left; cursor: pointer;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.row-side .bal { font-size: 12px; color: var(--warn); font-weight: 600; }
.row.overdue .row-sub .when { color: var(--danger); font-weight: 600; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700;
  background: var(--accent-soft); color: var(--accent);
}

/* ---------- pills ---------- */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.s-booked { background: var(--info-soft); color: var(--info); border-color: transparent; }
.s-cutting, .s-stitching { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.s-fitting { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.s-ready { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.s-delivered { background: var(--surface-2); color: var(--muted); }
.s-cancelled { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.search {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface);
}
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
/* Fade the right edge so a cut-off chip reads as "scroll for more"; the extra right padding
   lets the last chip scroll fully clear of the fade. */
.chips {
  padding-right: 32px;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent);
}
.chip {
  flex: none; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 500;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip .n { opacity: .7; margin-left: 4px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; font-weight: 600; white-space: nowrap; text-decoration: none; color: var(--text);
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn svg { width: 16px; height: 16px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- modal ---------- */
dialog {
  width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); } /* neutral dim — stays dark in every palette and mode */
.modal-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-body { padding: 16px 20px; }
.modal-foot {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--surface); border-top: 1px solid var(--border);
}
.modal-foot .spacer { flex: 1; }
.icon-btn { border: 0; background: transparent; cursor: pointer; padding: 6px; border-radius: 8px; color: var(--muted); display: grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* New/Edit order follows a simple three-section workspace. */
.order-form-shell {
  display: flex; flex-direction: column;
  height: min(760px, calc(100dvh - 48px)); min-height: 520px;
  overflow: hidden;
}
.order-form-shell .modal-head { position: static; flex: none; }
.order-tabs {
  position: relative; z-index: 4; flex: none; display: grid; grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--border); background: var(--surface);
}
.order-tab {
  position: relative; min-height: 52px; padding: 10px 8px;
  border: 0; border-right: 1px solid var(--border); background: transparent;
  color: var(--muted); font-size: 14px; font-weight: 650; cursor: pointer;
}
.order-tab:last-child { border-right: 0; }
.order-tab:hover { background: var(--surface-2); color: var(--text); }
.order-tab.active { color: var(--accent); background: var(--accent-soft); }
.order-tab.active::after { display: none; }
.order-tab-body {
  flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; padding: 18px 20px;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scrollbar-gutter: stable; scroll-padding-top: 16px;
}
.order-tab-panel[hidden] { display: none !important; }
.order-tab-panel { min-height: 100%; }
.order-tab-panel > fieldset { min-height: 100%; }
.order-form-shell .field { min-width: 0; }
.order-form-shell .field input,
.order-form-shell .field select,
.order-form-shell .field textarea { min-width: 0; max-width: 100%; }
.order-form-shell input[type="date"] { width: 100%; min-width: 0; }
.order-form-error {
  margin-bottom: 14px; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border));
  border-radius: 9px; background: var(--danger-soft); color: var(--danger); font-size: 13px; font-weight: 650;
}
.order-form-shell .input-error { border-color: var(--danger); outline: 2px solid color-mix(in srgb, var(--danger) 24%, transparent); }
.order-form-shell .modal-foot {
  position: static; flex: none; display: grid; grid-template-columns: 1fr;
  gap: 0; padding: 0; flex-wrap: nowrap;
}
.order-form-shell .modal-foot .btn {
  min-height: 58px; border: 0; border-right: 1px solid var(--border); border-radius: 0;
  font-size: 15px;
}
.order-form-shell .modal-foot .btn:last-child { border-right: 0; }
.order-form-shell .modal-foot .btn.primary { font-size: 16px; }

@media (max-width: 760px) {
  dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; border: 0; }
  .modal-head { padding-top: max(16px, env(safe-area-inset-top)); }
  .modal-foot { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  #modal:has(.order-form-shell) {
    position: fixed; inset: var(--app-visible-top, 0px) 0 auto;
    width: 100vw; height: var(--app-visible-height, 100dvh); max-height: var(--app-visible-height, 100dvh);
    overflow: hidden;
  }
  #modal:has(.order-form-shell) > #modal-body { height: 100%; overflow: hidden; }
  .order-form-shell { height: 100%; min-height: 0; }
  .order-tab { min-height: 50px; }
  .order-tab-body { padding: 20px 14px 14px; }
  .order-form-shell .modal-foot { padding-bottom: env(safe-area-inset-bottom); }
  .order-form-shell .modal-foot .btn { min-height: 56px; }
  /* While the keyboard is up: no action bar above it, and nothing from the
     page showing through the keyboard's translucent top area. */
  html.keyboard-open .modal-foot { display: none; }
  html.keyboard-open dialog::backdrop { background: var(--surface); }
  html.keyboard-open body { background: var(--surface); }
  .order-form-shell .field input,
  .order-form-shell .field select,
  .order-form-shell .field textarea { min-height: 44px; font-size: 16px; }
  .order-form-shell .field textarea { resize: none; }
  .order-form-shell select { text-overflow: ellipsis; }
}

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 520px) {
  .form-grid { grid-template-columns: 1fr; }
  .order-form-shell .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .order-form-shell .form-grid .full { grid-column: 1 / -1; }
}
@media (max-width: 480px) {
  .order-form-shell .form-grid .order-schedule-field { grid-column: 1 / -1; }
}
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2); color: var(--text); font-size: 15px; width: 100%;
}
.field textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus, .search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.req::after { content: " *"; color: var(--danger); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px 14px; margin: 0; }
legend { padding: 0 6px; font-weight: 600; font-size: 14px; }
.measure-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.measure-grid .field input { padding: 7px 9px; }
.measure-input { display: flex; }
.measure-input input { flex: 1; min-width: 0; border-top-right-radius: 0 !important; border-bottom-right-radius: 0 !important; }
.measure-input-pair { gap: 5px; align-items: stretch; }
.measure-input-pair input { width: 0; box-sizing: border-box; }
.measure-input-pair .measure-first {
  border: 1px solid var(--border); border-radius: 9px !important;
}
.measure-input-pair .measure-second {
  position: relative; z-index: 1; border: 1.5px solid color-mix(in srgb, var(--accent) 68%, var(--border));
  border-radius: 9px !important; background: var(--surface);
}
.measure-input-pair .measure-second:focus { z-index: 2; outline-width: 2px; }
.measure-pair-values { display: inline-flex; align-items: center; gap: 4px; font-style: normal; }
.measure-pair-values i {
  box-sizing: border-box; min-width: 30px; min-height: 24px; padding: 2px 5px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); text-align: center; font-style: normal; font-variant-numeric: tabular-nums;
}
.measure-pair-values i.second { border: 1.5px solid color-mix(in srgb, var(--accent) 68%, var(--border)); padding: 1.5px 4.5px; }
.unit-btn {
  flex: none; min-width: 42px; padding: 0 10px; cursor: pointer;
  border: 1px solid var(--border); border-left: 0; border-radius: 0 9px 9px 0;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 13px;
}
.measure-input-pair .unit-btn { margin-left: 0; border-left: 1px solid var(--border); border-radius: 9px; }
.unit-btn:hover { filter: brightness(.97); }
.measure-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; flex: none; }
.seg button { border: 0; background: var(--surface); color: var(--text); padding: 5px 12px; font-size: 13px; font-weight: 500; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button:hover { background: var(--surface-2); }
.hint { font-size: 12px; color: var(--muted); }
.new-customer { display: none; }
.new-customer.show { display: contents; }

/* ---------- detail ---------- */
.detail-section { margin-top: 18px; }
.detail-section:first-child { margin-top: 0; }
.detail-section h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 16px; }
.kv div span { display: block; font-size: 12px; color: var(--muted); }
.kv div strong { font-weight: 600; }
.measure-table { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.measure-table div { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 8px; padding: 6px 10px; background: var(--surface-2); border-radius: 8px; font-size: 14px; }
.measure-table div span { color: var(--muted); }
.measure-table div strong { font-variant-numeric: tabular-nums; }
.measure-table small { font-size: 11px; font-weight: 500; color: var(--muted); }
.measure-table em { flex-basis: 100%; text-align: right; font-style: normal; font-size: 12px; color: var(--muted); }
.stepper { display: flex; gap: 6px; flex-wrap: wrap; }
.stepper button { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 500; color: var(--muted); }
.stepper button.done { color: var(--text); }
.stepper button.current { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.money-box { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.money-box div { padding: 10px 12px; background: var(--surface-2); border-radius: 10px; }
.money-box span { display: block; font-size: 12px; color: var(--muted); }
.money-box strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.money-box .due strong { color: var(--warn); }
.money-box .settled strong { color: var(--ok); }
.payments { margin: 8px 0 0; padding: 0; list-style: none; font-size: 14px; }
.payments li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.payments li:last-child { border-bottom: 0; }
.prewrap { white-space: pre-wrap; }
.muted { color: var(--muted); }

/* ---------- schedule ---------- */
.day { margin-bottom: 18px; }
.day-head { display: flex; align-items: baseline; gap: 8px; margin: 0 0 8px; font-weight: 700; }
.day-head .rel { color: var(--muted); font-weight: 500; font-size: 13px; }
.day.overdue .day-head { color: var(--danger); }
.tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; text-transform: uppercase; letter-spacing: .03em; flex: none; }
.tag.due { background: var(--info-soft); color: var(--info); }
.tag.fitting { background: var(--warn-soft); color: var(--warn); }

/* ---------- line editor (opened from Settings → Measurements) ---------- */
.line-editor-preview {
  display: grid; place-items: center; height: 330px; margin: 14px 0; overflow: hidden;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2);
}
.line-editor-preview .body-stage { width: auto; max-width: none; height: 306px; }
.line-editor-list { display: grid; gap: 8px; }
.line-editor-row { overflow: hidden; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); }
.line-editor-row summary {
  display: grid; grid-template-columns: 15px minmax(0, 1fr) auto 16px; align-items: center; gap: 10px;
  padding: 12px 13px; cursor: pointer; list-style: none;
}
.line-editor-row summary::-webkit-details-marker { display: none; }
.line-editor-row summary::after { content: "›"; color: var(--muted); font-size: 20px; transform: rotate(0); transition: transform .16s; }
.line-editor-row[open] summary::after { transform: rotate(90deg); }
.line-editor-row summary strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.line-editor-row .line-pattern { margin-right: 4px; color: var(--muted); font-size: 12px; text-transform: capitalize; }
.line-swatch { width: 12px; height: 12px; border-radius: 50%; background: var(--swatch); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border); }
.line-editor-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 14px; border-top: 1px solid var(--border); background: var(--surface-2); }
.line-editor-fields .full { grid-column: 1 / -1; }
.line-editor-fields output { float: right; color: var(--text); font-variant-numeric: tabular-nums; }
.line-editor-fields input[type="color"] { min-height: 42px; padding: 4px; cursor: pointer; }
.line-editor-fields input[type="range"] { min-height: 30px; padding: 0; accent-color: var(--accent); }
.line-editor-fields .btn { justify-self: start; }
@media (max-width: 520px) {
  .line-editor-preview { height: 260px; }
  .line-editor-preview .body-stage { height: 240px; }
  .line-editor-fields { gap: 10px; padding: 12px; }
}

/* ---------- full-screen line designer ---------- */
.le .viewer-bar { flex: none; }
.le-title { display: flex; flex-direction: column; min-width: 0; text-align: center; }
.le-title strong { font-size: 16px; }
.le-title span { color: var(--muted); font-size: 11px; }
.le-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 370px); overflow: hidden; background: var(--bg); }
.le-stage { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; overflow: hidden; padding: 58px 18px 18px; background-color: var(--surface); background-image: linear-gradient(color-mix(in srgb, var(--border) 24%, transparent) 1px, transparent 1px), linear-gradient(90deg, color-mix(in srgb, var(--border) 24%, transparent) 1px, transparent 1px); background-size: 24px 24px; border-right: 1px solid var(--border); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--border) 55%, transparent); }
#le-figure { display: flex; justify-content: center; width: 100%; height: 100%; min-height: 0; }
#le-figure .body-stage { width: auto; max-width: 100%; height: 100%; max-height: 100%; touch-action: none; user-select: none; transform-origin: center; cursor: grab; }
#le-figure .body-stage:active { cursor: grabbing; }
#le-figure .mk { cursor: pointer; }
#le-figure .mk.active .mk-line { filter: drop-shadow(0 0 2px color-mix(in srgb, var(--accent) 65%, transparent)); }
.line-editor-svg .mk-dot { opacity: 0; pointer-events: none; }
.line-editor-svg .mk.active .mk-dot { r: 2.2px; opacity: 1; pointer-events: all; cursor: grab; stroke-width: 1.2; }
.line-editor-svg .mk.active .mk-dot:active { cursor: grabbing; }
.line-draw-preview { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: none; pointer-events: none; }
.line-draw-preview.snapped { stroke: var(--ok); }
.le-gender { position: absolute; top: 14px; left: 50%; z-index: 3; transform: translateX(-50%); background: var(--surface); box-shadow: var(--shadow); }
.le-zoom-hint { position: absolute; right: 12px; bottom: 10px; z-index: 2; padding: 5px 8px; border-radius: 7px; background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--muted); font-size: 10px; pointer-events: none; }
.le-draw-tip { position: absolute; left: 50%; bottom: 18px; z-index: 4; width: max-content; max-width: calc(100% - 28px); transform: translateX(-50%); padding: 9px 14px; border-radius: 999px; background: var(--text); color: var(--bg); font-size: 12px; text-align: center; box-shadow: var(--shadow); }
#le-add.drawing { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.le-save-state { justify-self: end; color: var(--ok); font-size: 12px; font-weight: 700; }
.le-save-state.unsaved { color: var(--warn); }
.le-side { min-height: 0; display: grid; grid-template-rows: auto auto minmax(250px, 1fr); padding: 14px; overflow: hidden; background: var(--bg); }
.le-side, .le-side * { min-width: 0; }
.le-side-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 0 2px 10px; }
.le-side-head span { color: var(--muted); font-size: 12px; }
.le-list { margin-bottom: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.le-display-title { margin-bottom: 9px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.le-display-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.le-display { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 7px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); color: var(--muted); cursor: pointer; }
.le-display strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.le-display.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.le-display.drawing { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.le-check, .le-count { display: grid; place-items: center; flex: none; width: 22px; height: 22px; border: 1px solid currentColor; border-radius: 5px; font-size: 12px; font-weight: 800; }
.le-display-help { margin: 9px 2px 0; color: var(--muted); font-size: 11px; line-height: 1.35; }
.le-all-style { margin-top: 8px; border-top: 1px solid var(--border); }
.le-all-style summary { padding: 9px 2px 4px; color: var(--accent); font-size: 12px; font-weight: 700; cursor: pointer; }
.le-all-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding-top: 5px; }
.le-all-grid label { min-width: 0; color: var(--muted); font-size: 10px; }
.le-all-grid label.full { grid-column: 1 / -1; }
.le-all-grid input, .le-all-grid select { width: 100%; min-width: 0; margin-top: 2px; padding: 5px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); }
.le-all-grid input[type="color"] { height: 34px; padding: 3px; }
.le-all-grid input[type="range"] { padding: 0; accent-color: var(--accent); }
.le-all-grid output { float: right; color: var(--text); }
.le-choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 5px; max-height: 190px; margin-top: 9px; padding-top: 9px; overflow-y: auto; border-top: 1px solid var(--border); }
.le-choice { display: grid; grid-template-columns: 20px minmax(0, 1fr); align-items: center; gap: 6px; min-width: 0; min-height: 34px; padding: 5px 7px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); text-align: left; cursor: pointer; }
.le-choice > span { display: grid; place-items: center; width: 18px; height: 18px; border: 1px solid var(--border); border-radius: 4px; color: var(--accent-text); font-size: 11px; font-weight: 800; }
.le-choice strong { overflow: hidden; font-size: 11px; font-weight: 600; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; }
.le-choice.checked { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.le-choice.checked > span { border-color: var(--accent); background: var(--accent); }
.le-hidden { display: none; }
.le-line { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; align-items: center; gap: 9px; width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); text-align: left; cursor: pointer; }
.le-line:hover { border-color: var(--accent); }
.le-line.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.le-line > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.le-line small { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.le-controls { min-height: 0; overflow-y: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: 0 1px 3px color-mix(in srgb, var(--text) 4%, transparent); }
.le-active-picker { display: grid; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700; }
.le-active-picker select { width: 100%; min-width: 0; padding: 8px 9px; border: 1px solid var(--accent); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 14px; }
.le-selected { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 13px 15px; border-bottom: 1px solid var(--border); background: var(--surface); }
.le-selected strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.le-controls .line-editor-fields { border-top: 0; background: transparent; }
.le-controls .field { padding: 2px; }
.le-controls .field input, .le-controls .field select { min-width: 0; max-width: 100%; }
.le-gesture-note { margin: 0; padding: 9px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 11px; line-height: 1.35; }
.le-controls input[type="range"] { width: 100%; }
.le-controls .btn.danger { color: var(--danger); }
.le-controls .btn.le-confirm:disabled { opacity: .45; cursor: default; filter: none; }
/* "Save your line changes?" question shown over the line editor */
.le-ask { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: color-mix(in srgb, var(--text) 38%, transparent); }
.le-ask-card { width: min(100%, 380px); padding: 20px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.le-ask-card h3 { margin: 0 0 6px; font-size: 18px; }
.le-ask-card p { margin: 0 0 16px; color: var(--muted); font-size: 14px; line-height: 1.4; }
.le-ask-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.le-ask-buttons .btn { flex: 1 1 auto; min-height: 44px; }

@media (max-width: 760px) {
  .le-bar { padding-inline: 9px; }
  .le-title span { display: none; }
  .le-body { grid-template-columns: minmax(0, 62%) minmax(0, 38%); grid-template-rows: minmax(0, 1fr); }
  .le-stage { padding: 48px 5px 8px; border-right: 1px solid var(--border); border-bottom: 0; }
  .le-gender { top: 8px; }
  .le-draw-tip { bottom: 8px; font-size: 11px; }
  .le-side { display: flex; flex-direction: column; min-width: 0; padding: 7px; overflow-y: auto; }
  .le-side-head { padding-bottom: 6px; }
  .le-side-head span { display: none; }
  .le-list { margin-bottom: 8px; padding: 9px; }
  .le-display-title { margin-bottom: 6px; }
  .le-display-options { grid-template-columns: 1fr; gap: 4px; }
  .le-display { justify-content: flex-start; min-height: 34px; padding: 4px 6px; }
  .le-display strong { font-size: 11px; }
  .le-check, .le-count { width: 20px; height: 20px; }
  .le-display-help { display: none; }
  .le-choice-grid { grid-template-columns: 1fr; max-height: 155px; }
  .le-choice { min-height: 32px; }
  .le-line { height: 42px; padding: 7px 9px; }
  .le-line small { display: none; }
  .le-controls { flex: none; overflow: visible; }
  .le-controls .line-editor-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 6px; padding: 8px; }
  .le-controls .line-editor-fields .full { grid-column: 1 / -1; }
  .le-controls .field { gap: 3px; font-size: 11px; }
  .le-controls .field input, .le-controls .field select { min-height: 38px; padding: 7px 8px; font-size: 14px; }
  .le-controls .field input[type="color"] { padding: 3px; }
  .le-controls .field input[type="range"] { min-height: 26px; padding: 0; }
  .le-controls .btn { grid-column: 1 / -1; width: 100%; padding: 7px 8px; white-space: normal; font-size: 12px; }
  .le-selected { padding: 9px; }
  .le-selected strong { font-size: 14px; }
  .le-gesture-note { padding: 7px 8px; font-size: 10px; }
}

@media (max-width: 430px) {
  .le-body { grid-template-columns: minmax(0, 60%) minmax(0, 40%); }
  .le-stage { padding-inline: 2px; }
  .le-side { padding: 5px; }
  .le-list { padding: 6px; }
  .le-display-options { gap: 3px; }
  .le-display { min-height: 32px; }
}

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 32px; z-index: 100;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 10px 18px; border-radius: 10px; max-width: calc(100vw - 32px);
  background: var(--text); color: var(--bg); font-weight: 500; box-shadow: var(--shadow);
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); color: var(--surface); }
@media (max-width: 760px) { #toast { bottom: calc(90px + env(safe-area-inset-bottom)); } }

/* ---------- measurement figure ---------- */
.measure-layout { display: grid; grid-template-columns: minmax(150px, 200px) minmax(0, 1fr); gap: 18px; align-items: start; }
.figure-wrap { position: sticky; top: 72px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.figure-wrap.small { position: static; }
.body-stage { position: relative; width: 100%; max-width: 190px; aspect-ratio: var(--body-ratio); flex: none; container-type: size; }
.body-frame { position: absolute; inset: 0; margin: auto; width: min(100cqw, 100cqh * var(--body-ar)); height: min(100cqh, 100cqw / var(--body-ar)); }
.body-frame > .body-art { position: absolute; display: block; max-width: none; pointer-events: none; user-select: none; }
.body-frame > svg.body-fig { position: absolute; inset: 0; display: block; width: 100%; height: 100%; max-width: none; max-height: none; overflow: visible; }
.body-fig .skin {
  fill: var(--surface-2);
  stroke: var(--text);
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.body-art { image-rendering: auto; }
/* The artwork has an almost-white background; blend it into light panels.
   Follows the chosen mode (data-mode), not only the computer's setting. */
:root[data-mode="light"] .body-frame > .body-art { mix-blend-mode: multiply; }
@media not (prefers-color-scheme: dark) { :root:not([data-mode="dark"]) .body-frame > .body-art { mix-blend-mode: multiply; } }
/* Dark fallback: invert so the lines turn light. Blending can't remove the paper here
   (.body-stage's container-type makes its own stacking context), so a dark box remains. */
:root[data-mode="dark"] .body-frame > .body-art { filter: brightness(1.03) invert(1) brightness(.92); }
@media (prefers-color-scheme: dark) { :root:not([data-mode="light"]) .body-frame > .body-art { filter: brightness(1.03) invert(1) brightness(.92); } }
/* Preferred, every mode: the <filter id="zune-ink"> in index.html turns the paper transparent
   (alpha = 1 − luma·255/249, as on Android) and paints the outline in the theme's --text. */
.zune-ink-color { flood-color: var(--text); }
:root:has(#zune-ink) .body-frame > .body-art { filter: url(#zune-ink); mix-blend-mode: normal; }
.mk { cursor: pointer; }
.mk-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; }
.mk-line { fill: none; stroke: var(--line-color, var(--accent)); stroke-width: var(--line-width, 1.4); stroke-dasharray: var(--line-dash, 3.5 3); opacity: .78; }
.mk-dot { fill: var(--line-color, var(--accent)); stroke: var(--surface); stroke-width: .7; opacity: .86; }
.mk.back .mk-line { stroke-dasharray: 1 3; }
.mk.filled .mk-line { stroke: var(--accent); stroke-dasharray: none; opacity: .7; }
.mk.filled .mk-dot { fill: var(--accent); opacity: .7; }
.mk.active .mk-line { stroke: var(--line-color, var(--accent)); stroke-width: calc(var(--line-width, 1.4) * 1.6); opacity: 1; }
.mk.active .mk-dot { fill: var(--line-color, var(--accent)); opacity: 1; }
.mk:hover .mk-line { opacity: 1; }
.figure-caption { margin: 0; font-size: 12px; line-height: 1.4; color: var(--muted); text-align: center; min-height: 3.6em; max-width: 220px; }
.figure-caption strong { color: var(--text); font-size: 13px; }
.m-groups { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.m-group-title { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.m-group-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.seg button.on { background: var(--accent); color: var(--accent-text); }
.measure-table div[data-key] { cursor: pointer; }
.measure-table div.active { box-shadow: inset 0 0 0 2px var(--accent); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.section-head h4 { margin: 0; }
@media (max-width: 640px) {
  .measure-layout { grid-template-columns: 1fr; gap: 12px; }
  .figure-wrap { top: 56px; z-index: 1; flex-direction: row; gap: 12px; padding: 6px 0; background: var(--surface); border-bottom: 1px solid var(--border); }
  .figure-wrap.small { border-bottom: 0; }
  .body-stage { max-width: 112px; }
  .m-groups .measure-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figure-caption { flex: 1; text-align: left; max-width: none; min-height: 0; }
}

/* ---------- notes ---------- */
.note-group h3 { margin: 20px 4px 6px; font-size: 19px; font-weight: 700; }
.note-group:first-child h3 { margin-top: 0; }
.detail-section .note-group h3 { margin: 10px 2px 4px; font-size: 13px; color: var(--muted); }
.note-list { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.note-row {
  display: flex; flex-direction: column; gap: 2px; width: 100%;
  padding: 10px 16px; border: 0; border-bottom: 1px solid var(--border);
  background: transparent; text-align: left; cursor: pointer;
}
.note-row:last-child { border-bottom: 0; }
.note-row:hover { background: var(--surface-2); }
.note-title { display: flex; align-items: center; gap: 4px; font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-title .pin { width: 14px; height: 14px; color: var(--accent); }
.note-sub { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-time { color: var(--text); margin-right: 4px; }
.note-for { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.note-for svg { width: 12px; height: 12px; }

.note-sheet { display: flex; flex-direction: column; min-height: min(78vh, 680px); }
.note-bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 2px; padding: 10px 10px 6px; background: var(--surface); }
.note-bar .spacer { flex: 1; }
.note-btn { display: inline-flex; align-items: center; gap: 2px; padding: 6px 8px; border: 0; border-radius: 8px; background: transparent; color: var(--accent); font-size: 17px; cursor: pointer; }
.note-btn:hover { background: var(--surface-2); }
.note-btn svg { width: 22px; height: 22px; }
.note-btn.back { max-width: 55%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.note-btn.back svg { width: 24px; height: 24px; stroke-width: 2.5; }
.note-btn.done { font-weight: 600; }
.note-btn.on svg { fill: var(--accent); }
.note-meta { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 2px 20px 8px; font-size: 13px; color: var(--muted); }
.note-link { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); }
.note-link svg { width: 14px; height: 14px; }
.note-link select { max-width: 200px; padding: 3px 0; border: 0; background: transparent; color: var(--text); font-size: 13px; }

/* ---------- note editor (text + sketches) ---------- */
.ne { display: flex; flex-direction: column; }
.ne-text { min-height: 1.6em; padding: 2px 0; font-size: 17px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; outline: none; cursor: text; }
.ne-text.is-empty[data-ph]::before { content: attr(data-ph); color: var(--muted); pointer-events: none; }
#note-editor { flex: 1; padding: 6px 20px 24px; min-height: 45vh; }
#note-editor .ne-text:first-child::first-line { font-size: 1.55em; font-weight: 700; line-height: 1.3; }
#note-editor .ne-text:last-child { flex: 1; min-height: 6em; }
.ne-sketch { position: relative; margin: 8px 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); overflow: hidden; }
svg.sk-svg { display: block; width: 100%; height: auto; color: var(--text); }
.sk-svg path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ne-sketch-tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; }
.ne-sketch-tools button { padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; }
.ne-sketch-tools button:last-child { color: var(--danger); }
.note-toolbar { position: sticky; bottom: 0; display: flex; align-items: center; gap: 4px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-top: 1px solid var(--border); }
.note-toolbar .spacer { flex: 1; }
.note-toolbar .note-btn { gap: 6px; font-size: 15px; font-weight: 600; }
.note-btn.recording { color: var(--danger); background: var(--danger-soft); }
.voice-open { width: 100%; min-height: 58px; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 0; background: var(--surface-2); color: var(--text); font: inherit; font-weight: 650; text-align: left; }
.voice-open span { margin-left: auto; color: var(--muted); font-weight: 500; }
#voice-player { position: fixed; z-index: 120; top: calc(64px + env(safe-area-inset-top, 0px)); right: 10px; width: min(360px, calc(100vw - 20px)); display: grid; grid-template-columns: 1fr repeat(4, 42px); grid-template-rows: auto auto; align-items: center; padding: 8px; border: 1px solid var(--accent); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
#voice-player .vp-name { grid-column: 1; grid-row: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text); font-weight: 700; }
#voice-player .vp-count { grid-column: 1; grid-row: 2; color: var(--muted); font-size: 12px; }
#voice-player button { grid-row: 1 / 3; min-width: 40px; min-height: 40px; border: 0; border-radius: 50%; background: transparent; color: var(--accent); font-size: 17px; }
#voice-player button:hover { background: var(--accent-soft); }
.note-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.note-box { border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); overflow: hidden; }
#order-note { padding: 8px 12px; min-height: 90px; color: var(--text); }
#order-note .ne-text { font-size: 15px; }
#order-note .ne-text:last-child { min-height: 3em; }
.note-box-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 12px; border-top: 1px solid var(--border); background: var(--surface); }
.note-preview { display: flex; flex-direction: column; gap: 8px; }
.note-preview p { margin: 0; }
.sk-view { border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); overflow: hidden; max-width: 520px; }

/* note list rows with sketch thumbnails */
.note-row { flex-direction: row; align-items: center; gap: 12px; }
.note-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.note-tags { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.note-thumb { flex: none; width: 64px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); overflow: hidden; }

/* ---------- sketch pad ---------- */
#sketch { width: min(980px, calc(100vw - 32px)); height: min(820px, calc(100dvh - 32px)); max-width: none; max-height: none; padding: 0; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); }
#sketch::backdrop { background: var(--backdrop, rgba(0, 0, 0, .5)); }
.sk { display: flex; flex-direction: column; height: 100%; }
.sk-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.sk-bar .note-btn { padding: 6px 10px; }
.sk-hist { display: flex; gap: 4px; }
.sk-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 6px; background: var(--bg); }
#sk-canvas { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; touch-action: none; cursor: crosshair; box-shadow: var(--shadow); }
.sk-tools { display: flex; align-items: center; justify-content: safe center; gap: 4px; padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.sk-sep { flex: none; width: 1px; height: 18px; background: var(--border); margin: 0 2px; }
.sk-ink, .sk-w { flex: none; display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 2px solid transparent; border-radius: 50%; background: var(--surface-2); cursor: pointer; }
.sk-ink span { width: 16px; height: 16px; border-radius: 50%; }
.sk-icon { flex: none; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text); cursor: pointer; }
.sk-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sk-icon.on { background: var(--accent); color: var(--accent-text); }
.sk-w span { border-radius: 50%; background: var(--text); }
.sk-ink.on, .sk-w.on { border-color: var(--accent); }
@media (max-width: 760px) {
  .note-sheet { min-height: 100dvh; }
}
@media (max-width: 640px) {
  #sketch { width: 100vw; height: 100dvh; border: 0; border-radius: 0; }
  .sk-stage { padding: 4px; }
}

/* ---------- proportional body figure ---------- */
.measure-layout { grid-template-columns: minmax(200px, 270px) minmax(0, 1fr); }
.figure-wrap { position: sticky; }
.figure-wrap .fig-expand {
  position: absolute; top: 0; right: 0; z-index: 1; display: grid; place-items: center;
  width: 34px; height: 34px; padding: 0; border: 1px solid var(--border); border-radius: 50%;
  background: var(--surface); color: var(--text); cursor: pointer;
}
.figure-wrap .fig-expand svg { width: 16px; height: 16px; }
.body-stage { max-width: 250px; max-height: 64vh; }
.body-fig .skin, .body-fig .mk-line, .body-fig .mk-hit { vector-effect: non-scaling-stroke; }
.body-fig .mk-label { fill: var(--accent); font-weight: 400; paint-order: stroke; stroke: var(--surface); stroke-width: 1px; stroke-linejoin: round; vector-effect: non-scaling-stroke; pointer-events: none; }
.body-fig .mk-label.inline { stroke-width: 7px; } /* cuts a gap in its line */
@media (max-width: 640px) {
  .measure-layout { grid-template-columns: 1fr; }
  .figure-wrap { position: relative; top: auto; z-index: 0; }
  .figure-wrap .fig-expand { top: 6px; right: 0; }
  .body-stage { max-width: 112px; }
}

/* ---------- full-screen viewer ---------- */
#viewer { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; border-radius: 0; background: var(--surface); color: var(--text); }
#viewer::backdrop { background: var(--surface); }
.viewer { display: flex; flex-direction: column; height: 100%; }
.viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); border-bottom: 1px solid var(--border); }
.viewer-body { flex: 1; min-height: 0; overflow: auto; }
.body-viewer { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: 16px; height: 100%; padding: 16px; }
.bv-figure { display: flex; justify-content: center; min-height: 0; }
.bv-figure .body-stage { max-width: none; max-height: none; width: auto; height: 100%; min-height: 420px; }
.bv-side { display: flex; flex-direction: column; gap: 12px; overflow: auto; }
.bv-side .figure-caption { text-align: left; max-width: none; min-height: 0; }
@media (max-width: 760px) {
  .body-viewer { grid-template-columns: 1fr; height: auto; }
  .bv-figure .body-stage { width: 100%; height: auto; min-height: 0; max-height: 78dvh; }
}
.photo-viewer { position: relative; display: grid; place-items: center; height: 100%; padding: 12px; background: var(--bg); }
.photo-viewer img { max-width: 100%; max-height: calc(100dvh - 90px); object-fit: contain; border-radius: 8px; }
.photo-save { position: absolute; top: 12px; left: 12px; z-index: 2; }
.cloud-backup-row > span:first-child { display: flex; flex-direction: column; gap: 2px; }
.cloud-backup-row small { color: var(--muted); }
.cloud-backup-row .btn-row { margin: 0; flex-wrap: nowrap; }

/* ---------- photos in notes ---------- */
.ne-photo { position: relative; margin: 8px 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); overflow: hidden; }
.ne-photo img { display: block; width: 100%; max-height: 440px; object-fit: contain; }
img[data-photo][data-state="loading"], img[data-photo]:not([src]) { min-height: 80px; background: var(--surface-2); }
img[data-photo][data-state="missing"] { min-height: 60px; }
.ph-view { display: block; padding: 0; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); overflow: hidden; cursor: zoom-in; max-width: 520px; }
.ph-view img { display: block; width: 100%; max-height: 360px; object-fit: cover; }
.note-thumb img { display: block; width: 64px; height: 48px; object-fit: cover; }
.note-thumb .sk-svg { height: 48px; }

/* ---------- full-screen measuring ---------- */
.mv .viewer-bar { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; min-height: 58px; padding-block: 8px; }
.mv-close {
  display: grid; place-items: center; flex: none; width: 36px; height: 36px;
  padding: 0; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); font-size: 24px; line-height: 1; cursor: pointer;
}
.mv-person { grid-column: 2; display: flex; flex-direction: column; min-width: 0; text-align: center; }
.mv-person strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.mv-person span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; }
.mv .viewer-bar > :last-child { justify-self: end; }
.mv-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(290px, 340px);
  grid-template-rows: minmax(0, 1fr) 196px;
  gap: 10px; height: 100%; padding: 10px; overflow: hidden;
  background: var(--bg);
}
.mv-body .bv-figure { grid-column: 1; grid-row: 1; overflow: hidden; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.mv-figure-wrap { position: relative; touch-action: none; cursor: grab; }
.mv-figure-wrap:active { cursor: grabbing; }
.zoom-btns { position: absolute; right: 8px; bottom: 8px; z-index: 2; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: color-mix(in srgb, var(--surface) 92%, transparent); }
.zoom-btns button { width: 36px; height: 36px; border: 0; background: none; color: var(--text); font-size: 20px; line-height: 1; cursor: pointer; }
.zoom-btns button + button { border-top: 1px solid var(--border); }
.zoom-btns button:disabled { color: var(--muted); opacity: .45; cursor: default; }
#mv-figure { display: flex; justify-content: center; width: 100%; height: 100%; min-height: 0; }
.mv-body .bv-figure .body-stage { height: 100%; width: auto; max-width: none; max-height: none; min-height: 420px; transform-origin: center; transition: transform .18s ease; }
.mv-body .bv-side {
  grid-column: 2; grid-row: 1; overflow: hidden;
  display: flex; flex-direction: column; gap: 8px;
  padding: 8px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface);
}
.mv-panel { grid-column: 2; grid-row: 2; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.mv-panel .btn { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
#mv-start { width: 100%; margin-top: auto; line-height: 1.2; }
.mv-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.mv-head strong { font-size: 18px; }
.mv-how { margin: 0; font-size: 13px; color: var(--muted); }
.mv-system-note { margin: 0; font-size: 13px; color: var(--text); }
.mv-value { margin: 0; font-weight: 600; }
.mv-next-top { width: 100%; min-height: 40px; font-size: 15px; }
.mv-entry-row { width: 100%; }
.mv-entry-row .measure-input { width: 100%; }
.mv-entry-row .measure-input input { padding: 10px 12px; border: 1px solid var(--accent); border-radius: 9px 0 0 9px; background: var(--surface); color: var(--text); font-size: 20px; font-weight: 600; width: 100%; }
.mv-entry-row .unit-btn { border-radius: 0 9px 9px 0; }
.mv-entry-row .measure-input-pair {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 5px;
}
.mv-entry-row .measure-input-pair input { width: 100%; min-width: 0; border-radius: 9px !important; }
.mv-entry-row .measure-input-pair .measure-first { grid-column: 1; grid-row: 1; border: 1px solid var(--border); }
.mv-entry-row .measure-input-pair .measure-second { grid-column: 1; grid-row: 2; border: 1.5px solid color-mix(in srgb, var(--accent) 68%, var(--border)); }
.mv-entry-row .measure-input-pair .unit-btn {
  grid-column: 2; grid-row: 1 / 3; min-width: 42px; border: 1px solid var(--border); border-radius: 9px;
}
.mv-part-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 4px; }
.mv-part-row strong { min-width: 0; font-size: 18px; }
.mv-row { display: flex; align-items: stretch; gap: 8px; }
.mv-row .measure-input { flex: 1; min-width: 0; }
.mv-row .measure-input input { padding: 10px 12px; border: 1px solid var(--accent); border-radius: 9px 0 0 9px; background: var(--surface); color: var(--text); font-size: 20px; font-weight: 600; width: 100%; }
.mv-row .unit-btn { border-radius: 0 9px 9px 0; }
.mv-row .btn { padding: 8px 14px; }
.mv-row .btn:disabled { opacity: .4; }
#mv-list .measure-table div.empty strong { color: var(--muted); font-weight: 500; }
#mv-list { flex: 1; min-height: 0; overflow: auto; padding-right: 2px; }
#mv-list .measure-table { grid-template-columns: 1fr; }
.mv-keyboard {
  grid-column: 1; grid-row: 2;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px;
  padding: 8px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface);
}
.mv-keyboard button {
  min-height: 42px; padding: 6px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); font-size: 19px; font-weight: 650;
  font-variant-numeric: tabular-nums; cursor: pointer; touch-action: manipulation;
}
.mv-keyboard button:hover { border-color: var(--accent); background: var(--accent-soft); }
.mv-keyboard button:active { transform: translateY(1px); }
.mv-keyboard button[data-mv-key="backspace"] { color: var(--accent); }
.m-empty { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
@media (max-width: 760px) {
  .mv .viewer-bar { min-height: 54px; padding-inline: 8px; gap: 7px; }
  .mv-close { width: 34px; height: 34px; }
  .mv-person { max-width: 42vw; }
  .mv-person strong { font-size: 14px; }
  .mv-body {
    grid-template-columns: minmax(0, 1fr) 148px;
    grid-template-rows: minmax(0, 1fr) 178px;
    height: 100%; padding: 6px; gap: 6px;
  }
  .mv-body .bv-side { grid-column: 2; grid-row: 1; position: static; padding: 5px; gap: 5px; overflow: hidden; }
  .mv-panel { grid-column: 2; grid-row: 2; gap: 5px; padding: 8px; }
  #mv-start { min-height: 40px; padding: 7px 5px; font-size: 12px; }
  .mv-panel { gap: 5px; padding: 8px; }
  .mv-head { align-items: flex-start; }
  .mv-head strong { font-size: 14px; line-height: 1.2; }
  .mv-next-top { min-height: 38px; padding: 7px; }
  .mv-entry-row .measure-input input { padding: 8px; font-size: 17px; }
  .mv-part-row strong { font-size: 15px; line-height: 1.2; }
  .mv-how, .mv-system-note { font-size: 10px; line-height: 1.3; }
  .mv-row { display: grid; grid-template-columns: 1fr auto; gap: 4px; }
  .mv-row .measure-input { grid-column: 1 / -1; }
  .mv-row .measure-input input { padding: 8px; font-size: 17px; }
  .mv-row #mv-next { grid-column: 1 / -1; padding: 7px; }
  #mv-list .measure-table { grid-template-columns: 1fr; gap: 3px; }
  #mv-list .measure-table div { padding: 5px 6px; font-size: 10px; }
  #mv-list .m-group-title { margin-bottom: 4px; font-size: 9px; }
  #mv-figure { height: 100%; }
  .mv-body .bv-figure .body-stage { width: auto; height: 100%; min-height: 0; max-width: 100%; max-height: 100%; }
  .mv-keyboard { gap: 4px; padding: 5px; border-radius: 10px; }
  .mv-keyboard button { min-height: 38px; padding: 4px; border-radius: 8px; font-size: 18px; }
}

/* ---------- phones & touch screens: tap targets ≥ 44px ---------- */
/* Placed after the view rules above so it wins at equal specificity. Inputs go to 16px so
   iPhone Safari doesn't zoom in on focus. Small round icons keep their look and get an
   invisible 44px hit area instead. */
@media (max-width: 760px), (pointer: coarse) {
  .btn, .btn.small, .chip, .seg button, .stepper button, .icon-btn,
  .today-stat, .note-btn, .le-display, .le-line, .mv-close, #mv-start, .mv-next-top,
  .zoom-btns button, .le-all-style summary, .line-editor-row summary, .ne-sketch-tools button { min-height: 44px; }
  .icon-btn, .mv-close, .zoom-btns button { min-width: 44px; }
  .mv-close { width: 44px; height: 44px; }
  .zoom-btns button { width: 44px; height: 44px; }
  .field input, .field select, .search,
  .le-controls .field input, .le-controls .field select,
  .le-all-grid input, .le-all-grid select, .le-active-picker select { min-height: 44px; font-size: 16px; }
  .measure-input .unit-btn { min-width: 44px; }
  .measure-table div[data-key], #mv-list .measure-table div { min-height: 44px; align-items: center; }
  .le-choice { min-height: 44px; }
  .note-link { min-height: 44px; }
  .note-link select { min-height: 40px; font-size: 16px; }
  .sk-ink, .sk-w, .sk-icon { width: 44px; height: 44px; }
  .note-btn { min-width: 44px; justify-content: center; }
  .le-controls .field input[type="range"], .le-all-grid input[type="range"], .line-editor-fields input[type="range"] { min-height: 44px; }
  .mv-keyboard button { min-height: 44px; }
  .mv-body { grid-template-rows: minmax(0, 1fr) 202px; } /* 4 key rows × 44px + gaps */
  /* hit areas grow left and down only, so they never stick out past a dialog's right edge */
  .sync::after, .fig-expand::after { content: ""; position: absolute; inset: -5px 0 -5px -10px; }
  .fig-expand { position: relative; }
  .figure-wrap .fig-expand { position: absolute; }
}

/* Money summary: three boxes don't fit a 360px phone with long amounts — keep each
   amount on one line ("45,000 Ks", never "Ks" alone) and go to two columns. */
.money-box div { min-width: 0; }
.money-box strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 420px) {
  .money-box { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .money-box div:last-child { grid-column: 1 / -1; }
  .money-box strong { font-size: 17px; }
}
/* payment row: date on the left; amount and its × together on the right */
.payments li > span:first-child { min-width: 0; }
.payments li > span:last-child { display: inline-flex; align-items: center; gap: 2px; flex: none; white-space: nowrap; }

/* Phones: list rows show two lines of detail instead of cutting off the due date. */
@media (max-width: 760px) {
  .row-title, .row-sub {
    white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  }
  /* measuring list (148px column): label on its own line, values below, the same for every row */
  #mv-list .measure-table div { flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; }
}

/* Tablet widths (761–1100px): six labelled nav buttons and the shop name don't fit in one
   row, so the labels go under the icons, as in the phone bottom bar. */
@media (min-width: 761px) and (max-width: 1100px) {
  .topbar { gap: 12px; padding-inline: 16px; }
  .nav { gap: 0; }
  .nav button { flex-direction: column; gap: 2px; min-width: 64px; padding: 5px 6px; font-size: 11px; }
}

/* Floating "New order" button: it must not cover the right end of list rows (status pills).
   Wide screens: it fits in the margin beside the 1040px column. Narrower: icon only, and
   below 1180px the content leaves a lane for it on the right. */
@media (min-width: 761px) and (max-width: 1379px) {
  .fab { padding: 16px; }
  .fab span { display: none; }
}
@media (min-width: 761px) and (max-width: 1179px) {
  main { padding-right: 96px; }
}

/* ---------- print ---------- */
#print-area { display: none; }
@media print {
  body { background: #fff; color: #000; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; font-size: 13px; color: #000; }
  #print-area h1 { font-size: 20px; margin: 0; }
  #print-area .p-head { display: flex; justify-content: space-between; border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 12px; }
  #print-area table { width: 100%; border-collapse: collapse; margin: 8px 0 14px; }
  #print-area td, #print-area th { border: 1px solid #999; padding: 5px 8px; text-align: left; }
  #print-area h4 { margin: 14px 0 4px; }
}

/* ---------- sync badge ---------- */
/* sync state icon in the top bar (words in its tooltip) */
.sync { position: relative; flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: var(--ok); background: var(--ok-soft); }
.sync:empty { display: none; }
.sync svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sync.busy { color: var(--accent); background: var(--accent-soft); }
.sync.warn { color: var(--warn); background: var(--warn-soft); }
.sync.bad { color: var(--danger); background: var(--danger-soft); }
.sync.spin svg { animation: sync-spin 1.1s linear infinite; }
@keyframes sync-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .sync.spin svg { animation: none; } }
.sync b { position: absolute; top: -3px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: currentColor; font: 700 10px/17px system-ui, sans-serif; text-align: center; }
.sync b { color: var(--surface); background: var(--accent); }
.sync.warn b { background: var(--warn); }
.bad-text { color: var(--danger); }

/* ---------- account ---------- */
.acct-tabs { margin: 4px 0 12px; }
.acct-tabs button.on { background: var(--accent); color: var(--accent-text); }
.acct-form { margin-top: 8px; }
.acct-email { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--accent-soft); }
.acct-email p { margin: 0 0 8px; }
.acct-more { margin-top: 12px; }
.acct-more summary { cursor: pointer; font-weight: 600; color: var(--text); }
.acct-welcome { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; border-color: var(--accent); background: var(--accent-soft); }
.acct-welcome p { margin: 4px 0 0; color: var(--muted); }
#sync { cursor: pointer; margin-left: auto; }
/* account and transfer forms stay a comfortable width on wide screens */
.acct-form { max-width: 560px; }

/* Device access: the website joins Zune in the same way as the Android app. */
body.access-locked .topbar, body.access-locked .fab { display: none; }
body.access-locked main { display: grid; min-height: 100dvh; padding: 24px; place-items: center; }
.access-page { width: min(100%, 480px); padding: 28px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.access-page > img { display: block; width: 84px; height: 84px; margin: 0 auto 14px; border-radius: 20px; }
.access-page h1 { margin: 0 0 18px; text-align: center; }
.access-page > p, .access-form p { color: var(--muted); font-size: 15px; }
.access-form { display: grid; gap: 14px; margin-top: 18px; }
.access-form .btn { min-height: 48px; justify-content: center; }
.st-device-name { margin: 0 0 10px; font-size: 18px; }
.access-role-list { display: grid; gap: 8px; margin: 10px 0 14px; max-width: 560px; }
.access-role-list label { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.access-role-list label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.access-role-list input { accent-color: var(--accent); }
.pairing-code { display: grid; gap: 4px; margin-top: 14px; padding: 18px; border-radius: var(--radius); background: var(--accent-soft); text-align: center; }
.pairing-code strong { color: var(--accent); font-size: clamp(32px, 8vw, 46px); letter-spacing: .12em; }
.pairing-code span, .device-row span { color: var(--muted); font-size: 14px; }
.device-list { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); }
.device-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; padding: 10px 12px; border-top: 1px solid var(--border); }
.device-row:first-child { border-top: 0; }
.device-row > div:first-child { display: grid; gap: 2px; }
@media (max-width: 520px) { .access-page { padding: 22px 18px; } .device-row { align-items: flex-start; flex-direction: column; } }

/* settings — owned by CL-4 (website Settings); add nothing below this line from other blocks */
/* Settings home list + one page. Phones: list OR page (Back button). ≥600px: list left, page right. */
.st { display: grid; gap: 20px; align-items: start; }
.st-h1 { margin: 0 0 14px; font-size: 24px; }
.st-list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.st-row { display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 10px 14px; border: 0; border-top: 1px solid var(--border); background: transparent; color: var(--text); text-align: left; font: inherit; cursor: pointer; }
.st-row:first-child { border-top: 0; }
.st-row:hover { background: var(--surface-2); }
.st-row:focus-visible, .st-back:focus-visible, .st-swatch:focus-visible, .st-choice:focus-visible, .st-choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.st-icon { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.st-icon svg, .st-chev, .st-back svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.st-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.st-row-title { font-size: 16px; font-weight: 600; }
.st-row-value { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-chev { flex: none; color: var(--muted); }

.st-page { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 18px 22px; min-width: 0; }
.st-back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; margin: -8px 0 4px -8px; padding: 0 12px 0 4px; border: 0; border-radius: 8px; background: transparent; color: var(--accent); font: inherit; font-size: 16px; font-weight: 600; cursor: pointer; }
.st-back:hover { background: var(--accent-soft); }
.st-title { margin: 0 0 16px; font-size: 22px; color: var(--text); text-transform: none; letter-spacing: 0; }
.st-section { margin-top: 22px; }
.st-title + .st-section, .st-title + .st-note + .st-section { margin-top: 0; }
.st-section h3 { margin: 0 0 10px; font-size: 16px; }
.st-h4 { margin: 18px 0 4px; font-size: 15px; }
.st-note { margin: 0 0 12px; color: var(--muted); font-size: 15px; }
.st-page .btn { min-height: 44px; font-size: 15px; }
.st-wide { width: 100%; max-width: 360px; justify-content: center; }

/* Look: colour swatches */
.st-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.st-swatch { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border: 2px solid transparent; border-radius: var(--radius); background: transparent; color: var(--text); font: inherit; font-size: 15px; cursor: pointer; }
.st-swatch:hover { background: var(--surface-2); }
.st-swatch.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.st-dot { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--border); background: linear-gradient(135deg, var(--sw-bg) 0 50%, var(--sw-accent) 50% 100%); }

/* Big one-of-many choices (Light/Dark/Same as phone, Centimetres/Inches, Sign in/First time) */
.st-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.st-choice { position: relative; display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 18px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font: inherit; font-size: 15px; font-weight: 500; cursor: pointer; }
.st-choice:hover { background: var(--surface-2); }
.st-choice.on, .st-choice:has(input:checked) { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.st-choice input { position: absolute; opacity: 0; pointer-events: none; }
.acct-tabs.st-choices { margin: 0 0 12px; }
.acct-tabs .st-choice.on { background: var(--accent); color: var(--accent-text); }

/* Measurements: extra list + add */
.st-items { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; max-width: 480px; }
.st-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 52px; padding: 0 6px 0 14px; border-top: 1px solid var(--border); font-size: 15px; }
.st-item:first-child { border-top: 0; }
.st-none { color: var(--muted); }
.st-x { flex: none; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; cursor: pointer; }
.st-x:hover { background: var(--danger-soft); color: var(--danger); }
.st-add { display: flex; gap: 8px; margin-top: 10px; max-width: 480px; }
.st-add .search { flex: 1; min-width: 0; min-height: 44px; font-size: 15px; }
.st-switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; max-width: 480px; font-size: 16px; font-weight: 500; cursor: pointer; }
.st-switch input { appearance: none; flex: none; position: relative; width: 52px; height: 30px; margin: 0; border-radius: 999px; background: var(--border); cursor: pointer; transition: background .15s; }
.st-switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow); transition: transform .15s; }
.st-switch input:checked { background: var(--accent); }
.st-switch input:checked::after { transform: translateX(22px); }
.st-switch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Business / About fields */
.st-fields { display: grid; gap: 14px; max-width: 480px; }
.st-page .field { font-size: 15px; }
.st-page .field input { font-size: 16px; min-height: 44px; }
.st-page .hint { font-size: 14px; }
.st-fixed { padding: 10px 0; font-size: 16px; font-weight: 600; color: var(--text); }

/* Phones & tablets: save status */
.st-status { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 12px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.st-status svg { flex: none; width: 32px; height: 32px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.st-status div { display: flex; flex-direction: column; gap: 2px; font-size: 16px; }
.st-status span { font-size: 14px; color: var(--muted); }
.st-status.synced { background: var(--accent-soft); border-color: transparent; }
.st-status.synced svg { color: var(--accent); }
.st-status.pending svg, .st-status.syncing svg { color: var(--info); }
.st-status.offline svg { color: var(--warn); }
.st-status.problem { background: var(--danger-soft); border-color: transparent; }
.st-status.problem svg { color: var(--danger); }

/* Phones: one at a time */
@media (max-width: 599.98px) {
  .st:not(.st-open) .st-page { display: none; }
  .st.st-open .st-home { display: none; }
  .st-page { padding: 14px 14px 20px; }
}
/* Tablets and computers: list left, page right */
@media (min-width: 600px) {
  .st { grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); }
  .st-home { position: sticky; top: 12px; }
  .st-back { display: none; }
  .st-row.on { background: var(--accent-soft); }
  .st-row.on .st-row-title { color: var(--accent); }
}

/* orders filter dropdown */
.of-dd { position: relative; width: 100%; }
@media (min-width: 600px) { .of-dd { width: 320px; } }
.of-btn {
  display: flex; align-items: center; gap: 6px; width: 100%; min-height: 48px; padding: 10px 12px 10px 14px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text);
  font: inherit; font-size: 16px; text-align: left; cursor: pointer;
}
.of-btn:hover { border-color: var(--muted); }
.of-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.of-dd.open .of-btn { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.of-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.of-n { color: var(--muted); white-space: nowrap; }
.of-chev { flex: none; width: 22px; height: 22px; margin-left: auto; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.of-dd.open .of-chev { transform: rotate(180deg); }
.of-list {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; right: 0; min-width: 240px;
  max-height: min(65vh, 560px); overflow-y: auto; margin: 0; padding: 6px; list-style: none;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.of-list[hidden] { display: none; }
.of-opt {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 12px 0 8px;
  border-radius: 8px; font-size: 16px; cursor: pointer; outline: none;
}
.of-opt:hover, .of-opt:focus { background: var(--surface-2); }
.of-opt:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.of-opt.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.of-tick { flex: none; width: 20px; height: 20px; display: inline-flex; }
.of-tick svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.of-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.of-count { flex: none; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.of-opt.on .of-count { color: var(--accent); }

/* schedule calendar */
.sched { max-width: 720px; margin: 0 auto; }
.sched-mode { display: flex; width: 100%; margin-bottom: 16px; border-radius: 10px; }
.sched-mode button { flex: 1; min-height: 44px; font-size: 15px; font-weight: 600; }
.sched-month { display: flex; align-items: center; gap: 10px; margin: 22px 0 10px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.sched-month::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.day-head.sched-today { color: var(--accent); }
.sched-overdue { display: block; width: 100%; margin-bottom: 12px; padding: 10px 14px; border: 0; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font: inherit; font-size: 14px; font-weight: 600; text-align: left; cursor: pointer; }
.sched-cal-wrap { display: flex; flex-direction: column; gap: 16px; }
.sched-cal { padding: 8px; width: 100%; max-width: 480px; margin: 0 auto; box-sizing: border-box; }
.sched-cal-head { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.sched-cal-title { flex: 1; min-width: 0; text-align: center; font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sched-nav { width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; background: transparent; color: var(--text); font-size: 26px; font-weight: 700; line-height: 1; cursor: pointer; }
.sched-nav:hover { background: var(--surface-2); }
.sched-today-btn { flex: none; min-height: 40px; color: var(--accent); }
.sched-weekdays, .sched-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.sched-weekdays div { text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); padding: 4px 0; }
.sched-cell { aspect-ratio: 1; min-height: 40px; margin: 2px; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font: inherit; cursor: pointer; }
.sched-cell.blank { cursor: default; }
.sched-cell:not(.blank):hover { background: var(--surface-2); }
.sched-cell .n { font-size: 15px; font-weight: 500; line-height: 1; }
.sched-cell.past { color: var(--muted); }
.sched-cell.today { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.sched-cell.today .n, .sched-cell.sel .n { font-weight: 700; }
.sched-cell.sel, .sched-cell.sel:hover { background: var(--accent); color: var(--accent-text); box-shadow: none; }
.sched-cell .dots { display: flex; gap: 3px; height: 7px; }
.sched i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
.sched i.fit { background: var(--warn); }
.sched i.due { background: var(--info); }
.sched-cell.sel i { background: var(--accent-text); }
.sched-legend { display: flex; justify-content: center; gap: 16px; margin: 8px 0 4px; font-size: 12px; color: var(--muted); }
.sched-legend span { display: inline-flex; align-items: center; gap: 5px; }
.sched-day-list { margin-bottom: 0; }
/* wide screens: the calendar beside the chosen day's list */
@media (min-width: 900px) {
  .sched:has(.sched-cal-wrap) { max-width: 1000px; }
  .sched-cal-wrap { flex-direction: row; align-items: flex-start; }
  .sched-cal { flex: 0 1 460px; margin: 0; }
  .sched-day-list { flex: 1; min-width: 0; }
}

/* print: voice notes */
/* The slip prints each voice note as one plain muted line (printBlocks in app.js).
   Safety net: if a .voice-open button ever reaches the slip, drop its button look. */
@media print {
  #print-area .p-voice { margin: 4px 0; color: #555; }
  #print-area .voice-open { display: block; width: auto; min-height: 0; margin: 4px 0; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; color: #555; font: inherit; text-align: left; }
  #print-area .voice-open svg { display: none; }
}

/* Voice notes: shared recording, row and player design. */
.note-toolbar { gap: 2px; padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px)); }
.note-box-tools { gap: 2px; padding: 6px; flex-wrap: wrap; }
.note-box-tools > .hint { flex: 1 0 100%; text-align: center; }
.note-toolbar > .note-btn, .note-box-tools > .note-btn { flex: 1 1 0; min-width: 0; min-height: 56px; padding: 4px 2px; flex-direction: column; justify-content: center; gap: 4px; font-size: 13px; line-height: 18px; white-space: nowrap; }
.note-toolbar > .note-btn svg, .note-box-tools > .note-btn svg { width: 24px; height: 24px; flex: none; }
.note-toolbar > .note-btn[data-action="record-voice"], .note-box-tools > .note-btn[data-action="record-voice"] { color: var(--accent); background: transparent; border-radius: 14px; }
.note-toolbar > .spacer { display: none; }
.voice-row { display: flex; align-items: center; min-height: 64px; margin: 4px 0; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.voice-row .voice-open { flex: 1; min-width: 0; min-height: 64px; display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 14px; background: transparent; color: var(--text); }
.voice-row .voice-open span { margin-left: 0; }
.voice-row .voice-mic { flex: none; width: 22px; color: var(--accent); }
.voice-row .voice-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.voice-copy strong { color: var(--text); font-size: 16px; line-height: 22px; }
.voice-row .voice-status { font-size: 14px; line-height: 20px; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 400; text-align: left; }
.voice-row .voice-play { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 50%; color: var(--accent); background: var(--accent-soft); }
.voice-row svg, .voice-recording svg, .voice-saved svg, #voice-player svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.voice-row .voice-remove { display: grid; place-items: center; flex: none; min-width: 48px; min-height: 48px; margin-right: 4px; padding: 10px; border: 0; border-radius: 10px; color: var(--danger); background: transparent; }
.voice-row .voice-remove svg { width: 20px; height: 20px; }
.voice-row .voice-retry { display: none; }
.voice-row.missing .voice-play { display: none; }
.voice-row.missing .voice-retry { display: grid; place-items: center; flex: none; min-height: 48px; padding: 0 8px; color: var(--accent); font-size: 15px; font-weight: 600; }
.voice-row.playing { border-color: var(--accent); background: var(--accent-soft); }
.voice-row.playing .voice-play { color: var(--accent-text); background: var(--accent); }
.voice-row.playing .voice-status { color: var(--accent); }
.voice-row.missing .voice-mic, .voice-row.missing strong { color: var(--muted); }
.note-toolbar:has(> .voice-recording), .note-box-tools:has(> .voice-recording) { background: var(--danger-soft); border-top: 1px solid var(--danger); }
.note-toolbar:has(> .voice-saved), .note-box-tools:has(> .voice-saved) { background: var(--accent-soft); border-top: 1px solid var(--accent); }
.voice-recording, .voice-saved { flex: 1; min-height: 64px; display: flex; align-items: center; gap: 12px; padding: 4px 4px 4px 12px; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.voice-recording > span:nth-child(2) { flex: 1; color: var(--danger); font-size: 17px; }
.voice-dot { flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: voice-pulse 1s ease-in-out infinite alternate; }
@keyframes voice-pulse { from { opacity: 1; transform: scale(1); } to { opacity: .35; transform: scale(.85); } }
@media (prefers-reduced-motion: reduce) { .voice-dot { animation: none; } }
.voice-recording button { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 112px; min-height: 48px; padding: 0 18px; border: 0; border-radius: 24px; background: var(--danger); color: var(--surface); font: inherit; font-weight: 700; }
.voice-recording button svg { width: 20px; height: 20px; }
.voice-saved { color: var(--accent); }
#voice-player { top: calc(72px + env(safe-area-inset-top, 0px)); right: 8px; width: min(360px, calc(100vw - 16px)); height: 72px; display: flex; flex-direction: row; align-items: center; gap: 4px; padding: 0 4px 0 14px; border: 1px solid var(--accent); border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); z-index: 130; }
#voice-player .vp-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#voice-player .vp-name { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 15px; font-weight: 600; line-height: 20px; }
#voice-player .vp-progress { display: flex; align-items: center; gap: 8px; }
#voice-player button { display: grid; place-items: center; flex: none; padding: 0; border: 0; border-radius: 50%; background: transparent; }
#voice-player .vp-toggle { width: 52px; height: 52px; margin-left: 6px; background: var(--accent); color: var(--accent-text); }
#voice-player .vp-close { width: 48px; height: 48px; color: var(--muted); }
#voice-player [data-voice-seek] { flex: 1; min-width: 24px; height: 44px; margin: 0; -webkit-appearance: none; appearance: none; cursor: pointer;
  background: linear-gradient(var(--accent), var(--accent)) left center / var(--fill, 0%) 4px no-repeat, linear-gradient(var(--border), var(--border)) left center / 100% 4px no-repeat; }
#voice-player [data-voice-seek]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--accent); }
#voice-player [data-voice-seek]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--accent); }
#voice-player [data-voice-seek]::-moz-range-track { background: transparent; }
#voice-player .vp-time { flex: none; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
dialog #voice-player { top: calc(8px + env(safe-area-inset-top, 0px)); }
#modal:has(#voice-player) #modal-body { padding-top: 88px; }
body:has(> #voice-player) main { padding-top: 104px; }
.note-thumb > svg { display: block; width: 24px; height: 24px; margin: 12px 20px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (max-height: 480px) {
  #voice-player { height: 56px; }
  #voice-player .vp-progress { display: none; }
  #modal:has(#voice-player) #modal-body { padding-top: 72px; }
}
@media (hover: hover) {
  .voice-row .voice-open:hover, .voice-row .voice-remove:hover, #voice-player .vp-close:hover { background: var(--accent-soft); }
}
@media (hover: none) {
  .note-btn:hover, #voice-player .vp-close:hover { background: transparent; }
  .note-toolbar > .note-btn[data-action="record-voice"]:hover { background: transparent; }
}
@media print {
  #voice-player, .voice-recording, .voice-saved, .voice-remove { display: none !important; }
}
.ne-voice { margin: 4px 0; }
.voice-copy strong { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
/* voice notes: "allow the microphone" dialog (showMicHelp in app.js) */
#mic-help { width: min(400px, calc(100vw - 32px)); max-width: none; height: fit-content; max-height: calc(100dvh - 32px); margin: auto; inset: 0; padding: 20px; border: 0; border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
#mic-help::backdrop { background: rgba(0, 0, 0, .45); }
#mic-help h3 { margin: 0 0 8px; font-size: 18px; line-height: 1.3; }
#mic-help p { margin: 0 0 16px; color: var(--muted); line-height: 1.45; }
#mic-help .btn-row { justify-content: flex-end; }
#mic-help .btn { min-width: 96px; min-height: 48px; }

/* Order attachments stay directly below the three tabs while form content scrolls. */
.order-form-shell > .order-note-tools {
  flex: none; margin: 8px 14px; border: 1px solid var(--border);
  border-radius: 16px; flex-wrap: nowrap;
}
