/* Kurant app demo: the Android app's screens, running its simulator in the browser.
   Layout and states mirror ebike-app (DashboardScreen, SettingsScreen, SpeedModeUi,
   ConnectionSheet). Palette is the app's RideTheme, with the Kurant cyan as primary.
   Everything is scoped under .kd so it never leaks into the page. */

.kd {
  --kd-ink: #0A0D10;
  --kd-panel: #141A20;
  --kd-high: #1A2129;
  --kd-highest: #212A33;
  --kd-line: #3A4652;
  --kd-soft: #26303A;
  --kd-text: #EEF2F5;
  --kd-mute: #9AA7B4;
  --kd-primary: var(--cyan, #00D2FF);
  --kd-on-primary: #061015;
  --kd-primary-box: rgba(0, 210, 255, .14);
  --kd-amber: #FFB547;
  --kd-amber-box: rgba(255, 181, 71, .14);
  --kd-red: #FF6B6B;
  --kd-red-box: rgba(255, 107, 107, .14);
  --kd-green: #4ADE80;
  --kd-green-box: rgba(74, 222, 128, .14);
  --kd-sky: #5BC8F5;
  --kd-sky-box: rgba(91, 200, 245, .14);
  --kd-r-s: 10px;
  --kd-r-m: 14px;
  --kd-r-l: 18px;

  position: relative;
  display: grid;
  grid-template-rows: 30px minmax(0, 1fr) 62px;
  height: min(640px, 80svh);
  min-height: 520px;
  border-radius: 28px;
  overflow: hidden;
  background: var(--kd-ink);
  color: var(--kd-text);
  font-family: var(--sans, system-ui, sans-serif);
  font-size: 13px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  text-align: left;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.kd *, .kd *::before, .kd *::after { box-sizing: border-box; }
.kd :where(button, input) { font: inherit; color: inherit; }
.kd :where(button) { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
.kd :where(button:disabled) { cursor: default; }
.kd :focus-visible { outline: 2px solid var(--kd-primary); outline-offset: 2px; }
.kd svg { display: block; flex: none; }
.kd [hidden] { display: none !important; }

/* Status bar + nav */
.kd-status { display: flex; align-items: center; justify-content: space-between; padding: 0 22px; font-size: 12px; font-weight: 600; }
.kd-sim-tag { font-family: var(--mono, monospace); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--kd-primary); font-weight: 500; }
.kd-nav { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--kd-soft); background: var(--kd-ink); }
.kd-tab { display: grid; justify-items: center; align-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--kd-mute); }
.kd-tab .kd-tab-ico { display: grid; place-items: center; width: 56px; height: 28px; border-radius: 14px; transition: background-color .2s; }
.kd-tab[aria-selected="true"] { color: var(--kd-text); }
.kd-tab[aria-selected="true"] .kd-tab-ico { background: var(--kd-primary-box); color: var(--kd-primary); }

/* Scrolling pages */
.kd-body { position: relative; min-height: 0; }
.kd-page {
  position: absolute; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  padding: 6px 14px 20px;
  scrollbar-width: thin; scrollbar-color: var(--kd-soft) transparent;
  touch-action: pan-y;
}
@media (pointer: fine) { .kd-page { overscroll-behavior: contain; } }
.kd-page::-webkit-scrollbar { width: 6px; }
.kd-page::-webkit-scrollbar-thumb { background: var(--kd-soft); border-radius: 3px; }
.kd-more {
  position: absolute; left: 0; right: 0; bottom: 0; height: 30px; pointer-events: none;
  background: linear-gradient(to bottom, rgba(10, 13, 16, 0), var(--kd-ink));
  display: grid; place-items: end center; padding-bottom: 0; color: var(--kd-mute);
  opacity: 0; transition: opacity .25s;
}
.kd-body[data-more="true"] .kd-more { opacity: 1; }

