:root {
  --ink: #14213D;
  --ink-soft: #55607A;
  --paper: #F4F6F8;
  --card: #FFFFFF;
  --line: #DCE1E8;
  --label: #FFD23F;
  --done: #2E7D5B;
  --alert: #C8102E;
  --focus: #2F6FEB;
  --font: 'Archivo', system-ui, -apple-system, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.45 var(--font);
  font-variation-settings: 'wdth' 100;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

#app { max-width: 640px; margin: 0 auto; padding: calc(var(--safe-top) + 12px) 18px calc(var(--safe-bottom) + 48px); }

.top { display: flex; align-items: center; justify-content: space-between; padding: 6px 0 2px; }
.top h1 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: 0.01em; color: var(--ink-soft); }
.top-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent;
  display: grid; place-items: center;
}
.icon-btn:active { background: var(--line); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* The one bold thing: big condensed day headings */
.day { margin: 22px 0 6px; }
.day h2 {
  margin: 0;
  font-size: clamp(30px, 9vw, 40px);
  line-height: 0.95;
  font-weight: 800;
  font-variation-settings: 'wdth' 62;
  letter-spacing: -0.01em;
}
.day .day-sub { margin-top: 4px; color: var(--ink-soft); font-size: 14px; }
.day.quiet h2 { font-size: 24px; font-variation-settings: 'wdth' 75; color: var(--ink-soft); }

.pkg {
  position: relative;
  display: grid; grid-template-columns: 64px 1fr auto; gap: 1px 12px; align-items: center;
  width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 14px 10px 10px; margin: 8px 0;
}
.thumb {
  grid-row: 1 / 4; grid-column: 1; position: relative; width: 64px; height: 64px; border-radius: 10px;
  background: var(--paper); overflow: hidden; display: grid; place-items: center;
  font-weight: 800; font-size: 24px; color: var(--ink-soft); font-variation-settings: 'wdth' 75;
}
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #fff; }
.thumb img.logo { inset: 16px; width: 32px; height: 32px; object-fit: contain; background: transparent; border-radius: 6px; }
.thumb .mini-logo { position: absolute; right: 3px; bottom: 3px; width: 18px; height: 18px; border-radius: 5px; background: #fff; box-shadow: 0 0 0 1.5px #fff; object-fit: contain; inset: auto 3px 3px auto; }
.store-line { display: flex; align-items: center; gap: 6px; }
.pkg::before { content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 0 4px 4px 0; background: transparent; }
.pkg[data-tone='label']::before { background: var(--label); }
.pkg[data-tone='alert']::before { background: var(--alert); }
.pkg .store { font-size: 13px; color: var(--ink-soft); }
.pkg .name { font-weight: 650; font-size: 17px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pkg .store, .pkg .name { grid-column: 2; }
.pkg .where { grid-column: 2 / 4; font-size: 14px; color: var(--ink-soft); }
.pkg .where strong { color: var(--ink); font-weight: 600; }
.pkg[data-tone='alert'] .where strong { color: var(--alert); }
.pkg[data-tone='done'] .where strong { color: var(--done); }
.pkg .carrier { grid-row: 1 / 3; grid-column: 3; align-self: start; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); }
.pkg:active { transform: scale(0.99); }
.pkg.delivered { opacity: 0.72; }

.empty { margin: 72px 8px; text-align: center; color: var(--ink-soft); }
.empty h2 { color: var(--ink); font-size: 22px; margin: 0 0 6px; }

.notice { background: #FFF6D1; border: 1px solid #F1D774; border-radius: 12px; padding: 12px 14px; margin: 12px 0; font-size: 14px; }
.notice b { display: block; margin-bottom: 2px; }
.notice a { color: var(--ink); word-break: break-all; }
.notice .row { display: flex; gap: 10px; margin-top: 8px; }

/* Sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(20, 33, 61, 0.35); z-index: 10; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11;
  max-width: 640px; margin: 0 auto; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--card); border-radius: 20px 20px 0 0;
  padding: 8px 20px calc(var(--safe-bottom) + 28px);
}
.sheet.opening { animation: rise 0.22s ease-out; }
@keyframes rise { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet.opening { animation: none; } .pkg:active { transform: none; } }
.sheet-head {
  position: sticky; top: -8px; z-index: 2; margin: -8px -20px 6px; padding: 8px 12px 6px;
  background: var(--card); display: flex; align-items: center; justify-content: flex-end; min-height: 52px;
  touch-action: none; border-radius: 20px 20px 0 0;
}
.sheet-grip { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
.sheet-close { border: 0; background: var(--paper); color: var(--ink); font-weight: 650; font-size: 16px; padding: 8px 16px; border-radius: 999px; min-height: 40px; }
.sheet.dragging { transition: none; }
.sheet.settling { transition: transform 0.2s ease-out; }
.sheet h3 { margin: 0; font-size: 24px; line-height: 1.2; }
.sheet .sub { color: var(--ink-soft); margin-top: 4px; font-size: 14px; }
.eta-big { margin: 18px 0 4px; font-size: 40px; line-height: 1; font-weight: 800; font-variation-settings: 'wdth' 62; }

.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 16px 0 6px; padding: 0; list-style: none; }
.steps li { font-size: 12px; color: var(--ink-soft); }
.steps li::before { content: ''; display: block; height: 6px; border-radius: 3px; background: var(--line); margin-bottom: 6px; }
.steps li.on { color: var(--ink); font-weight: 600; }
.steps li.on::before { background: var(--ink); }
.steps.alert li.on::before { background: var(--alert); }
.steps.done li.on::before { background: var(--done); }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 50px; border-radius: 12px; border: 0; background: var(--ink); color: #fff;
  font-weight: 650; font-size: 16px; text-decoration: none; margin: 10px 0;
}
.btn.secondary { background: var(--paper); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--alert); border: 1px solid var(--line); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-row .btn { margin: 0; }

.block { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 14px; }
.block h4 { margin: 0 0 8px; font-size: 15px; }
.track-no { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--paper); border-radius: 10px; padding: 10px 12px; font-variant-numeric: tabular-nums; word-break: break-all; }
.track-no button { border: 0; background: none; font-weight: 600; color: var(--focus); flex: none; }
.items { margin: 0; padding: 0; list-style: none; }
.items li { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.items .item-img { width: 52px; height: 52px; border-radius: 9px; object-fit: cover; background: var(--paper); flex: none; }
.sheet-logo { width: 22px; height: 22px; border-radius: 5px; vertical-align: -5px; margin-right: 6px; }
.search { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 16px; background: var(--paper); margin: 12px 0 4px; }
.month { margin: 18px 0 2px; font-weight: 700; color: var(--ink-soft); font-size: 15px; }

.events { list-style: none; margin: 0; padding: 0; }
.events li { position: relative; padding: 0 0 14px 18px; border-left: 2px solid var(--line); margin-left: 5px; }
.events li::before { content: ''; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.events li:first-child::before { background: var(--ink); }
.events li:last-child { border-left-color: transparent; }
.events .ev-text { font-weight: 600; font-size: 15px; }
.events .ev-meta { font-size: 13px; color: var(--ink-soft); }

.field { display: block; margin: 12px 0; }
.field span { display: block; font-size: 14px; color: var(--ink-soft); margin-bottom: 6px; }
.field input { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; font-size: 16px; }

.toggle { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.toggle input { width: 22px; height: 22px; accent-color: var(--ink); }
.log { font-size: 13px; color: var(--ink-soft); }
.log div { padding: 6px 0; border-bottom: 1px solid var(--line); }
.log b { color: var(--ink); font-weight: 600; }

.login { max-width: 360px; margin: 18vh auto 0; }
.login h1 { font-size: 56px; line-height: 0.95; margin: 0 0 18px; font-weight: 800; font-variation-settings: 'wdth' 62; }

.toast { position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 20px); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 20; }

#history-list { min-height: 55vh; }
