/* Ride — design system.
   Reference object: the Chinese fleet 三联派车单 (carbonless dispatch slip):
   pale blue-grey stock, deep ink-blue printing, one red chop. Field labels are
   wide-tracked and small; values are large. Times use tabular monospace so a
   column of departures reads like an instrument.

   No webfonts on purpose — drivers are on Chinese mobile networks where
   fonts.googleapis.com is unreliable. Personality lives in the numerals. */

:root {
  --paper:    #F2F5F7;
  --paper-2:  #FFFFFF;
  --carbon:   #DCE7EC;
  --ink:      #12293C;
  --ink-2:    #5A7385;
  --stamp:    #C0392B;
  --route:    #C77A12;
  --ok:       #1E7A5A;
  --shadow:   0 1px 2px rgba(18,41,60,.06), 0 8px 24px -12px rgba(18,41,60,.18);
  --r:        10px;

  --cjk: "PingFang SC", "HarmonyOS Sans SC", "Noto Sans CJK SC", "Microsoft YaHei",
         system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:   #0B1620;
    --paper-2: #12222E;
    --carbon:  #223949;
    --ink:     #E8F0F4;
    --ink-2:   #90A8B8;
    --stamp:   #E2604F;
    --route:   #F0AB48;
    --ok:      #3FA97F;
    --shadow:  0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
  }
}

* { box-sizing: border-box; }
/* A pasted URL, a long email or a 60-character address has no break
   opportunity and will otherwise push the whole page wider than the screen.
   Applied to the text-bearing containers rather than globally so it cannot
   interfere with the mono time column. */
.card, .turn, .place, .empty, .toast, .chip, .lab, .muted { overflow-wrap: anywhere; }
/* Flex and grid children default to min-width:auto, which refuses to shrink
   below their content — the other half of the same problem. Buttons and chips
   are excluded: they carry nowrap text, so letting them shrink would push the
   label outside its own box instead. */
.row > *:not(.btn):not(.chip):not(.flag), .turn > *, .route .place { min-width: 0; }
/* .topbar/.tabs set display:flex, which outranks the UA's [hidden] rule. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  /* No pinch-zoom, and no 300ms double-tap-to-zoom delay either — this is an
     app, not a document, and a zoomed layout is wider than the screen. The
     16px input rule above is what actually stops iOS zooming on focus;
     user-scalable=no alone is ignored there. */
  touch-action: manipulation;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--cjk);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select, textarea { font: inherit; color: inherit; }
/* iOS Safari zooms the whole page when a field smaller than 16px takes focus,
   and the zoomed layout is then wider than the screen — which reads as "the
   app is broken on my phone" rather than "my browser zoomed". 16px is the
   threshold; body text stays 15px. */
input, select, textarea { font-size: 16px; }
a { color: inherit; }

.wrap {
  max-width: 34rem; margin: 0 auto;
  /* viewport-fit=cover means landscape on a notched phone puts the notch over
     the left or right edge; without the insets the first characters of every
     line sit under it. */
  padding: 0 max(1rem, env(safe-area-inset-right)) 5rem max(1rem, env(safe-area-inset-left));
}

/* --- slip chrome ------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: .75rem;
  padding: calc(env(safe-area-inset-top) + .7rem)
           max(1rem, env(safe-area-inset-right)) .7rem
           max(1rem, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(150%) blur(12px);
  border-bottom: 1px solid var(--carbon);
}
.topbar h1 {
  margin: 0; font-size: .9375rem; font-weight: 700; letter-spacing: .16em;
}
.topbar .sub { color: var(--ink-2); font-size: .8125rem; letter-spacing: .04em; }
.spacer { flex: 1; }

/* Field label, straight off the printed form. */
.lab {
  font-size: .6875rem; font-weight: 600; letter-spacing: .18em;
  color: var(--ink-2);
  /* Labels are short by design; letting "合伙人" stack into three lines beside a
     long title is never what was meant. */
  white-space: nowrap;
}

/* Times, dates, counts — the instrument face. */
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

.card {
  background: var(--paper-2);
  border: 1px solid var(--carbon);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: .75rem;
}

/* --- the chop: the one red thing in the product ----------------------- */
.chop {
  display: inline-flex; align-items: baseline; gap: .45rem;
  padding: .3rem .6rem;
  border: 1.5px solid var(--stamp);
  box-shadow: inset 0 0 0 1px var(--paper-2), 0 0 0 1px color-mix(in srgb, var(--stamp) 30%, transparent);
  border-radius: 3px;
  color: var(--stamp);
  transform: rotate(-1.2deg);       /* applied by hand, not printed */
  transform-origin: left center;
}
.chop .lab { color: inherit; opacity: .8; }
.chop b { font-size: 1rem; font-weight: 700; letter-spacing: .02em; }
.chop.pending { --stamp: var(--ink-2); }

