  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

  :root {
    --bg: #0d0f12;
    --surface: #151820;
    --surface2: #1c2030;
    --border: rgba(255,255,255,0.07);
    --text: #f0f0ee;
    --muted: #7a8090;
    --faint: #3a4050;
    --green: #1cc98a;
    --blue: #5aabf0;
    --glow-1: rgba(90,171,240,0.11);
    --glow-2: rgba(28,201,138,0.08);
    --font-display: 'Bricolage Grotesque', sans-serif;
    --font-mono: 'Geist Mono', monospace;
  }

  :root[data-theme="light"] {
    --bg: #f5f4f0;
    --surface: #ffffff;
    --surface2: #eceae4;
    --border: rgba(0,0,0,0.08);
    --text: #1a1a18;
    --muted: #7a7a72;
    --faint: #c8c6be;
    --green: #0d9e68;
    --blue: #1a6db5;
    --glow-1: rgba(26,109,181,0.06);
    --glow-2: rgba(13,158,104,0.05);
  }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-display);
    min-height: 100vh;
    padding: 2rem 1.5rem 4rem;
  }

  body::before {
    content: '';
    position: fixed; inset: 0;
    background-image:
      radial-gradient(1100px 650px at 12% -8%, var(--glow-1), transparent 60%),
      radial-gradient(1000px 750px at 92% 28%, var(--glow-2), transparent 60%);
    pointer-events: none; z-index: 0;
  }

  .container { max-width: 820px; margin: 0 auto; position: relative; z-index: 1; }

  header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.5rem; padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
  }

  .logo { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

  .bolt {
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
  }

  .logo-text h1 { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
  .logo-text p { font-size: 0.7rem; color: var(--muted); font-family: var(--font-mono); margin-top: 3px; }

  .controls {
    display: flex; align-items: center; gap: 8px; flex-wrap: nowrap;
    justify-content: flex-end; flex-shrink: 0;
  }

  .controls label {
    font-size: 0.7rem; color: var(--muted);
    font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em;
    white-space: nowrap;
  }

  @media (max-width: 540px) {
    body { padding: 1rem 1rem 3rem; }
    header { flex-direction: column; align-items: stretch; gap: 0.6rem; }
    .controls { justify-content: flex-start; gap: 8px; }
    .controls label { display: none; }
    select { width: auto; flex: 0 1 auto; font-size: 0.8rem; }
  }

  select {
    background: var(--surface); color: var(--text);
    border: 1px solid var(--faint); border-radius: 6px;
    padding: 6px 10px; font-size: 0.8rem; font-family: var(--font-mono);
    cursor: pointer; outline: none; transition: border-color 0.2s;
  }
  select:hover, select:focus { border-color: rgba(255,255,255,0.2); }

  button {
    background: var(--surface2); color: var(--text);
    border: 1px solid var(--faint); border-radius: 6px;
    padding: 6px 14px; font-size: 0.8rem;
    font-family: var(--font-display); font-weight: 600;
    cursor: pointer; display: flex; align-items: center; gap: 6px;
    transition: background 0.2s, border-color 0.2s, transform 0.1s;
  }
  button:hover { background: rgba(255,255,255,0.07); border-color: rgba(255,255,255,0.15); }
  button:active { transform: scale(0.97); }

  .metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px; margin-bottom: 1.5rem;
  }

  @media (min-width: 600px) {
    .metrics { grid-template-columns: repeat(4, 1fr); }
  }

  .metric {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 1rem 1.1rem;
    position: relative; overflow: hidden;
    animation: fadeUp 0.4s ease both;
  }

  .metric::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: var(--accent-color, transparent);
    border-radius: 10px 10px 0 0;
  }

  @keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .metric-label { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; font-family: var(--font-mono); margin-bottom: 6px; }
  .metric-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1; margin-bottom: 4px; }
  .metrics .metric:first-child .metric-value { font-size: 2.3rem; letter-spacing: -0.02em; }
  .metric-sub { font-size: 0.7rem; color: var(--muted); font-family: var(--font-mono); }

  .chart-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 1.25rem; margin-bottom: 1.5rem;
  }

  .chart-header {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 1rem; flex-wrap: wrap; gap: 8px;
  }

  .chart-title { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; font-family: var(--font-mono); }

  .chart-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

  .share-btn {
    padding: 4px 10px; font-size: 0.7rem;
    font-family: var(--font-mono); font-weight: 500;
  }

  .legend { display: flex; gap: 10px; flex-wrap: wrap; }
  .legend-item { display: flex; align-items: center; gap: 5px; font-size: 0.65rem; color: var(--muted); font-family: var(--font-mono); }
  .legend-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
  .legend-line { width: 14px; height: 0; border-top: 2px dashed var(--muted); flex-shrink: 0; }

  .chart-wrap { position: relative; height: 180px; width: 100%; }

  .bars-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 1.25rem; margin-bottom: 1.5rem;
  }
  .bars-title { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; font-family: var(--font-mono); margin-bottom: 1rem; }

  .bar-row {
    display: flex; align-items: center; gap: 10px;
    padding: 3px 4px; border-radius: 4px; transition: background 0.15s;
  }
  .bar-row:hover { background: rgba(255,255,255,0.03); }
  .bar-row.current { background: rgba(255,255,255,0.04); }

  .bar-time { font-size: 0.7rem; color: var(--muted); min-width: 42px; text-align: right; font-family: var(--font-mono); flex-shrink: 0; }
  :root[data-theme="light"] .bar-row.current .bar-time { color: var(--text); }
  :root[data-theme="light"] .bar-row.current .bar-val { color: var(--text); }
  .bar-row.current .bar-time { color: var(--text); }
  .bar-wrap { flex: 1; height: 16px; background: rgba(255,255,255,0.04); border-radius: 3px; overflow: hidden; }
  .bar-fill { height: 100%; border-radius: 3px; transition: width 0.6s cubic-bezier(0.16,1,0.3,1); }
  .bar-val { font-size: 0.7rem; color: var(--muted); min-width: 48px; text-align: right; font-family: var(--font-mono); flex-shrink: 0; }
  .bar-row.current .bar-val { color: var(--text); font-weight: 500; }

  .now-pill {
    background: var(--green); color: #fff;
    font-size: 0.55rem; font-weight: 600; padding: 1px 5px; border-radius: 99px;
    font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; flex-shrink: 0;
  }

  .tomorrow-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 1.25rem; margin-bottom: 1.5rem;
  }

  .tomorrow-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1rem; flex-wrap: wrap; gap: 8px;
  }

  .tomorrow-title { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; font-family: var(--font-mono); }

  .tomorrow-note { font-size: 0.65rem; color: var(--faint); font-family: var(--font-mono); }

  .tomorrow-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
  }

  .tomorrow-metric {
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 8px; padding: 0.75rem 1rem;
    position: relative; overflow: hidden;
  }

  .tomorrow-metric::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 2px;
    background: var(--accent-color, transparent);
    border-radius: 8px 8px 0 0;
  }

  .theme-toggle {
    background: none;
    border: 1px solid var(--faint);
    border-radius: 6px;
    padding: 5px 8px;
    cursor: pointer;
    color: var(--muted);
    display: flex; align-items: center;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
    flex-shrink: 0;
  }
  .theme-toggle:hover { color: var(--text); border-color: var(--text); background: var(--surface2); }
  .theme-toggle svg { width: 15px; height: 15px; }
  .icon-sun { display: none; }
  .icon-moon { display: block; }
  :root[data-theme="light"] .icon-sun { display: block; }
  :root[data-theme="light"] .icon-moon { display: none; }

  .saved-badge {
    font-size: 0.65rem; color: var(--green); font-family: var(--font-mono);
    opacity: 0; transition: opacity 0.3s;
    min-width: 48px; display: inline-block;
  }
  .saved-badge.show { opacity: 1; }

  .status { text-align: center; padding: 3rem 0; color: var(--muted); font-size: 0.85rem; font-family: var(--font-mono); }
  .status.error { color: #f05050; }

  .spinner {
    display: inline-block; width: 14px; height: 14px;
    border: 2px solid var(--faint); border-top-color: var(--muted);
    border-radius: 50%; animation: spin 0.8s linear infinite;
    vertical-align: middle; margin-right: 8px;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  .svt-tooltip {
    position: static; display: inline-flex; align-items: center;
  }
  .svt-q {
    display: inline-flex; align-items: center; justify-content: center;
    width: 13px; height: 13px; border-radius: 50%;
    background: var(--faint); color: var(--muted);
    font-size: 0.6rem; font-family: var(--font-mono);
    cursor: default; margin-left: 3px; flex-shrink: 0;
    line-height: 1; user-select: none;
  }
  .tip {
    visibility: hidden; opacity: 0;
    background: var(--surface2); color: var(--text);
    border: 1px solid var(--border);
    font-size: 0.68rem; font-family: var(--font-mono);
    line-height: 1.5;
    width: 210px; padding: 7px 10px; border-radius: 6px;
    position: fixed;
    transition: opacity 0.15s; z-index: 9999;
    pointer-events: none;
  }

  .explainer {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 1.25rem; margin-bottom: 1.5rem;
  }

  .explainer-title {
    font-size: 0.7rem; color: var(--muted); text-transform: uppercase;
    letter-spacing: 0.1em; font-family: var(--font-mono); margin-bottom: 0.75rem;
  }

  .explainer p {
    font-size: 0.78rem; color: var(--muted); font-family: var(--font-mono);
    line-height: 1.7; margin-bottom: 0.5rem;
  }

  .explainer p:last-child { margin-bottom: 0; }

  .explainer strong { color: var(--text); font-weight: 500; }

  .explainer p.faq-q {
    font-family: var(--font-display); color: var(--text);
    font-weight: 700; font-size: 0.9rem; line-height: 1.4;
    margin-bottom: 0.35rem;
  }

  .explainer-toggle {
    background: none; border: none; padding: 0;
    font-size: 0.7rem; color: var(--blue); font-family: var(--font-mono);
    cursor: pointer; margin-top: 0.5rem; display: flex; align-items: center; gap: 4px;
  }
  .explainer-toggle:hover { text-decoration: underline; }

  .explainer-body { overflow: hidden; transition: max-height 0.3s ease; max-height: 0; }
  .explainer-body.open { max-height: 600px; }

  .region-intro { margin-bottom: 1.5rem; }
  .region-intro-title {
    font-family: var(--font-display); font-size: 1.05rem; font-weight: 700;
    letter-spacing: -0.01em; margin-bottom: 0.5rem;
  }
  .region-intro-text {
    font-family: var(--font-mono); font-size: 0.78rem; color: var(--muted);
    line-height: 1.7;
  }
  .region-intro-text strong { color: var(--text); font-weight: 500; }

  .region-links {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 1.25rem; margin-bottom: 1.5rem;
  }
  .region-links-title {
    font-size: 0.7rem; color: var(--muted); text-transform: uppercase;
    letter-spacing: 0.1em; font-family: var(--font-mono); margin-bottom: 0.85rem;
  }
  .region-links-grid {
    display: flex; flex-wrap: wrap; gap: 8px;
  }
  .region-links-grid a {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 6px; padding: 5px 11px;
    font-size: 0.72rem; font-family: var(--font-mono); color: var(--text);
    text-decoration: none; transition: border-color 0.15s, background 0.15s;
  }
  .region-links-grid a:hover { border-color: var(--blue); background: rgba(90,171,240,0.08); text-decoration: none; }
  .region-links-guide {
    margin-top: 0.9rem; padding-top: 0.9rem; border-top: 1px solid var(--border);
    font-size: 0.75rem; font-family: var(--font-mono);
  }

  .referral-card {
    background: linear-gradient(135deg, rgba(230,57,70,0.12) 0%, rgba(90,171,240,0.08) 100%);
    border: 1px solid rgba(230,57,70,0.25);
    border-radius: 10px; padding: 1.1rem 1.25rem; margin-bottom: 1.5rem;
  }

  .referral-inner {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap;
  }

  @media (max-width: 480px) {
    .referral-inner { flex-direction: column; align-items: flex-start; }
    .referral-btn { width: 100%; justify-content: center; }
  }

  .referral-label {
    font-size: 0.8rem; font-weight: 700; margin-bottom: 3px; color: var(--text);
  }

  .referral-sub {
    font-size: 0.72rem; color: var(--muted); font-family: var(--font-mono); line-height: 1.5;
  }

  .referral-savings {
    font-size: 0.72rem; color: var(--muted); font-family: var(--font-mono); line-height: 1.5;
    margin-top: 6px;
  }
  .referral-savings strong { color: var(--green); font-weight: 700; }

  .referral-btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: #E63946; color: #fff;
    border: none; border-radius: 6px;
    padding: 8px 16px; font-size: 0.8rem; font-weight: 700;
    font-family: var(--font-display); text-decoration: none; white-space: nowrap;
    transition: background 0.15s, transform 0.1s;
    flex-shrink: 0;
  }
  .referral-btn:hover { background: #c8303c; text-decoration: none; transform: translateY(-1px); }
  .referral-btn:active { transform: scale(0.97); }

  /* Setup overlay */
  .setup-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.75);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 1rem; backdrop-filter: blur(4px);
  }
  .setup-overlay.hidden { display: none; }

  .setup-modal {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; padding: 2rem 1.75rem;
    max-width: 400px; width: 100%; text-align: center;
  }

  .setup-octopus { margin-bottom: 1rem; display: flex; justify-content: center; }

  .setup-title {
    font-size: 1.2rem; font-weight: 700; margin-bottom: 0.5rem;
  }

  .setup-sub {
    font-size: 0.78rem; color: var(--muted); font-family: var(--font-mono);
    line-height: 1.6; margin-bottom: 1.25rem;
  }

  .setup-input-wrap {
    display: flex; gap: 8px; margin-bottom: 0.5rem;
  }

  .setup-input {
    flex: 1; background: var(--surface2); color: var(--text);
    border: 1px solid var(--faint); border-radius: 6px;
    padding: 9px 12px; font-size: 0.9rem; font-family: var(--font-mono);
    text-transform: uppercase; outline: none; letter-spacing: 0.05em;
  }
  .setup-input:focus { border-color: var(--accent); }

  .setup-btn {
    background: #E63946; color: #fff; border: none;
    border-radius: 6px; padding: 9px 16px;
    font-size: 0.82rem; font-weight: 700; cursor: pointer;
    white-space: nowrap; transition: background 0.15s;
  }
  .setup-btn:hover { background: #c8303c; }
  .setup-btn:disabled { opacity: 0.5; cursor: not-allowed; }

  .setup-error {
    font-size: 0.72rem; color: #f05050; font-family: var(--font-mono);
    min-height: 1.2em; margin-bottom: 0.5rem;
  }

  .setup-note {
    font-size: 0.65rem; color: var(--muted); font-family: var(--font-mono);
    line-height: 1.5;
  }

  .setup-skip {
    background: none; border: none; border-radius: 0;
    width: 100%; justify-content: center; margin-top: 1rem; padding: 0;
    font-size: 0.72rem; color: var(--blue); font-family: var(--font-mono); font-weight: 400;
  }
  .setup-skip:hover { background: none; border-color: transparent; text-decoration: underline; }

  /* Postcode input in header */
  .postcode-wrap {
    display: flex; align-items: center;
    background: var(--surface2); border: 1px solid var(--faint);
    border-radius: 6px; overflow: hidden;
  }

  .postcode-input {
    background: transparent; color: var(--text); border: none; outline: none;
    padding: 6px 10px; font-size: 0.78rem; font-family: var(--font-mono);
    text-transform: uppercase; letter-spacing: 0.05em; width: 90px;
  }

  .postcode-btn {
    background: transparent; border: none; border-left: 1px solid var(--faint);
    color: var(--muted); padding: 6px 8px; cursor: pointer;
    display: flex; align-items: center; transition: color 0.15s;
  }
  .postcode-btn:hover { color: var(--text); }

  .postcode-chip {
    display: inline-flex; align-items: center; gap: 5px;
    background: var(--surface2); border: 1px solid var(--faint);
    border-radius: 6px; padding: 5px 10px;
    font-size: 0.78rem; font-family: var(--font-mono);
    color: var(--text); cursor: pointer; letter-spacing: 0.05em;
    transition: border-color 0.15s, background 0.15s;
    text-transform: uppercase;
  }
  .postcode-chip::after {
    content: '✎'; font-size: 0.65rem; color: var(--muted); margin-left: 2px;
  }
  .postcode-chip:hover { border-color: rgba(255,255,255,0.2); background: rgba(255,255,255,0.05); }

  .postcode-clear {
    background: none; border: 1px solid var(--faint); border-radius: 6px;
    padding: 5px 8px; color: var(--muted);
    font-size: 0.7rem; font-family: var(--font-mono); font-weight: 400;
  }
  .postcode-clear:hover { color: #f05050; border-color: #f05050; background: none; }

  .tip-banner {
    display: flex; align-items: flex-start; gap: 10px;
    background: rgba(28,201,138,0.08);
    border: 1px solid rgba(28,201,138,0.25);
    border-radius: 10px; padding: 0.9rem 1.1rem;
    margin-bottom: 1.25rem;
    font-family: var(--font-mono); font-size: 0.78rem; line-height: 1.6;
    color: var(--text);
  }

  .tip-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }

  .tip-banner strong { color: #1cc98a; }

  footer {
    display: flex; justify-content: space-between;
    align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 0.5rem;
  }
  .footer-note { font-size: 0.65rem; color: var(--faint); font-family: var(--font-mono); }
  a { color: var(--blue); text-decoration: none; }
  a:hover { text-decoration: underline; }

  /* Trend range selector */
  .trend-range-group {
    display: flex; gap: 2px;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 6px; padding: 2px;
  }
  .trend-range-btn {
    background: none; border: none; border-radius: 4px;
    padding: 4px 9px; font-size: 0.7rem; font-weight: 500;
    font-family: var(--font-mono); color: var(--muted);
  }
  .trend-range-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); }
  .trend-range-btn.active { background: var(--surface2); color: var(--text); }

  /* Heatmap */
  .heatmap-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 1.25rem; margin-bottom: 1.5rem;
  }
  .heatmap-scroll { overflow-x: auto; padding-bottom: 2px; }
  .heatmap-grid { display: flex; flex-direction: column; gap: 2px; min-width: 560px; }
  .heatmap-row { display: grid; grid-template-columns: 34px repeat(24, 1fr); gap: 2px; align-items: center; }
  .heatmap-row-label {
    font-size: 0.62rem; color: var(--muted); font-family: var(--font-mono);
    text-align: right; padding-right: 6px;
  }
  .heatmap-hour-tick {
    font-size: 0.55rem; color: var(--faint); font-family: var(--font-mono);
    text-align: center;
  }
  .heatmap-cell {
    appearance: none; border: none; padding: 0; margin: 0;
    width: 100%; aspect-ratio: 1; border-radius: 2px;
    cursor: pointer; transition: outline-color 0.1s, filter 0.1s;
    outline: 2px solid transparent; outline-offset: 1px;
  }
  .heatmap-cell:hover, .heatmap-cell:focus-visible {
    filter: brightness(1.25);
    outline-color: var(--text);
  }
  .heatmap-footer {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 10px; margin-top: 1rem;
  }
  .heatmap-readout {
    font-size: 0.72rem; color: var(--text); font-family: var(--font-mono);
  }
  .heatmap-legend { display: flex; align-items: center; gap: 6px; font-size: 0.65rem; color: var(--muted); font-family: var(--font-mono); }
  .heatmap-legend-gradient { width: 90px; height: 8px; border-radius: 4px; }