/* Building blocks */
.kd-panel { background: var(--kd-panel); border-radius: var(--kd-r-l); padding: 14px; }
.kd-panel.flush { padding: 0; }
.kd-section { font-family: var(--mono, monospace); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--kd-mute); padding: 20px 4px 8px; }
.kd-title { font-size: 22px; font-weight: 600; padding: 14px 0 10px; }
.kd-overline { font-family: var(--mono, monospace); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--kd-mute); }
.kd-t { font-size: 14px; font-weight: 600; }
.kd-s { font-size: 12px; color: var(--kd-mute); }
.kd-readout { font-size: 17px; font-weight: 600; }
.kd-divider { height: 1px; background: var(--kd-soft); margin: 0; border: 0; }
.kd-flush-divider { margin: 0 14px; }
.kd-row { display: flex; align-items: center; gap: 10px; }
.kd-grow { flex: 1; min-width: 0; }
.kd-badge { display: inline-block; border-radius: 999px; padding: 2px 8px; font-size: 10.5px; font-weight: 600; white-space: nowrap; background: var(--kd-highest); color: var(--kd-mute); }
.kd-badge.ok { background: var(--kd-green-box); color: var(--kd-green); }
.kd-badge.accent { background: var(--kd-primary-box); color: var(--kd-primary); }
.kd-badge.caution { background: var(--kd-amber-box); color: var(--kd-amber); }
.kd-badge.error { background: var(--kd-red-box); color: var(--kd-red); }
.kd-badge.info { background: var(--kd-sky-box); color: var(--kd-sky); }
.kd-btn-text { color: var(--kd-primary); font-weight: 600; padding: 8px 10px; border-radius: 999px; }
.kd-btn-text:disabled { color: var(--kd-mute); opacity: .5; }
.kd-btn { background: var(--kd-primary); color: var(--kd-on-primary); font-weight: 600; padding: 8px 16px; border-radius: 999px; }
.kd-btn:disabled { background: var(--kd-highest); color: var(--kd-mute); }
.kd-btn.danger { background: var(--kd-red); color: #1a0606; }
.kd-btn.danger:disabled { background: var(--kd-highest); color: var(--kd-mute); }

/* Ride: status row */
.kd-top { display: flex; gap: 8px; padding-top: 6px; }
.kd-pill { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 10px 0 14px; border-radius: 999px; background: var(--kd-panel); font-weight: 600; }
.kd-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--kd-green); animation: kd-pulse 2s ease-in-out infinite; }
@keyframes kd-pulse { 50% { opacity: .35; } }
.kd-alerts { display: grid; gap: 8px; padding-top: 10px; }
.kd-alerts:empty { padding-top: 0; }
.kd-alert { display: flex; gap: 10px; align-items: center; border-radius: var(--kd-r-m); padding: 10px 12px; background: var(--kd-sky-box); }
.kd-alert svg { color: var(--kd-sky); }

/* Ride: gauge */
.kd-gauge { position: relative; width: 100%; max-width: 272px; aspect-ratio: 1; margin: 2px auto 0; }
.kd-gauge svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.kd-gauge .track { stroke: var(--kd-soft); }
.kd-gauge .fill { stroke: var(--kd-primary); transition: stroke-dasharray .35s ease-out, stroke .3s; }
.kd-gauge .fill.over { stroke: var(--kd-red); }
.kd-gauge .tick { stroke: var(--kd-line); }
.kd-gauge .limit { stroke: var(--kd-amber); transition: all .3s; }
.kd-read { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 2px; }
.kd-num { display: flex; align-items: baseline; line-height: 1; }
.kd-num b { font-size: 68px; font-weight: 600; letter-spacing: -.03em; }
.kd-num i { font-style: normal; font-size: 30px; font-weight: 600; color: var(--kd-mute); }
.kd-unit { font-size: 13px; color: var(--kd-mute); }
.kd-limit { font-family: var(--mono, monospace); font-size: 11px; letter-spacing: .1em; color: var(--kd-amber); margin-top: 4px; }