/* --- route: pickup -> dropoff, connected because it is a journey ------ */
.route { display: grid; grid-template-columns: 1rem 1fr; gap: 0 .7rem; }
.route .dot {
  position: relative; display: flex; justify-content: center; padding-top: .5rem;
}
.route .dot::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%;
  background: var(--ink); flex: none;
}
.route .dot.end::before { background: none; border: 2px solid var(--ink); }
.route .dot.line::after {
  content: ""; position: absolute; top: 1.1rem; bottom: -.35rem; width: 1px;
  background: repeating-linear-gradient(var(--carbon) 0 3px, transparent 3px 6px);
}
.route .place { padding: .25rem 0 .35rem; min-width: 0; }
.route .place b { font-weight: 600; }
.route .place small { display: block; color: var(--ink-2); font-size: .8125rem; }

/* --- buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: 0 1rem;
  border: 1px solid var(--carbon); border-radius: 8px;
  background: var(--paper-2); color: var(--ink);
  font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: transform .12s ease, background .12s ease;
}
/* Three actions across a 375px phone: let them shrink rather than wrap. */
.row .btn { min-width: 0; }
.row .btn.tight { padding: 0 .5rem; font-size: .875rem; }
.btn:active { transform: scale(.985); }
.btn:focus-visible { outline: 2px solid var(--stamp); outline-offset: 2px; }
.btn.primary { background: var(--ink); color: var(--paper-2); border-color: var(--ink); }
.btn.danger  { color: var(--stamp); border-color: color-mix(in srgb, var(--stamp) 45%, var(--carbon)); }
.btn.ghost   { background: transparent; }
.btn.wide    { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* The driver's one action. Sized to be hit without looking. */
.btn.huge {
  min-height: 68px; font-size: 1.25rem; letter-spacing: .08em;
  border-radius: 12px; width: 100%;
}

.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .55rem; border-radius: 999px;
  border: 1px solid var(--carbon); background: var(--paper);
  font-size: .75rem; font-weight: 600; letter-spacing: .04em;
  /* A status chip beside a long title must keep its shape: without these it
     gets squeezed until the text stacks vertically. */
  white-space: nowrap; flex: none;
}
.chip.live  { color: var(--stamp); border-color: color-mix(in srgb, var(--stamp) 40%, var(--carbon)); }
.chip.route { color: var(--route); border-color: color-mix(in srgb, var(--route) 40%, var(--carbon)); }
.chip.ok    { color: var(--ok);    border-color: color-mix(in srgb, var(--ok) 40%, var(--carbon)); }

.field { margin-bottom: .85rem; }
.field .lab { display: block; margin-bottom: .3rem; }
.input {
  width: 100%; min-height: 44px; padding: .5rem .7rem;
  background: var(--paper-2); border: 1px solid var(--carbon);
  border-radius: 8px;
}
.input:focus-visible { outline: 2px solid var(--ink); outline-offset: -1px; }
textarea.input { min-height: 5rem; resize: vertical; }

.row { display: flex; align-items: center; gap: .6rem; }
.muted { color: var(--ink-2); }
.hr { height: 1px; background: var(--carbon); margin: .9rem -1rem; }

/* Day heading: the slip's date band. */
.dayband {
  display: flex; align-items: baseline; gap: .6rem;
  margin: 1.4rem 0 .6rem; padding-bottom: .35rem;
  border-bottom: 2px solid var(--ink);
}
.dayband .d { font-size: 1.0625rem; font-weight: 700; letter-spacing: .04em; }

.sheet {
  position: fixed; inset: 0; z-index: 50; display: none;
  /* Opaque enough that the list underneath stops competing for attention --
     this is where the dispatch decision gets made. */
  background: rgba(6, 16, 24, .66);
  backdrop-filter: blur(2px);
}
.sheet.open { display: block; }
.sheet .panel {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: 34rem;
  max-height: 92vh; overflow: auto; overscroll-behavior: contain;
  background: var(--paper);
  border: 1px solid var(--carbon); border-bottom: 0;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 40px -8px rgba(6, 16, 24, .45);
  padding: 1rem max(1rem, env(safe-area-inset-right))
           calc(env(safe-area-inset-bottom) + 1.5rem)
           max(1rem, env(safe-area-inset-left));
  animation: rise .22s cubic-bezier(.2,.8,.3,1);
}
@keyframes rise { from { transform: translate(-50%, 14px); opacity: .6; } }
.sheet .grab {
  width: 36px; height: 4px; border-radius: 2px; background: var(--carbon);
  margin: 0 auto .9rem;
}

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 1.2rem);
  transform: translateX(-50%);
  background: var(--ink); color: var(--paper-2);
  padding: .6rem 1rem; border-radius: 999px; font-size: .875rem;
  z-index: 90; box-shadow: var(--shadow); max-width: 90vw;
}

.empty { text-align: center; padding: 3.5rem 1rem; color: var(--ink-2); }
.empty .big { font-size: 1.0625rem; color: var(--ink); font-weight: 600; margin-bottom: .35rem; }

