 :root {
      --bg: #f0f4f8;
      --surface: #ffffff;
      --surface2: #f7f9fc;
      --border: #dde3ec;
      --border2: #c8d2df;
      --accent: #2563eb;
      --accent-light: #eff4ff;
      --accent2: #0891b2;
      --accent2-light: #ecfeff;
      --success: #16a34a;
      --success-light: #f0fdf4;
      --warning: #d97706;
      --warning-light: #fffbeb;
      --danger: #dc2626;
      --text: #1e2d3d;
      --text2: #4a5f75;
      --text3: #8fa4b8;
      --radius: 12px;
      --radius-sm: 8px;
      --font: 'DM Sans', sans-serif;
      --mono: 'Space Mono', monospace;
      --header-h: 48px;
      --bar-h: 32px;
      --touch-min: 44px;
    }
    *, *::before, *::after { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color: transparent; }

    html, body {
      font-family: var(--font);
      background: var(--bg);
      color: var(--text);
      height: 100dvh; width: 100vw;
      overflow: hidden;
      display: flex; flex-direction: column;
      font-size: 14px;
      -webkit-text-size-adjust: 100%;
    }

    /* ── HEADER ── */
    .header {
      background: var(--surface);
      border-bottom: 1px solid var(--border);
      padding: 0 12px;
      display: flex; align-items: center; justify-content: space-between;
      flex-shrink: 0; height: var(--header-h);
      gap: 8px;
    }
    .logo { display: flex; align-items: center; gap: 7px; }
    .logo-icon {
      width: 30px; height: 30px; background: var(--accent);
      border-radius: 8px; display: flex; align-items: center;
      justify-content: center; color: white; font-size: 15px; flex-shrink: 0;
    }
    .logo-name { font-size: 14px; font-weight: 700; color: var(--text); }

    .header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

    .clock-block { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
    .clock {
      font-family: var(--mono); font-size: 13px; font-weight: 700;
      color: var(--accent); background: var(--accent-light);
      padding: 3px 7px; border-radius: 6px; white-space: nowrap;
    }
    .clock-date { font-size: 9px; color: var(--text3); font-family: var(--mono); white-space: nowrap; }

    /* ── WS BADGE ── */
    .ws-badge {
      display: flex; align-items: center; gap: 4px;
      font-size: 9px; padding: 4px 8px; border-radius: 100px;
      font-weight: 700; font-family: var(--mono); white-space: nowrap;
      border: 1px solid transparent;
    }
    .ws-badge.ok   { background: var(--success-light); color: var(--success); border-color: #bbf7d0; }
    .ws-badge.err  { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
    .ws-badge.conn { background: var(--accent-light); color: var(--accent); border-color: #bfdbfe; }
    .ws-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
    .ws-badge.ok .ws-dot   { background: var(--success); }
    .ws-badge.err .ws-dot  { background: var(--danger); }
    .ws-badge.conn .ws-dot { background: var(--accent); animation: sensorPulse 0.8s ease-in-out infinite; }
    @keyframes sensorPulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

    /* ── MAIN ── */
    .main {
      flex: 1; display: flex; align-items: center; justify-content: center;
      padding: 10px 10px 6px;
      overflow: hidden;
    }

    /* ── START SCREEN ── */
    #screen-start {
      max-width: 100%; width: 100%;
      display: flex; flex-direction: column;
      align-items: center; justify-content: center;
      min-height: 100%; gap: 0;
    }
    .start-hero {
      display: flex; flex-direction: column; align-items: center;
      gap: 12px; text-align: center; margin-bottom: 28px;
    }
    .start-logo-big {
      width: 64px; height: 64px; background: var(--accent);
      border-radius: 16px; display: flex; align-items: center;
      justify-content: center; font-size: 30px;
      box-shadow: 0 6px 24px rgba(37,99,235,0.22);
    }
    .start-title    { font-size: 28px; font-weight: 700; letter-spacing: -0.8px; color: var(--text); }
    .start-subtitle { font-size: 13px; color: var(--text2); max-width: 280px; line-height: 1.6; }

    /* ── SWIPE BUTTON ── */
    .swipe-wrapper {
      position: relative; width: 280px; height: 56px;
      background: var(--accent-light); border: 1.5px solid #bfdbfe;
      border-radius: 100px; display: flex; align-items: center;
      overflow: hidden; user-select: none; touch-action: none;
    }
    .swipe-track-text {
      position: absolute; left: 0; right: 0; text-align: center;
      font-size: 13px; font-weight: 600; color: var(--accent);
      pointer-events: none; transition: opacity 0.2s;
    }
    .swipe-arrows {
      position: absolute; right: 16px; display: flex; gap: 3px;
      pointer-events: none;
    }
    .swipe-arrows span { font-size: 14px; color: var(--accent); }
    .swipe-handle {
      position: absolute; left: 4px; width: 48px; height: 48px;
      border-radius: 50%; background: var(--accent);
      display: flex; align-items: center; justify-content: center;
      color: white; font-size: 20px; cursor: grab;
      box-shadow: 0 3px 12px rgba(37,99,235,0.3); z-index: 2;
    }
    .swipe-handle.released { transition: left 0.3s ease; }
    .swipe-wrapper.complete .swipe-track-text { opacity: 0; }
    .swipe-wrapper.complete .swipe-arrows { display: none; }
    .swipe-wrapper.complete .swipe-handle {
      background: var(--success);
      box-shadow: 0 3px 12px rgba(22,163,74,0.35);
    }

    /* ── SENSOR BAR ── */
    .sensor-bar {
      background: var(--surface); border-top: 1px solid var(--border);
      padding: 0 12px; display: flex; align-items: center; gap: 8px;
      flex-shrink: 0; height: var(--bar-h); overflow: hidden;
    }
    .sensor-bar-label {
      font-size: 8px; text-transform: uppercase; letter-spacing: 1px;
      color: var(--text3); font-weight: 700; flex-shrink: 0;
    }
    .sensor-items { display: flex; align-items: center; gap: 10px; flex: 1; overflow: hidden; }
    .sensor-item  { display: flex; align-items: center; gap: 4px; font-size: 9px; color: var(--text2); white-space: nowrap; }
    .sensor-dot   { width: 5px; height: 5px; border-radius: 50%; background: var(--border2); flex-shrink: 0; transition: all 0.3s; }
    .sensor-dot.connected { background: var(--success); }
    .sensor-dot.active    { background: var(--accent); animation: sensorPulse 0.6s ease-in-out infinite; }
    .sensor-dot.error     { background: var(--danger); }

    /* ── TOAST ── */
    .db-save-toast {
      position: fixed; bottom: calc(var(--bar-h) + 10px); right: 12px;
      background: var(--success); color: white; padding: 7px 14px;
      border-radius: 8px; font-size: 11px; font-weight: 700;
      display: none; z-index: 999;
    }
    .db-save-toast.show { display: block; animation: fadein 0.3s ease; }
    @keyframes fadein { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }

    @media (max-width: 359px) {
      .start-title { font-size: 24px; }
      .swipe-wrapper { width: 250px; }
    }
    @media (max-height: 580px) and (orientation: landscape) {
      .start-logo-big { width: 48px; height: 48px; font-size: 22px; }
      .start-title { font-size: 22px; }
      .start-hero { gap: 8px; margin-bottom: 16px; }
    }