:root {
  --bg: #f2f4f7;
  --card: #ffffff;
  --text: #15202b;
  --muted: #5b6875;
  --line: #d8dee5;
  --brand: #0f5c8c;
  --brand-text: #ffffff;
  --rec: #d92d20;
  --ok: #157f3b;
  --warn-bg: #fff4d6;
  --warn-text: #6b4b00;
  --err-bg: #fde8e6;
  --err-text: #8a1c12;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1419;
    --card: #18212a;
    --text: #e8edf2;
    --muted: #9aa8b5;
    --line: #2c3946;
    --brand: #3a9ad9;
    --brand-text: #08131c;
    --rec: #ff5a4d;
    --ok: #4cc27a;
    --warn-bg: #3a2f10;
    --warn-text: #f5d98a;
    --err-bg: #3d1714;
    --err-text: #ffb4ab;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }

.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: var(--brand); color: var(--brand-text);
}
.bar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.bar-title strong { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-title .muted { color: inherit; opacity: .8; font-size: 13px; }
.icon-btn {
  width: 44px; height: 44px; border: 0; border-radius: 10px;
  background: rgba(255,255,255,.15); color: inherit; font-size: 22px; cursor: pointer;
}

main { max-width: 680px; margin: 0 auto; padding: 12px 16px 40px; }

#search {
  width: 100%; padding: 12px 14px; margin: 4px 0 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card);
}

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px;
  margin-bottom: 12px;
}
.cards .card { margin: 0; }
.wo-card { width: 100%; text-align: left; cursor: pointer; display: block; }
.wo-card:active { transform: scale(.99); }
.wo-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wo-number { font-weight: 700; }
.wo-vehicle { font-size: 20px; font-weight: 700; margin-top: 2px; }
.pill { font-size: 13px; padding: 2px 10px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tasks { margin: 8px 0 0; padding-left: 20px; color: var(--muted); }
.tasks li { margin: 2px 0; }
.small { font-size: 14px; }

.recorder { text-align: center; }
.rec-btn {
  width: 100%; min-height: 120px; border: 0; border-radius: 18px;
  background: var(--rec); color: #fff; font-size: 22px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 14px; cursor: pointer;
}
.rec-btn .rec-dot { width: 26px; height: 26px; border-radius: 50%; background: #fff; }
.rec-btn.recording { background: #222; }
.rec-btn.recording .rec-dot { border-radius: 5px; background: var(--rec); animation: pulse 1.2s infinite; }
.rec-btn:disabled { opacity: .5; }
@keyframes pulse { 50% { opacity: .35; } }
.rec-live { margin-top: 12px; }
.rec-time { font-size: 34px; font-variant-numeric: tabular-nums; font-weight: 700; }
.meter { height: 10px; border-radius: 6px; background: var(--line); overflow: hidden; margin: 6px 0 0; }
#rec-level { height: 100%; width: 0; background: var(--ok); transition: width .08s linear; }
.tip { font-size: 15px; margin: 12px 0 0; }

.draft-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.draft-head h2 { font-size: 18px; margin: 0 0 8px; }
textarea {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); resize: vertical; font-size: 16px; line-height: 1.4;
}
details { margin-top: 10px; }
summary { cursor: pointer; color: var(--muted); padding: 6px 0; }
.actions { display: grid; gap: 10px; margin-top: 14px; }
.primary, .secondary {
  min-height: 52px; border-radius: 12px; font-weight: 700; cursor: pointer; font-size: 18px;
}
.primary { background: var(--brand); color: var(--brand-text); border: 0; }
.secondary { background: transparent; border: 2px solid var(--brand); color: var(--brand); }
.primary:disabled, .secondary:disabled { opacity: .5; }
.danger-link { background: none; border: 0; color: var(--err-text); padding: 10px; cursor: pointer; }

.notice, .error, .banner {
  border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; font-size: 15px;
}
.notice, .banner { background: var(--warn-bg); color: var(--warn-text); }
.error { background: var(--err-bg); color: var(--err-text); }
#banners { max-width: 680px; margin: 0 auto; padding: 12px 16px 0; }
#banners:empty { display: none; }
.banner button, .notice button, .error button, .draft-chip button {
  margin: 8px 8px 0 0; padding: 8px 12px; border-radius: 8px;
  border: 1px solid currentColor; background: transparent; cursor: pointer; font-size: 15px;
}
.draft-chip {
  background: var(--card); border: 2px solid var(--brand); border-radius: 14px;
  padding: 12px 14px; margin-bottom: 10px;
}
.spinner {
  display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto; padding: 14px 16px; border-radius: 12px;
  background: #15202b; color: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.25); z-index: 10; font-size: 16px;
}