.tabs { display: flex; gap: .3rem; padding: .6rem 0; }
.tabs button {
  flex: 1; min-height: 38px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; color: var(--ink-2); font-weight: 600; cursor: pointer;
}
.tabs button[aria-selected="true"] {
  background: var(--paper-2); border-color: var(--carbon); color: var(--ink);
}

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

/* ===== work items: the spine, the buckets, the thread ===== */

/* The spine. Locked work hangs off it and the empty stretches between are
   labelled with how long they are -- that number is the question he actually
   asks all day, so it belongs in the structure rather than in a tooltip. */
.spine { position: relative; padding-left: 1.6rem; }
.spine::before {
  content: ""; position: absolute; left: 4px; top: .4rem; bottom: .4rem; width: 1px;
  background: repeating-linear-gradient(var(--carbon) 0 4px, transparent 4px 8px);
}
.node { position: relative; margin-bottom: .55rem; }
.node::before {
  content: ""; position: absolute; left: -1.6rem; top: .55rem;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--ink); box-shadow: 0 0 0 4px var(--paper);
}
.node.done::before { background: var(--ok); }
.node.now::before {
  background: var(--stamp);
  box-shadow: 0 0 0 4px var(--paper), 0 0 0 6px color-mix(in srgb, var(--stamp) 25%, transparent);
}
.gap { position: relative; margin: .1rem 0 .6rem;
       font-size: .75rem; letter-spacing: .1em; color: var(--ink-2); }
.gap::before { content: ""; position: absolute; left: -1.6rem; top: 50%;
               width: 9px; height: 1px; background: var(--carbon); }

.tick { font-family: var(--mono); font-variant-numeric: tabular-nums;
        font-size: 1.5rem; font-weight: 700; line-height: 1.1; }

/* A thread turn: two columns, no bubbles, no avatars. This is a work log. */
.turn { display: grid; grid-template-columns: 3.4rem 1fr; gap: .5rem;
        margin-top: .45rem; font-size: .875rem; }
.turn .who { color: var(--ink-2); font-size: .75rem; padding-top: .15rem; }
.turn.mine .who { color: var(--ink); font-weight: 600; }
.turn img { max-width: 100%; border-radius: 8px; margin-top: .3rem;
            border: 1px solid var(--carbon); }

/* The one thing allowed to interrupt: he is stuck and needs a decision. */
.flag { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; flex: none;
        padding: .2rem .55rem; border-radius: 999px;
        background: var(--stamp); color: #fff;
        font-size: .75rem; font-weight: 700; letter-spacing: .04em; }
.card.blocked { border-color: var(--stamp);
                box-shadow: var(--shadow), inset 3px 0 0 var(--stamp); }

.sectionhead { display: flex; align-items: baseline; gap: .5rem;
               margin: 1.5rem 0 .55rem; padding-bottom: .3rem;
               border-bottom: 1px solid var(--carbon); }
.sectionhead .t { font-size: .8125rem; font-weight: 700; letter-spacing: .16em; }
.sectionhead .n { font-family: var(--mono); color: var(--ink-2); font-size: .8125rem; }

/* Adding an item is not what he does while driving, so this does not float
   over the one thing that matters. */
.fab { width: 100%; min-height: 52px; margin: 1.4rem 0 .5rem; }

.seg { display: flex; gap: .4rem; }
.seg .btn { flex: 1; }

.quiet { opacity: .72; }


/* 高德's suggestion panel is third-party DOM appended to <body>, carrying its
   own light-mode styling — in dark mode it renders near-white text on a
   near-white card and is effectively invisible. These overrides are broad and
   !important on purpose: the SDK sets several of these inline, and we do not
   control its markup. Also lifted above the sheet (z-index 50) so it is not
   clipped behind the form it belongs to. */
.amap-sug-result,
[class*="amap-sug"] {
  background: var(--paper-2) !important;
  border: 1px solid var(--carbon) !important;
  border-radius: 8px !important;
  box-shadow: var(--shadow) !important;
  color: var(--ink) !important;
  font-family: var(--cjk) !important;
  z-index: 60 !important;
  overflow: hidden !important;
}
.amap-sug-result .auto-item {
  background: transparent !important;
  color: var(--ink) !important;
  border-bottom: 1px solid var(--carbon) !important;
  padding: .55rem .7rem !important;
  min-height: 44px !important;          /* a real tap target on a phone */
  line-height: 1.4 !important;
}
.amap-sug-result .auto-item:last-child { border-bottom: 0 !important; }
.amap-sug-result .auto-item:hover,
.amap-sug-result .auto-item.auto-item-hover,
.amap-sug-result .auto-item[class*="hover"] {
  background: var(--carbon) !important;
}
/* The SDK marks the district/address half with its own class in some versions
   and a bare trailing span in others; catch both and mute them. */
.amap-sug-result .auto-item * { color: inherit !important; }
.amap-sug-result .auto-item .poi-more,
.amap-sug-result .auto-item .auto-item-addr,
.amap-sug-result .auto-item span + span {
  color: var(--ink-2) !important;
}