/* Hold-to-confirm */
.kd-hold { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 9px 14px; border-radius: var(--kd-r-l); background: var(--kd-high); overflow: hidden; touch-action: pan-y; }
.kd-hold.on-highest { background: var(--kd-highest); }
.kd-hold::before { content: ""; position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--p, 0)); background: var(--hold-fill, var(--kd-primary)); opacity: .32; }
.kd-hold.releasing::before { transition: transform .28s ease-out; }
.kd-hold > * { position: relative; }
.kd-hold:disabled > * { opacity: .45; }
.kd-hold .kd-t { font-size: 15px; }

/* Ride: stats + assist */
.kd-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.kd-stat { background: var(--kd-panel); border-radius: var(--kd-r-l); padding: 11px 14px; }
.kd-stat-v { display: flex; align-items: baseline; gap: 3px; margin-top: 3px; }
.kd-stat-v b { font-size: 24px; font-weight: 600; }
.kd-stat-v span { color: var(--kd-mute); font-size: 12px; }
.kd-bar { height: 4px; border-radius: 2px; background: var(--kd-soft); margin-top: 8px; overflow: hidden; }
.kd-bar i { display: block; height: 100%; width: var(--w, 0%); background: var(--kd-green); border-radius: 2px; transition: width .3s; }
.kd-bar i.low { background: var(--kd-amber); }
.kd-bar i.crit { background: var(--kd-red); }
.kd-assist-row { display: flex; gap: 10px; margin-top: 10px; }
.kd-assist { position: relative; flex: 1; display: grid; grid-template-columns: repeat(6, 1fr); height: 56px; border-radius: var(--kd-r-l); background: var(--kd-high); }
.kd-assist .ind { position: absolute; top: 5px; bottom: 5px; left: 5px; width: calc(100% / 6 - 10px); border-radius: var(--kd-r-m); background: var(--kd-primary); transform: translateX(calc(var(--i, 0) * (100% + 10px))); transition: transform .32s cubic-bezier(.3, 1.3, .5, 1); }
.kd-assist button { position: relative; display: grid; place-items: center; font-size: 15px; font-weight: 600; transition: color .2s; }
.kd-assist button[aria-checked="true"] { color: var(--kd-on-primary); }
.kd-assist button:first-of-type { font-size: 12px; }
.kd-light { width: 56px; height: 56px; border-radius: var(--kd-r-l); background: var(--kd-high); display: grid; place-items: center; color: var(--kd-mute); transition: background-color .2s, color .2s; }
.kd-light[aria-pressed="true"] { background: var(--kd-amber); color: #1d1300; }

/* Settings */
.kd-mode-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kd-mode-tile { border: 1px solid var(--kd-soft); border-radius: var(--kd-r-m); background: var(--kd-high); padding: 11px 12px; }
.kd-mode-tile .kd-row svg { color: var(--accent); }
.kd-mode-tile .kd-readout { color: var(--kd-mute); }
.kd-mode-tile.active { border: 2px solid var(--accent); padding: 10px 11px; background: var(--accent-box); }
.kd-mode-tile.active .kd-readout { color: var(--accent); }
.kd-gap { height: 12px; }
.kd-range-wrap { padding: 12px 0; }
.kd-range { width: 100%; margin: 12px 0 0; accent-color: var(--accent, var(--kd-primary)); height: 24px; cursor: pointer; touch-action: pan-y; }
.kd-row-btn { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 10px 0; }
.kd-switch { position: relative; flex: none; width: 46px; height: 28px; border-radius: 14px; background: var(--kd-highest); border: 2px solid var(--kd-line); transition: background-color .2s, border-color .2s; }
.kd-switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 16px; height: 16px; border-radius: 50%; background: var(--kd-mute); transition: transform .2s, background-color .2s, width .2s, height .2s, top .2s; }
.kd-switch[aria-checked="true"] { background: var(--kd-primary); border-color: var(--kd-primary); }
.kd-switch[aria-checked="true"]::after { transform: translateX(16px); top: 2px; left: 2px; width: 20px; height: 20px; background: var(--kd-on-primary); }
.kd-setting { padding: 14px; }
.kd-setting .kd-s { margin-top: 2px; }
.kd-lock { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; font-size: 12px; color: var(--kd-mute); }
.kd-int { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.kd-int .kd-range { margin: 0; }
.kd-icon-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--kd-highest); display: grid; place-items: center; flex: none; }
.kd-icon-btn:disabled { opacity: .4; }
.kd-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.kd-chip { border: 1px solid var(--kd-line); border-radius: 8px; padding: 5px 10px; font-size: 12px; font-weight: 500; }
.kd-chip[aria-checked="true"] { background: var(--kd-primary-box); border-color: transparent; color: var(--kd-primary); }
.kd-staged { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.kd-staged .kd-grow { color: var(--kd-mute); font-size: 13px; }
.kd-nav-row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 14px; min-height: 56px; }
.kd-nav-row > svg { color: var(--kd-mute); }
.kd-nav-row:disabled .kd-t { color: var(--kd-mute); }
.kd-foot { font-size: 11px; color: var(--kd-mute); padding-top: 20px; }

