  /* Elementa design-system tokens (from the Claude Design project
     "Bash Delivery Driver Scheduling" — Driver Scheduling v2). */
  :root {
    --em-background-primary: #fcfcfc;
    --em-background-secondary: #f1f1f1;
    --em-background-brand-primary: #4646e8;
    --em-background-brand-secondary: #5c58cf;
    --em-background-brand-tertiary: #cfd4ff;
    --em-background-inverse-primary: #040404;
    --em-background-success-tertiary: #bcffec;
    --em-background-error-tertiary: #ffe9e5;
    --em-background-scrim-primary: rgba(4, 4, 4, 0.7);
    --em-border-extra-light: rgba(4, 4, 4, 0.05);
    --em-border-light: rgba(4, 4, 4, 0.2);
    --em-border-brand-primary: #4646e8;
    --em-text-primary: #040404;
    --em-text-secondary: rgba(4, 4, 4, 0.7);
    --em-text-tertiary: rgba(4, 4, 4, 0.6);
    --em-text-brand-primary: #4646e8;
    --em-text-inverse-primary: #fcfcfc;
    --em-text-success-primary: #027e68;
    --em-text-error-primary: #cb0210;
    --em-states-hover: rgba(4, 4, 4, 0.1);
    --em-font-ui: "Inter", system-ui, sans-serif;
    --em-font-code: "Roboto Mono", monospace;
    --em-shadow-card: 0 2px 4px rgba(4, 4, 4, 0.1);
    --em-shadow-sheet: 0 8px 16px rgba(4, 4, 4, 0.4);
  }
  * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
  html, body { min-height: 100%; }
  body { overscroll-behavior-y: contain; }
  body {
    background: var(--em-background-secondary);
    color: var(--em-text-primary);
    font-family: var(--em-font-ui);
    -webkit-font-smoothing: antialiased;
    font-size: 14px; line-height: 20px; letter-spacing: -0.25px;
  }
  button { font-family: inherit; letter-spacing: -0.25px; cursor: pointer; }
  button:focus { outline: none; }
  button:focus-visible { outline: 2px solid var(--em-background-brand-primary); outline-offset: 2px; }
  .mono { font-family: var(--em-font-code); }
  [hidden] { display: none !important; }

  .shell { max-width: 480px; margin: 0 auto; min-height: 100vh; background: var(--em-background-secondary); display: flex; flex-direction: column; }

  /* ---------- header ---------- */
  header {
    background: var(--em-background-primary);
    border-bottom: 1px solid var(--em-border-extra-light);
    padding: 16px 16px 0; position: sticky; top: 0; z-index: 20;
  }
  .hd-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .hd-row img { height: 34px; border-radius: 8px; display: block; }
  .hd-id { display: flex; align-items: center; gap: 10px; }
  .hd-name { text-align: right; }
  .hd-name b { display: block; font-size: 14px; line-height: 18px; font-weight: 600; }
  .hd-name span { font-size: 12px; line-height: 14px; color: var(--em-text-tertiary); }
  .avatar {
    width: 40px; height: 40px; border-radius: 9999px; flex-shrink: 0;
    background: var(--em-background-brand-tertiary); color: var(--em-background-brand-primary);
    display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700;
    border: none;
  }
  .tabs { display: flex; margin-top: 14px; }
  .tabs button {
    flex: 1; height: 44px; background: none; border: none;
    border-bottom: 2px solid transparent;
    color: var(--em-text-secondary); font-size: 14px; font-weight: 600;
  }
  @media (hover: hover) { .tabs button:hover { background: var(--em-states-hover); } }
  .tabs button:focus-visible { outline: none; background: var(--em-states-hover); }
  .tabs button.on { border-bottom-color: var(--em-background-brand-primary); color: var(--em-text-primary); }

  main { flex: 1; padding: 16px 16px 120px; display: flex; flex-direction: column; gap: 24px; will-change: transform; position: relative; }
  #ptr {
    position: absolute; top: -44px; left: 0; right: 0; height: 40px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    color: var(--em-text-tertiary); font-size: 13px; font-weight: 600; pointer-events: none;
  }
  #ptr .spin { color: var(--em-background-brand-primary); display: block; }
  @keyframes em-spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
  #ptr.spinning .spin { animation: em-spin 0.7s linear infinite; }

  /* ---------- week / day structure ---------- */
  .week { display: flex; flex-direction: column; gap: 12px; }
  /* Extra breathing room before each subsequent week so the boundary reads
     clearly (adds to main's 24px flex gap). */
  .week + .week { margin-top: 20px; }
  .week-head { display: flex; align-items: baseline; justify-content: space-between; margin-top: 4px; }
  .week-head h2 { font-size: 20px; line-height: 24px; font-weight: 600; }
  .week-head span { font-size: 12px; color: var(--em-text-tertiary); }
  .week-head .range { font-family: var(--em-font-code); }
  .day { display: flex; flex-direction: column; gap: 8px; }
  .day-head { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
  .day-head b { font-size: 14px; font-weight: 700; }
  .day-head span { font-size: 12px; color: var(--em-text-tertiary); }

  /* ---------- cards ---------- */
  .card {
    background: var(--em-background-primary);
    border: 1px solid var(--em-border-extra-light);
    border-radius: 16px; padding: 14px 16px;
    box-shadow: var(--em-shadow-card);
    display: flex; flex-direction: column; gap: 8px;
  }
  .card.mine { border: 1.5px solid var(--em-border-brand-primary); }
  .card.full { opacity: 0.6; }
  .card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .card-when { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
  .card-when .t { font-size: 18px; font-weight: 700; font-family: var(--em-font-code); white-space: nowrap; }
  .card-when .w { font-size: 13px; color: var(--em-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .pill {
    display: inline-flex; align-items: center; height: 24px; padding: 0 10px;
    border-radius: 9999px; font-size: 12px; font-weight: 700; white-space: nowrap; flex-shrink: 0;
  }
  .pill.open { background: var(--em-background-success-tertiary); color: var(--em-text-success-primary); }
  .pill.scarce { background: var(--em-background-error-tertiary); color: var(--em-text-error-primary); }
  .pill.muted { background: var(--em-background-secondary); color: var(--em-text-tertiary); }
  .pill.booked { background: var(--em-background-brand-tertiary); color: var(--em-text-brand-primary); }
  .pill.progress { background: var(--em-background-success-tertiary); color: var(--em-text-success-primary); }
  .pill.cancelled { background: var(--em-background-error-tertiary); color: var(--em-text-error-primary); }
  .reason { font-size: 12px; line-height: 18px; color: var(--em-text-tertiary); }
  .card-foot { display: flex; align-items: center; gap: 8px; }
  .card-foot .detail { margin-left: auto; font-size: 13px; color: var(--em-text-secondary); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .btn-book {
    align-self: flex-start; height: 36px; padding: 0 16px; border-radius: 12px; border: none;
    background: var(--em-background-inverse-primary); color: var(--em-text-inverse-primary);
    font-size: 13px; font-weight: 600;
  }
  .btn-book:hover { opacity: 0.9; }
  .btn-cancel {
    align-self: flex-start; height: 32px; padding: 0 12px; border-radius: 12px;
    border: 1px solid var(--em-border-light); background: none;
    color: var(--em-text-error-primary); font-size: 12px; font-weight: 700;
  }
  .btn-cancel:hover { background: var(--em-states-hover); }

  /* my-schedule variant */
  .card .day-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .card .day-line b { font-size: 14px; font-weight: 700; }
  .card .when-line { display: flex; align-items: baseline; gap: 10px; }
  .card .when-line .t { font-size: 20px; font-weight: 700; font-family: var(--em-font-code); white-space: nowrap; }
  .card .when-line .w { font-size: 13px; color: var(--em-text-secondary); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .empty-week {
    border: 1px dashed var(--em-border-light); border-radius: 16px; padding: 28px 24px;
    text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center;
  }
  .empty-week div { font-size: 14px; color: var(--em-text-secondary); }
  .btn-brand {
    height: 40px; padding: 0 16px; border-radius: 12px; border: none;
    background: var(--em-background-brand-primary); color: #fcfcfc;
    font-size: 14px; font-weight: 600;
  }
  .btn-brand:hover { opacity: 0.9; }

  /* ---------- sheets ---------- */
  .scrim { position: fixed; inset: 0; background: var(--em-background-scrim-primary); z-index: 40; }
  .sheet {
    position: fixed; left: 50%; transform: translateX(-50%); bottom: 0;
    width: 100%; max-width: 480px; background: var(--em-background-primary);
    border-radius: 24px 24px 0 0; padding: 24px 24px calc(24px + env(safe-area-inset-bottom));
    z-index: 50; box-shadow: var(--em-shadow-sheet);
    display: flex; flex-direction: column; gap: 16px;
  }
  .dialog {
    position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: calc(100% - 32px); max-width: 400px; background: var(--em-background-primary);
    border-radius: 24px; padding: 24px; z-index: 50; box-shadow: var(--em-shadow-sheet);
    display: flex; flex-direction: column; gap: 16px;
  }
  .sheet h3, .dialog h3 { font-size: 20px; line-height: 24px; font-weight: 600; }
  .sheet .sub, .dialog .sub { margin-top: 4px; font-size: 14px; color: var(--em-text-secondary); }
  .sheet-slot {
    background: var(--em-background-secondary); border-radius: 16px; padding: 16px;
    display: flex; flex-direction: column; gap: 4px;
  }
  .sheet-slot .t { font-size: 20px; font-weight: 700; font-family: var(--em-font-code); }
  .sheet-slot .d { font-size: 14px; color: var(--em-text-secondary); }
  .sheet-slot .c { font-size: 12px; color: var(--em-text-tertiary); }
  .late-warning { background: var(--em-background-error-tertiary); border-radius: 12px; padding: 12px 16px; }
  .late-warning div { font-size: 14px; color: var(--em-text-error-primary); font-weight: 600; }
  .sheet-actions { display: flex; flex-direction: column; gap: 10px; }
  .btn-confirm {
    padding: 0 20px;
    height: 56px; border-radius: 12px; border: none;
    background: var(--em-background-brand-primary); color: #fcfcfc;
    font-size: 14px; font-weight: 600;
  }
  .btn-confirm:hover { opacity: 0.9; }
  .btn-destroy {
    padding: 0 20px;
    height: 48px; border-radius: 12px; border: none;
    background: var(--em-text-error-primary); color: #fcfcfc;
    font-size: 14px; font-weight: 700;
  }
  .btn-destroy:hover { opacity: 0.9; }
  .btn-quiet {
    padding: 0 20px;
    height: 48px; border-radius: 12px; border: 1px solid var(--em-border-light);
    background: none; color: var(--em-text-primary); font-size: 14px; font-weight: 600;
  }
  .btn-quiet:hover { background: var(--em-states-hover); }

  @keyframes em-scrim-in { from { opacity: 0; } to { opacity: 1; } }
  @keyframes em-scrim-out { from { opacity: 1; } to { opacity: 0; } }
  @keyframes em-sheet-in { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
  @keyframes em-sheet-out { from { transform: translate(-50%, 0); } to { transform: translate(-50%, 100%); } }
  @keyframes em-dialog-out { from { opacity: 1; } to { opacity: 0; } }
  .scrim { animation: em-scrim-in 0.2s ease; }
  .sheet { animation: em-sheet-in 0.28s cubic-bezier(0.22, 1, 0.36, 1); }
  .closing .scrim { animation: em-scrim-out 0.22s ease forwards; }
  .closing .sheet { animation: em-sheet-out 0.24s cubic-bezier(0.4, 0, 1, 1) forwards; }
  .closing .dialog { animation: em-dialog-out 0.18s ease forwards; }
  @media (prefers-reduced-motion: reduce) {
    .scrim, .sheet, .closing .scrim, .closing .sheet, .closing .dialog { animation: none; }
  }
  /* ---------- toast ---------- */
  @keyframes em-toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
  #toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 60;
    background: var(--em-background-inverse-primary); color: var(--em-text-inverse-primary);
    border-radius: 12px; padding: 12px 20px; font-size: 14px; font-weight: 600;
    box-shadow: var(--em-shadow-sheet); animation: em-toast-in 0.25s ease;
    max-width: min(448px, calc(100vw - 32px)); text-align: center;
  }

  /* ---------- sign-in / enrolment (token-styled; not in the mock) ---------- */
  .gate {
    min-height: 100vh; padding: 24px; display: flex; flex-direction: column;
    justify-content: center; gap: 16px; text-align: center; align-items: center;
  }
  .gate img { height: 48px; border-radius: 12px; margin-bottom: 8px; }
  .gate h1 { font-size: 28px; line-height: 34px; font-weight: 700; letter-spacing: -0.5px; }
  .gate p { color: var(--em-text-secondary); max-width: 32ch; }
  .gate .g-wrap {
    margin-top: 8px; background: var(--em-background-primary);
    border: 1px solid var(--em-border-extra-light); border-radius: 16px;
    box-shadow: var(--em-shadow-card); padding: 20px;
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    width: 100%; max-width: 360px;
  }
  .gate .hint { font-size: 12px; color: var(--em-text-tertiary); }
  .err-badge {
    width: 100%; background: var(--em-background-error-tertiary); border-radius: 12px;
    padding: 12px 16px; font-size: 15px; font-weight: 600; color: var(--em-text-error-primary);
  }
  .err-body { font-size: 14px; color: var(--em-text-secondary); }
  .err-email {
    width: 100%; background: var(--em-background-secondary); border-radius: 12px;
    padding: 10px 14px; font-family: var(--em-font-code); font-size: 13px;
    overflow-wrap: anywhere;
  }
  /* The confirm view reuses sheet components outside a sheet: give the
     identity block a real card on the grey page, and restore full width
     to the action buttons (they are styled for width-constrained sheets). */
  #view-confirm .sheet-slot {
    width: 100%; max-width: 360px;
    background: var(--em-background-primary);
    border: 1px solid var(--em-border-extra-light);
    box-shadow: var(--em-shadow-card);
  }
  #view-confirm .sheet-actions { width: 100%; max-width: 360px; }
  .devbox { border: 1px dashed var(--em-border-light); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
  .devbox label { font-size: 12px; color: var(--em-text-tertiary); }
  .devbox input {
    height: 48px; padding: 0 14px; font: inherit; border-radius: 12px;
    border: 1px solid var(--em-border-light); background: var(--em-background-primary);
    color: var(--em-text-primary);
  }
  .devbox input:focus { outline: 2px solid var(--em-background-brand-primary); border-color: transparent; }
  .skel { color: var(--em-text-tertiary); text-align: center; padding: 32px 0; }
