/* tripline — mobile-first. Base styles are the phone; min-width queries only add. */

@layer base, timeline, sheet, util;

@layer base {
  :root {
    color-scheme: light;

    /* The four brand colours: the wordmark, the day accents and the main event types */
    --red:    #D1091E;
    --orange: #E29000;
    --green:  #8BBF4B;
    --blue:   #00B2ED;

    /* Extended, to give the quieter event types some personality too */
    --violet: #7B8CDE;
    --coral:  #F2765C;
    --teal:   #2FB3A3;
    --slate:  #8D97A8;

    --bg:      #fbfaf7;
    --surface: #ffffff;
    --raised:  #f6f5f1;
    --ink:     #14161b;
    --muted:   #6b7280;
    --line:    #e8e7e2;
    --shadow:    0 1px 3px rgb(20 20 20 / .07);
    --shadow-lg: 0 12px 40px rgb(20 20 20 / .16);

    --safe-t: env(safe-area-inset-top, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);

    --font: ui-rounded, "SF Pro Rounded", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
            Roboto, "Helvetica Neue", Arial,
            /* local-language text: Chinese, Japanese, Korean */
            "PingFang SC", "Hiragino Sans", "Hiragino Sans GB", "Microsoft YaHei", "Yu Gothic",
            "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --gutter: 18px;
    --spine: 27px;   /* x-position of the timeline spine */
    --indent: 62px;  /* where event content starts */
  }

  [data-type="flight"] { --accent: var(--blue); }
  [data-type="train"]  { --accent: var(--red); }
  [data-type="hotel"]  { --accent: var(--green); }
  [data-type="ticket"] { --accent: var(--orange); }
  [data-type="move"]   { --accent: var(--violet); }
  [data-type="food"]   { --accent: var(--coral); }
  [data-type="sight"]  { --accent: var(--teal); }
  [data-type="admin"]  { --accent: var(--slate); }

  * { box-sizing: border-box; }

  body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
    overflow-wrap: break-word;
  }
  button { font: inherit; color: inherit; }

  .skip {
    position: absolute; left: -9999px;
    &:focus { left: 8px; top: 8px; z-index: 99; background: var(--surface); padding: 8px 12px; border-radius: 10px; }
  }

  /* ── Hero header (scrolls away) ───────────────────────── */
  .topbar {
    padding: calc(var(--safe-t) + 22px) var(--gutter) 22px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
  }
  .brand { display: flex; align-items: center; gap: 12px; }
  .brand-mark { flex: none; }
  .brand-name {
    display: flex; flex-wrap: wrap; align-items: baseline;
    font-weight: 800; letter-spacing: -.04em; font-size: 1.85rem; line-height: .95;
    b { color: var(--c); }
    .brand-year { font-size: .55em; letter-spacing: -.01em; margin-left: .3em; }
  }
  .trip-progress {
    display: flex; align-items: center; gap: 10px; margin-top: 14px;
    .rail { flex: 1; height: 8px; border-radius: 99px; background: var(--raised); overflow: hidden; }
    .fill {
      display: block; height: 100%; width: 0; border-radius: 99px;
      background: linear-gradient(90deg, var(--red), var(--orange), var(--green), var(--blue));
      transition: width .6s ease;
    }
    .pct { font-size: .78rem; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
  }

  /* ── Live status (sticky) ─────────────────────────────── */
  .status {
    position: sticky; top: 0; z-index: 20;
    padding: 12px var(--gutter);
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
  }
  .status-head {
    display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
    padding: 0 2px 8px;
  }
  .status-label {
    font-size: .78rem; font-weight: 800; letter-spacing: -.01em;
    color: var(--accent, var(--muted));
  }
  .status-count { font-size: .76rem; font-weight: 700; color: var(--muted); }

  .status-card {
    display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center;
    width: 100%; text-align: left; cursor: pointer;
    padding: 15px 16px; margin: 0;
    background: var(--surface);
    border: 1.5px solid color-mix(in srgb, var(--accent) 30%, var(--line));
    border-radius: 18px;
    box-shadow: var(--shadow);
    transition: transform .12s ease;
    &:active { transform: scale(.985); }
    &[data-static="1"] { cursor: default; &:active { transform: none; } }
  }
  .status-icon {
    display: grid; place-items: center; flex: none;
    width: 46px; height: 46px; border-radius: 50%;
    font-size: 1.45rem; line-height: 1;
    background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  }
  .status-body { min-width: 0; }
  .status-title {
    display: block; font-weight: 750; font-size: 1.08rem; line-height: 1.25;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .status-sub {
    display: block; font-size: .84rem; color: var(--muted); margin-top: 3px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .status-time {
    flex: none; text-align: right;
    font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.02rem;
    color: var(--accent, var(--muted));
  }
  .status-bar {
    height: 5px; margin: 10px 4px 0; border-radius: 99px; overflow: hidden;
    background: var(--line);
    i { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--accent); transition: width .8s linear; }
  }
  .status:not(.is-live) .status-bar { display: none; }

  /* In the air: a plane rides the tip of the bar, and the route still to fly is dotted. */
  .status-plane { display: none; }
  .status[data-type="flight"] .status-bar {
    position: relative; overflow: visible; margin-top: 16px; margin-bottom: 6px;
    background: repeating-linear-gradient(90deg, var(--line) 0 6px, transparent 6px 11px);
  }
  .status[data-type="flight"] .status-plane {
    display: block; position: absolute; top: 50%;
    left: clamp(11px, calc(var(--progress, 0) * 100%), calc(100% - 11px));
    width: 22px; height: 22px; margin: -11px 0 0 -11px;
    color: var(--accent);
    filter: drop-shadow(0 1px 1.5px rgb(20 20 20 / .25));
    transition: left .8s linear;
    svg { display: block; transform: rotate(90deg); animation: plane-bob 2.6s ease-in-out infinite; }
  }
  @keyframes plane-bob {
    0%, 100% { translate: 0 -1.5px; }
    50%      { translate: 0 1.5px; }
  }

  /* On rails: the train's nose rides the tip of the bar, over the sleepers still ahead. */
  .status-train { display: none; }
  .status[data-type="train"] .status-bar {
    position: relative; overflow: visible; margin-top: 18px; margin-bottom: 4px;
    background:
      linear-gradient(var(--line), var(--line)) center / 100% 2px no-repeat,
      repeating-linear-gradient(90deg, var(--line) 0 2px, transparent 2px 8px);
  }
  .status[data-type="train"] .status-train {
    display: block; position: absolute; top: 50%;
    left: clamp(32px, calc(var(--progress, 0) * 100%), 100%);
    width: 34px; height: 16px; margin: -14px 0 0 -32px;
    color: var(--accent);
    filter: drop-shadow(0 1px 1.5px rgb(20 20 20 / .25));
    transition: left .8s linear;
    svg { display: block; animation: train-rumble .5s ease-in-out infinite alternate; }
  }
  @keyframes train-rumble {
    from { translate: 0 0; }
    to   { translate: 0 .6px; }
  }

  @media (prefers-reduced-motion: reduce) {
    .status[data-type="flight"] .status-plane svg,
    .status[data-type="train"] .status-train svg { animation: none; }
  }

  .foot {
    padding: 28px var(--gutter) calc(var(--safe-b) + 46px);
    text-align: center; font-size: .82rem; color: var(--muted);
    p { margin: 5px 0; }
  }

  .muted { color: var(--muted); }
  .build {
    font-size: .7rem; opacity: .65; cursor: pointer; user-select: none;
    code { font-family: var(--mono); }
  }

  /* Update prompt. Never reloads on its own — the screen might be showing a QR
     code at a ticket gate. */
  .update {
    position: fixed; z-index: 40;
    left: var(--gutter); right: var(--gutter); bottom: calc(var(--safe-b) + 16px);
    display: flex; align-items: center; gap: 12px;
    padding: 14px 14px 14px 16px; border-radius: 20px;
    background: var(--ink); color: #fff;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 45%, transparent), var(--shadow-lg);
    animation: update-in .45s cubic-bezier(.2, .9, .3, 1.2) both;
    &[hidden] { display: none; }
  }
  .update-icon { flex: none; font-size: 1.6rem; line-height: 1; }
  .update-text { flex: 1; min-width: 0; line-height: 1.25;
    b { display: block; font-size: 1rem; font-weight: 800; }
    small { display: block; margin-top: 2px; font-size: .76rem; font-weight: 600; opacity: .8; }
  }
  .update-btns { flex: none; display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
  .update-go, .update-later {
    cursor: pointer; border: 0; border-radius: 12px;
    font-size: .88rem; font-weight: 800;
  }
  .update-go {
    padding: 11px 16px; background: var(--green); color: #10300a;
    animation: update-pulse 2s ease-out infinite;
  }
  .update-later { padding: 4px 8px; background: none; color: #fff; font-size: .76rem; opacity: .7; }

  /* The install offer: the update card's shape, calmer — blue, no pulse. */
  .install {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 40%, transparent), var(--shadow-lg);
    .update-go { background: var(--blue); color: #04263a; animation: none; &[hidden] { display: none; } }
  }
  .foot-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
  .foot-btn {
    margin: 4px 0 8px; padding: 9px 16px; cursor: pointer;
    border: 1px solid var(--line); border-radius: 99px;
    background: var(--surface); color: var(--ink); font: inherit; font-weight: 750;
    &[hidden] { display: none; }
  }

  @keyframes update-in {
    from { transform: translateY(calc(100% + 24px)); opacity: 0; }
    to   { transform: none; opacity: 1; }
  }
  @keyframes update-pulse {
    0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--green) 70%, transparent); }
    100% { box-shadow: 0 0 0 12px transparent; }
  }
  @media (prefers-reduced-motion: reduce) {
    .update, .update-go { animation: none; }
  }

  .jump {
    position: fixed; z-index: 30;
    right: var(--gutter); bottom: calc(var(--safe-b) + 18px);
    .update:not([hidden]) ~ & { bottom: calc(var(--safe-b) + 112px); }
    .install:not([hidden]) ~ & { bottom: calc(var(--safe-b) + 150px); }
    display: flex; align-items: center; gap: 7px;
    padding: 13px 19px; border: 0; border-radius: 99px;
    background: var(--ink); color: var(--bg);
    font-size: .88rem; font-weight: 750;
    box-shadow: var(--shadow-lg); cursor: pointer;
    &[hidden] { display: none; }
    &:active { transform: scale(.95); }
  }

  /* Live info — network-only, so it reads as a distinct band from the offline timeline */
  .live {
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px;
    padding: 14px var(--gutter) 2px;
    &[hidden] { display: none; }
  }
  .live-chip {
    display: flex; align-items: center; gap: 9px;
    padding: 11px 12px; border-radius: 14px;
    text-decoration: none; color: var(--ink);
    background: var(--surface); border: 1px solid var(--line);
    &:active { transform: scale(.97); }
  }
  .live-ico { font-size: 1.15rem; line-height: 1; flex: none; }
  img.live-ico { width: 22px; height: 22px; border-radius: 6px; }
  .live-text { min-width: 0; line-height: 1.2; }
  .live-text b { display: block; font-size: .8rem; font-weight: 750; }
  .live-text small {
    display: block; font-size: .66rem; color: var(--muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
}

@layer timeline {
  .timeline { padding-bottom: 8px; }

  .day { padding-bottom: 10px; }

  .day-head {
    position: sticky; top: var(--stick, 120px); z-index: 10;
    display: flex; align-items: center; gap: 12px;
    padding: 14px var(--gutter) 12px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(10px);
  }
  .day-n {
    flex: none;
    display: grid; place-items: center;
    width: 42px; height: 42px; border-radius: 14px;
    background: var(--accent); color: #fff;
    font-size: 1.15rem; font-weight: 850;
    box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 38%, transparent);
  }
  .day-meta { min-width: 0; line-height: 1.25; }
  .day-date { font-size: 1.02rem; font-weight: 800; letter-spacing: -.015em; }
  .day-title { display: block; font-size: .82rem; color: var(--muted); }
  /* Where the clock changes: "GMT+7" beside the date. */
  .day-tz {
    margin-left: 8px; padding: 1px 7px; border-radius: 99px; vertical-align: 2px;
    font-size: .68rem; font-weight: 750; letter-spacing: 0;
    color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, transparent);
  }
  .day-local {
    margin-left: auto; flex: none;
    font-size: 1.05rem; font-weight: 750;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 13%, transparent);
    padding: 5px 11px; border-radius: 99px;
  }

  /* Day weather. Informative only — no tap target, nothing to press. */
  .day-wx {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px;
    margin: 0 var(--gutter) 2px;
    padding: 8px 12px; border-radius: 13px;
    background: var(--raised);
    font-size: .78rem; color: var(--muted);
  }
  .wx-ico { font-size: 1rem; line-height: 1; }
  .wx-hi { font-size: .95rem; font-weight: 800; color: var(--ink); }
  .wx-lo { font-weight: 650; }
  .wx-text { flex: 1 1 auto; min-width: 0; }
  .wx-pop { font-variant-numeric: tabular-nums; }
  .wx-rh { font-variant-numeric: tabular-nums; white-space: nowrap; }
  .wx-rh svg { width: 1.15em; height: 1.15em; margin-right: 1px; vertical-align: -.22em; }
  .wx-soft {
    flex: none;
    padding: 1px 7px; border-radius: 99px;
    background: color-mix(in srgb, var(--muted) 18%, transparent);
    font-size: .64rem; font-weight: 750; text-transform: uppercase; letter-spacing: .04em;
  }
  .wx-alt {
    margin: 4px var(--gutter) 0;
    padding: 0 12px;
    font-size: .72rem; line-height: 1.45; color: var(--muted);
  }
  .day-wx-wrap .day-wx { margin-bottom: 0; }

  .events {
    list-style: none; margin: 0;
    padding: 6px var(--gutter) 10px;
    position: relative;
  }
  /* four-colour spine, echoing the stacked wordmark */
  .events::before {
    content: ''; position: absolute;
    left: calc(var(--gutter) + var(--spine)); top: 0; bottom: 18px; width: 2.5px;
    border-radius: 99px;
    background: linear-gradient(var(--red), var(--orange), var(--green), var(--blue));
    opacity: .3;
  }

  .ev { position: relative; padding-left: var(--indent); margin-bottom: 16px; }

  .ev-chip {
    position: absolute; left: calc(var(--spine) - 17px); top: 6px;
    display: grid; place-items: center;
    width: 35px; height: 35px; border-radius: 50%;
    font-size: 1.05rem; line-height: 1;
    background: color-mix(in srgb, var(--accent) 17%, var(--surface));
    box-shadow: 0 0 0 3.5px var(--bg);
  }

  /* — rich events: a proper card you can tap — */
  .ev-card {
    display: block; width: 100%; text-align: left; cursor: pointer;
    padding: 14px 15px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    transition: transform .12s ease;
    &:active { transform: scale(.99); }
  }
  .ev-top { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
  .ev-time {
    font-size: .76rem; font-weight: 800; font-variant-numeric: tabular-nums;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 13%, transparent);
    padding: 3px 9px; border-radius: 99px;
  }
  .ev-chev { margin-left: auto; color: var(--muted); font-size: 1.1rem; line-height: 1; }
  .ev-title { display: block; font-weight: 700; font-size: 1rem; line-height: 1.32; }
  .ev-sub { display: block; font-size: .85rem; color: var(--muted); margin-top: 3px; }
  .tag {
    font-size: .7rem; font-weight: 750;
    padding: 4px 9px; border-radius: 99px;
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    color: color-mix(in srgb, var(--accent) 72%, var(--ink));
  }
  .tag.warn { background: color-mix(in srgb, var(--red) 14%, transparent); color: color-mix(in srgb, var(--red) 78%, var(--ink)); }

  /* — informative events: just a line of text, nothing to tap — */
  .ev--plain {
    margin-bottom: 13px;
    .ev-chip { width: 27px; height: 27px; left: calc(var(--spine) - 13px); top: 1px; font-size: .82rem; }
  }
  .ev-plain {
    padding: 1px 2px;
    .ev-time {
      background: none; padding: 0; margin-right: 8px;
      color: var(--muted); font-size: .78rem;
    }
    .ev-title { display: inline; font-weight: 600; font-size: .93rem; color: color-mix(in srgb, var(--ink) 78%, var(--bg)); }
    .ev-sub { font-size: .82rem; margin-top: 2px; }
  }

  /* an informative row can still be a moment that matters */
  .ev--plain[data-pin="1"] {
    .ev-title { font-weight: 750; color: var(--ink); }
    .ev-chip { background: color-mix(in srgb, var(--accent) 30%, var(--surface)); }
  }

  /* — state — */
  .ev.is-past { opacity: .38; }
  .ev.is-past .ev-card { box-shadow: none; background: transparent; }
  .ev.is-now .ev-card {
    border-color: var(--accent); border-width: 1.5px;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 17%, transparent), var(--shadow);
  }
  .ev.is-now .ev-chip { animation: pop 2.4s ease-out infinite; }
  .ev.is-now .ev-plain .ev-title { color: var(--ink); font-weight: 750; }

  @keyframes pop {
    0%   { box-shadow: 0 0 0 3.5px var(--bg), 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
    100% { box-shadow: 0 0 0 3.5px var(--bg), 0 0 0 15px transparent; }
  }
  @media (prefers-reduced-motion: reduce) {
    .ev.is-now .ev-chip { animation: none; }
    *, *::before { transition-duration: .01ms !important; }
  }
}