/* Overlays: sheet, dialogs, snackbar — all stay inside the phone. */
.kd-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); z-index: 5; }
.kd-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; max-height: 86%;
  overflow-y: auto; background: var(--kd-panel); border-radius: 22px 22px 0 0; padding: 8px 16px 20px;
  animation: kd-up .25s ease-out;
}
@keyframes kd-up { from { transform: translateY(40px); opacity: 0; } }
.kd-grip { width: 32px; height: 4px; border-radius: 2px; background: var(--kd-line); margin: 4px auto 12px; }
.kd-option { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border-radius: var(--kd-r-m); background: var(--kd-high); border: 1px solid transparent; margin-bottom: 8px; }
.kd-option[aria-checked="true"] { border: 2px solid var(--kd-primary); padding: 11px; background: var(--kd-primary-box); }
.kd-option:disabled { opacity: .55; }
.kd-dialog {
  position: absolute; left: 16px; right: 16px; top: 50%; z-index: 7; transform: translateY(-50%);
  max-height: 88%; overflow-y: auto; background: var(--kd-highest); border-radius: 24px; padding: 20px 18px 12px;
  display: grid; gap: 12px; animation: kd-pop .2s ease-out;
}
@keyframes kd-pop { from { opacity: 0; transform: translateY(-46%); } }
.kd-dialog h3 { margin: 0; font-size: 18px; font-weight: 600; line-height: 1.3; }
.kd-dialog p { margin: 0; font-size: 13px; color: var(--kd-text); }
.kd-dialog .kd-ico-head { color: var(--kd-amber); }
.kd-dialog .kd-ico-head.error { color: var(--kd-red); }
.kd-dialog .kd-change { background: var(--kd-panel); border-radius: var(--kd-r-m); padding: 10px 12px; font-weight: 600; }
.kd-dialog input[type="text"] { width: 100%; background: transparent; border: 1px solid var(--kd-line); border-radius: 8px; padding: 10px 12px; color: var(--kd-text); user-select: text; -webkit-user-select: text; }
.kd-dialog input[type="text"]:focus { outline: none; border-color: var(--kd-primary); }
.kd-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 4px; }
.kd-list { display: grid; }
.kd-list button { padding: 10px 6px; border-radius: 8px; font-size: 14px; display: flex; justify-content: space-between; gap: 8px; }
.kd-list button[aria-checked="true"] { color: var(--kd-primary); font-weight: 600; }
.kd-snack {
  position: absolute; left: 14px; right: 14px; bottom: 74px; z-index: 8; background: var(--kd-text); color: var(--kd-ink);
  border-radius: 8px; padding: 11px 14px; font-weight: 500; box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: none;
}
.kd-snack.show { opacity: 1; transform: none; }

/* Phone frame tweaks when the live demo replaces the static picture. */
.phone.kd-live { width: min(332px, 100%); padding: 10px; border-radius: 40px; }
.demo-hint { font-size: 13px; color: var(--mute); text-align: center; max-width: 34ch; margin: 0; }
.demo-hint b { color: var(--fg); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .kd *, .kd *::before, .kd *::after { animation: none !important; transition: none !important; }
}
.kd-hold, .kd-assist button, .kd-light { -webkit-touch-callout: none; }
figure.device { margin: 0; }
