:root {
  color-scheme: dark;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg:#14191c; --surface:#20282b; --line:#3b474a; --ink:#f3f5f5;
  --secondary:#afb8b9; --accent:#9ccab9; --error:#f09b96;
  --viewport-height:100vh;
  --usable-height:calc(var(--viewport-height) - var(--safe-top) - var(--safe-bottom));
  --safe-top:env(safe-area-inset-top, 0px);
  --safe-bottom:env(safe-area-inset-bottom, 0px);
  background:var(--bg); color:var(--ink);
}
@supports (height:100dvh) { :root { --viewport-height:100dvh } }
* { box-sizing:border-box }
[hidden] { display:none !important }
body { margin:0; min-height:var(--viewport-height) }
button,input,textarea,a { font:inherit; -webkit-tap-highlight-color:transparent }
button,a { touch-action:manipulation }
button { color:inherit; cursor:pointer; background:none; border:none }
button:disabled { cursor:default }
button:focus-visible,a:focus-visible { outline:2px solid var(--accent); outline-offset:3px }
.shell { max-width:56rem; min-height:var(--viewport-height); margin:auto; padding:var(--safe-top) max(20px,env(safe-area-inset-right)) var(--safe-bottom) max(20px,env(safe-area-inset-left)); display:flex; flex-direction:column }
header { min-height:72px; display:flex; align-items:center; justify-content:space-between; border-bottom:1px solid #30393c }
.brand { display:flex; align-items:center; gap:10px; font-weight:720; letter-spacing:-.04em; font-size:1.32rem }
.monogram { background:var(--accent); color:#1a3029; font:900 18px/26px system-ui; text-align:center; width:27px; height:27px; border-radius:7px }
#login { display:grid; flex:1; place-items:center; padding:28px 0 }
.login-card { background:var(--surface); width:min(100%,27rem); overflow:hidden; border:1px solid var(--line); border-radius:22px; box-shadow:0 18px 70px #080c0d3d }
.signal-art { position:relative; height:96px; overflow:hidden; background:repeating-linear-gradient(90deg,transparent 0 23px,#9ccab90a 23px 24px),repeating-linear-gradient(0deg,transparent 0 23px,#9ccab90a 23px 24px),linear-gradient(112deg,#253f38,#273333 70%,#212b2c); border-bottom:1px solid #37433f; }
.radar { position:absolute; top:50%; left:50%; display:grid; place-items:center; }
.radar i,.radar span { position:absolute; border-radius:50% }
.radar i { width:104px; height:104px; border:1px solid #a2cabc30 }
.radar i:nth-child(2) { width:160px; height:160px; border-color:#a2cabc20 }
.radar i:nth-child(3) { width:222px; height:222px; border-color:#a2cabc12 }
.radar span { width:64px; height:64px; background:#2b403a url('./assets/car.svg') center / 42px no-repeat; border:1px solid #657f75 }
.login-content { padding:28px clamp(20px,5vw,34px) 32px }
h1,h2,p { margin:0 }
h1 { font-size:clamp(2rem,5vw,2.6rem); letter-spacing:-.055em; line-height:1.12 }
h2 { font-size:1.3rem; letter-spacing:-.03em }
.intro { color:var(--secondary); font-size:1.05rem; margin:9px 0 26px }
label { display:block; margin:18px 0 8px; font-size:.94rem; color:#d3dbd9 }
input,textarea { width:100%; border-radius:9px; background:#172023; border:1px solid #445154; color:var(--ink); padding:13px 14px; }
input { height:52px }
input::placeholder { color:#929e9d }
input:focus,textarea:focus { outline:2px solid var(--accent); outline-offset:1px }
.password-wrap { position:relative }
.password-wrap input { padding-right:50px }
.eye { position:absolute; right:0; height:100%; width:48px; color:var(--secondary) }
.eye svg { width:21px; vertical-align:middle }
.primary,.secondary { min-height:46px; padding:12px 16px; border-radius:9px; font-weight:650; text-align:center; text-decoration:none; display:inline-flex; align-items:center; justify-content:center }
.primary { background:var(--accent); color:#152b23 }
.primary:hover { background:#addcca }
.secondary { background:#374346 }
.primary:disabled { opacity:.6 }
form .primary { margin-top:24px; width:100% }
.error { color:var(--error); font-size:.93rem }
.error:not(:empty) { margin-top:12px }
.quiet { color:var(--secondary); min-height:44px; padding:6px 12px }
footer { margin-top:auto; padding:16px 0 18px; text-align:center; color:#a6b1b0; font-size:.82rem }
footer span { padding:0 .3em }
#dashboard { margin:30px auto 20px; width:min(100%,43rem) }
.headline,.status-strip,.status,#wake-tools { display:flex; align-items:center; gap:10px }
.headline,.status-strip { justify-content:space-between }
#model { color:var(--accent); font-weight:600 }
.mono { color:var(--secondary); font: .88rem/1.5 ui-monospace,Menlo,monospace; margin:7px 0 18px; overflow-wrap:anywhere }
.status-strip { background:var(--surface); padding:7px 12px; border:1px solid var(--line); border-radius:12px; flex-wrap:wrap }
.status { padding:0; min-height:44px; text-align:left; line-height:1.3; color:var(--secondary) }
.status img { width:32px; filter:grayscale(1) }
.status.online { color:var(--accent) }
.status.online img { filter:none }
#wake-tools { gap:0 }
#wake-notice { color:var(--secondary); font-size:.9rem; margin:.5rem 0 }
#wake,#settings { min-height:44px; color:var(--accent) }
#settings { min-width:44px }
#settings img { width:21px; vertical-align:middle }
.metrics { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; margin:16px 0 24px }
.metric { border:1px solid var(--line); background:var(--surface); border-radius:14px; text-align:left; padding:clamp(14px,3vw,22px); display:flex; flex-direction:column; align-items:start; gap:8px; }
.metric-title { display:flex; align-items:center; gap:7px; font-size:.93rem; color:var(--secondary) }
.metric-title img { width:20px; height:20px }
.metric strong { font-size:clamp(1.4rem,5vw,2.15rem); letter-spacing:-.04em; font-variant-numeric:tabular-nums }
.metric small { color:var(--secondary); font-size:.82rem; line-height:1.3 }
.metric .range { font-size:1rem; font-weight:550; border-top:1px solid var(--line); padding-top:9px; margin-top:3px; width:100% }
.control-section h2 { margin:0 0 16px }
.control-panel { position:relative; padding:16px 4px; border:1px solid var(--line); border-radius:15px; background:#1b2225 }
#controls { display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); row-gap:20px }
.action { grid-column:span 2; padding:0 4px; display:flex; flex-direction:column; align-items:center; gap:5px; font-size:.94rem; font-weight:600; line-height:1.25; overflow-wrap:anywhere }
.action:nth-child(4) { grid-column:2 / span 2 }
.action .circle { width:clamp(54px,15vw,78px); aspect-ratio:1; border-radius:50%; border:2px solid #465357; background:var(--surface); display:grid; place-items:center; margin-bottom:3px }
.circle i { width:65%; height:65%; background:var(--ink); -webkit-mask:var(--icon) center/contain no-repeat; mask:var(--icon) center/contain no-repeat }
.action.active .circle { background:#243b36; border-color:var(--accent) }
.action.active i { background:var(--accent) }
.action:disabled:not(.active) i { background:#83918f }
.action small { color:var(--secondary); font-weight:400; font-size:.8rem; line-height:1.3 }
#command-overlay { position:absolute; inset:0; border-radius:inherit; background:#192123ee; display:flex; gap:10px; align-items:center; justify-content:center; text-align:center; padding:22px }
.spinner { width:20px; height:20px; flex-shrink:0; border:2px solid var(--line); border-top-color:var(--accent); border-radius:50%; animation:spin 1s linear infinite }
@keyframes spin { to { transform:rotate(360deg) } }
@media(prefers-reduced-motion:reduce){.spinner{animation:none}}
#command-notice:not(:empty),#copy-result:not(:empty) { margin-top:12px; color:var(--accent) }
dialog { width:min(calc(100% - 32px),26rem); max-height:85vh; overflow:auto; border:1px solid #52605e; border-radius:18px; background:var(--surface); color:var(--ink); padding:24px; box-shadow:0 16px 70px #0007 }
dialog::backdrop { background:#05090bac }
dialog p { line-height:1.5; margin-top:12px }
#detail-text { white-space:pre-line; overflow-wrap:anywhere }
.sms-actions { display:flex; flex-wrap:wrap; gap:8px; margin-top:22px }
.sms-actions > * { flex:1 }
.close { display:block; margin:10px auto 0 }
#account-actions { display:grid; gap:10px; margin:18px 0 }
#password-change { margin-top:18px }
#cancel-password { display:block; margin:8px auto 0 }
#account-dialog {
  top:calc(var(--visible-top, 0px) + var(--safe-top) + 12px);
  bottom:calc(var(--visible-bottom, 0px) + var(--safe-bottom) + 12px);
  max-height:calc(var(--visible-height, var(--viewport-height)) - var(--safe-top) - var(--safe-bottom) - 24px);
  overscroll-behavior:contain;
}
#account-notice:not(:empty) {
  position:fixed;
  z-index:2;
  bottom:calc(var(--safe-bottom) + 12px);
  inset-inline:0;
  width:fit-content;
  max-width:calc(100% - 32px);
  margin:auto;
  padding:10px 16px;
  border:1px solid var(--accent);
  border-radius:12px;
  background:var(--surface);
  color:var(--ink);
  text-align:center;
  pointer-events:none;
}

/* Scale the cards and controls between the short Safari viewport and standalone. */
@media (max-width:34rem) {
  .shell {
    padding-right:max(14px,env(safe-area-inset-right));
    padding-left:max(14px,env(safe-area-inset-left));
  }
  .shell:has(#dashboard:not([hidden])) header { min-height:clamp(44px,calc(var(--usable-height) * .06),52px) }
  #dashboard { margin:clamp(4px,calc(var(--usable-height) * .01),9px) auto 0 }
  .headline h1 { font-size:1.75rem }
  .mono { margin:1px 0 6px }
  .status-strip { gap:0 4px; padding:2px 7px }
  .status-strip button,.metric,.action { margin:0 }
  .status { flex:1 1 min-content; min-width:44px; gap:6px; padding:0 2px }
  .status img { width:26px; flex:none }
  .status span { min-width:0; overflow-wrap:anywhere }
  #wake-tools { min-width:0; max-width:100%; margin-inline-start:auto }
  #wake { min-width:44px; padding:2px 3px; line-height:1.18; overflow-wrap:anywhere }
  .metrics { gap:clamp(8px,calc(var(--usable-height) * .014),12px); margin:10px 0 14px }
  .metric {
    padding:clamp(10px,calc(var(--usable-height) * .04 - 14px),16px) 12px;
    gap:clamp(3px,calc(var(--usable-height) * .02 - 8px),6px);
    min-width:0; min-height:44px; overflow-wrap:anywhere;
  }
  .metric strong { font-size:1.35rem; line-height:1.15 }
  .metric .range { margin:2px 0 0; padding-top:3px; font-size:.92rem }
  .metric-title { gap:5px }
  .control-section h2 { margin-bottom:6px; font-size:1.2rem }
  .control-panel { padding:8px 3px }
  #controls { row-gap:9px }
  .action { gap:2px; min-height:44px; padding-inline:3px }
  .action .circle {
    --diameter:clamp(52px,calc(var(--usable-height) * .09),68px);
    width:var(--diameter); height:var(--diameter); margin:0;
  }
  .action small { font-size:.84rem }
  footer { padding:8px 0 }
}

/* Keep the lower climate labels beside their circles when vertical room is limited. */
@media (max-width:34rem) and (max-height:44rem) {
  .vehicle-heading { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:2px 6px }
  .vehicle-heading .headline { gap:5px }
  #dashboard { margin-top:3px }
  .mono { margin-bottom:3px }
  .headline h1 { font-size:1.5rem }
  .control-panel { padding:6px 3px }
  .action:nth-child(n+4) {
    grid-column:span 3;
    display:grid;
    grid-template-columns:auto minmax(0,1fr);
    grid-template-rows:auto auto;
    align-content:center;
    justify-self:center;
    column-gap:6px;
    text-align:left;
  }
  .action:nth-child(n+4) .circle { grid-row:span 2 }
  .action:nth-child(n+4) > span:nth-child(2) { align-self:end }
  .action:nth-child(n+4) small { align-self:start }
}

/* With both Safari toolbars on a small phone, share one line for title and value. */
@media (max-width:34rem) and (max-height:38rem) {
  .metric {
    flex-flow:row wrap;
    align-content:center;
    align-items:center;
    justify-content:space-between;
    padding-inline:10px;
    column-gap:4px;
  }
  .metric small,.metric .range { flex-basis:100% }
  .metric strong { font-size:1.18rem }
  .metric-title img { width:17px; height:17px }
  .metrics { margin:6px 0 8px }
}

@media (max-width:380px) {
  .login-content { padding:20px }
}