@layer sheet {
  .sheet {
    width: 100%; max-width: 560px; max-height: 90dvh;
    margin: auto auto 0;              /* bottom sheet on phones */
    padding: 0; border: 0;
    border-radius: 26px 26px 0 0;
    background: var(--surface); color: var(--ink);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    &::backdrop { background: rgb(10 10 12 / .55); backdrop-filter: blur(3px); }
    &[open] { display: flex; flex-direction: column; }
  }
  .sheet-close {
    position: sticky; top: 0; z-index: 2;
    display: flex; justify-content: flex-end;
    padding: 14px 14px 0;
    background: linear-gradient(var(--surface) 70%, transparent);
    button {
      width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
      border: 1px solid var(--line); background: var(--raised); font-size: 1rem;
    }
  }
  .sheet-body {
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding: 0 22px calc(var(--safe-b) + 32px);
  }

  .sh-kicker {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 13px 6px 8px; border-radius: 99px;
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    color: color-mix(in srgb, var(--accent) 78%, var(--ink));
    font-size: .76rem; font-weight: 800;
  }
  .sh-title { margin: 14px 0 4px; font-size: 1.5rem; line-height: 1.2; font-weight: 820; letter-spacing: -.02em; }

  /* "This place has a page." Rides at the end of the title in the event's own colour,
     sized to the finger with negative margins so it never grows the title's line box. */
  .ico-open {
    display: inline-grid; place-items: center;
    width: 36px; height: 36px; margin: -8px -9px -8px 0;
    vertical-align: -.22em;
    color: var(--accent, var(--muted)); border-radius: 10px;
    svg { width: 22px; height: 22px; }
    &:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
    &:active { transform: scale(.9); }
  }
  .sh-place { font-size: 1.05rem; font-weight: 650; color: var(--muted); line-height: 1.4; }
  .sh-place.has-copy { display: flex; align-items: center; gap: 4px; }

  /* The copy icon. Small on the page, 40px to the finger — the tap target is padding,
     not size, so it can sit tight against the name it copies. */
  .ico-copy {
    flex: none; display: inline-grid; place-items: center;
    width: 40px; height: 40px; margin: -9px -10px -9px 0; padding: 0;
    border: 0; background: none; color: var(--muted); cursor: pointer;
    border-radius: 10px;
    svg { width: 21px; height: 21px; transition: opacity .12s; }
    .g-done { display: none; }
    &:hover { color: var(--ink); background: var(--raised); }
    &:active { transform: scale(.9); }
    &.is-copied {
      color: #3d6b1a;
      .g-copy { display: none; }
      .g-done { display: block; }
    }
    &.is-failed { color: var(--red); }
  }
  .sh-when {
    margin: 18px 0; padding: 14px 16px;
    background: var(--raised); border-radius: 14px;
    font-variant-numeric: tabular-nums; font-weight: 700;
  }
  .sh-route { display: grid; gap: 10px; margin: 18px 0; }
  .sh-route div { display: flex; gap: 10px; align-items: center; }
  .sh-route strong { flex: 1; }
  .sh-route span:first-child { color: var(--muted); font-size: .78rem; width: 34px; flex: none; }

  .sh-h {
    margin: 28px 0 10px; font-size: .78rem; font-weight: 800;
    color: var(--muted);
  }

  .sh-dl { display: grid; margin: 0; }
  .sh-dl > div { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .sh-dl > div:last-child { border-bottom: 0; }
  .sh-dl > div.has-copy {
    display: grid; grid-template-columns: 1fr auto; align-items: center;
    column-gap: 12px;
    dt, dd { grid-column: 1; }
  }
  .sh-dl dt { font-size: .76rem; color: var(--muted); margin-bottom: 3px; }
  .sh-dl dd { margin: 0; font-size: .95rem; }
  .sh-dl > div.has-copy .ico-copy { grid-row: 1 / 3; grid-column: 2; align-self: center; margin-right: -10px; }
  .sh-map {
    margin: 0; padding: 0; cursor: zoom-in;
    border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
    background: #fdfcfa;
    img { display: block; width: 100%; height: auto; }
    &:active { transform: scale(.99); }
  }
  .sh-tel { color: var(--blue); font-weight: 700; }
  .sh-note {
    margin: 12px 0 0; padding: 11px 13px; border-radius: 11px;
    background: var(--raised);
    font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; line-height: 1.5;
    b { color: var(--ink); font-weight: 750; }
  }
  .sh-dl dd.local { font-size: 1.05rem; font-weight: 600; }
  .sh-dl dd code { font-family: var(--mono); font-size: .9rem; }

  .sh-warn {
    display: flex; gap: 11px; margin: 12px 0;
    padding: 14px 15px; border-radius: 15px;
    background: color-mix(in srgb, var(--red) 8%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--red) 26%, transparent);
    font-size: .9rem; line-height: 1.5;
    span { flex: none; }
  }

  .sh-driver {
    width: 100%; text-align: left; cursor: pointer;
    margin-top: 10px; padding: 18px;
    border: 2px dashed color-mix(in srgb, var(--ink) 22%, transparent);
    border-radius: 18px; background: var(--raised);
    .local { font-size: 1.32rem; font-weight: 700; line-height: 1.55; white-space: pre-line; }
    .en { margin-top: 10px; font-size: .82rem; color: var(--muted); }
    .hint { margin-top: 12px; font-size: .76rem; font-weight: 750; color: var(--accent); }
  }

  .sh-qrs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .sh-qr {
    display: grid; gap: 9px; justify-items: center; cursor: pointer;
    margin: 0; padding: 14px; border-radius: 16px; background: #fff;
    border: 1px solid var(--line);
    img { width: 100%; height: auto; max-width: 150px; image-rendering: pixelated; }
    figcaption { font-size: .64rem; color: #555; text-align: center; font-family: var(--mono); overflow-wrap: anywhere; }
  }

  .sh-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
  .sh-act {
    flex: 1 1 auto; cursor: pointer; text-decoration: none;
    display: inline-flex; align-items: center; justify-content: center; gap: 9px;
    padding: 13px 16px; border-radius: 14px;
    border: 1px solid var(--line); background: var(--raised); color: var(--ink);
    font-size: .9rem; font-weight: 750; text-align: center;
  }
  .act-ico {
    width: 22px; height: 22px; border-radius: 6px; flex: none;
    box-shadow: 0 1px 2px rgb(0 0 0 / .14);
  }
  .act-ico.is-emoji { width: auto; height: auto; box-shadow: none; font-size: 1.05rem; line-height: 1; }
  .sh-act.primary .act-ico { box-shadow: 0 1px 2px rgb(0 0 0 / .25); }
  .sh-act.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
  .sh-act.is-copied { background: color-mix(in srgb, var(--green) 22%, #fff); border-color: transparent; color: #3d6b1a; }

  .sh-list { margin: 0; padding-left: 20px; font-size: .92rem; li { margin: 8px 0; } }
}

@layer util {
  /* Fullscreen QR / driver card — for a turnstile or a taxi window */
  .lightbox {
    /* inset, not 100vw/100dvh: a viewport unit can resolve wider than the visible area,
       and the dialog then hangs off the right with everything inside it shifted. */
    position: fixed; inset: 0;
    width: auto; height: auto; max-width: none; max-height: none;
    margin: 0; padding: 0; border: 0;
    background: #fff; color: #000;
    &::backdrop { background: #fff; }
    /* One row, not two. The close button used to sit in a row of its own, which pushed
       everything below it and left the content visibly low on the screen. The single
       column is pinned to 100% so it can never size itself to a wide image and overflow. */
    &[open] { display: grid; grid-template-columns: 100%; }
  }
  .lightbox-close {
    position: absolute; z-index: 2;
    top: calc(var(--safe-t) + 14px); right: 16px;
    width: 46px; height: 46px; border-radius: 50%; cursor: pointer;
    border: 1px solid #ddd; background: #fff; color: #000; font-size: 1.1rem;
  }
  .lightbox-body {
    /* Matching insets top and bottom: the close button floats over the top one, and
       because they are equal, centring in this box is centring on the screen. */
    --chrome: 64px;
    --cap-h: 44px;
    --fit-h: calc(100dvh - var(--safe-t) - var(--safe-b) - var(--chrome) * 2 - var(--cap-h));
    box-sizing: border-box; min-width: 0; overflow: hidden;
    /* One full-width column, so the track has a definite size: that is what lets the
       image's own 100% resolve against the padding box instead of against itself. */
    display: grid; grid-template-columns: minmax(0, 1fr);
    align-content: center; justify-items: center; gap: 18px;
    padding: calc(var(--safe-t) + var(--chrome)) 22px calc(var(--safe-b) + var(--chrome));
    text-align: center;
    /* Everything is bounded by the padding box — never by a viewport unit. An image wider
       than its box overflows the grid track, and a centred track that overflows is exactly
       how the ticket ended up hard against the right edge. */
    img { width: min(100%, var(--fit-h)); height: auto; image-rendering: pixelated; }
    /* A ticket is a tall page, not a square code: fit it, keep it smooth, let the viewer
       pinch in for the seat number — and give it the side room back, since the gutter
       exists for a caption, not for a page you are trying to read. */
    &.is-doc {
      padding-inline: 12px;
      img {
        width: auto; height: auto;
        max-width: 100%; max-height: var(--fit-h);
        image-rendering: auto; border-radius: 10px; box-shadow: 0 2px 18px #0002;
      }
    }
    &.is-doc .cap { font-family: inherit; font-size: .95rem; font-weight: 700; color: #222; }
    .cap { font-family: var(--mono); font-size: .8rem; color: #444; overflow-wrap: anywhere; }
    .big-local { font-size: clamp(1.9rem, 7.5vw, 3.4rem); font-weight: 800; line-height: 1.45; white-space: pre-line; }
    .big-en { font-size: 1.05rem; color: #555; }
    .sh-act { flex: none; min-width: 160px; margin-top: 6px; }
  }

  /* Wider screens: the same phone layout, centred and a touch roomier */
  @media (min-width: 700px) {
    :root { --gutter: 26px; }
    .topbar > *, .status > *, .timeline, .foot > *, .live { max-width: 680px; margin-inline: auto; }
    .timeline { max-width: calc(680px + var(--gutter) * 2); }
    .sheet { margin: auto; border-radius: 26px; max-height: 86dvh; }
    .sh-qrs { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
    .brand-name { font-size: 2.2rem; }
  }
}
