/* ═══════════════════════════════════════════════════════════════════
   ResCalk — Style Sheet
   iOS-faithful dark-primary design with light theme support
   ═══════════════════════════════════════════════════════════════════ */

/* ── Reset ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

/* ── Design tokens ───────────────────────────────────────────────── */
:root {
  /* Dark (primary — matches iOS app) */
  --page-bg:      #0A0A10;
  --card-bg:      #161621;
  --card-inner:   #1E1E2D;
  --text:         #FFFFFF;
  --text-2:       #AAAACC;
  --text-3:       #666688;
  --border:       #252535;
  --accent:       #0066FF;
  --accent-glow:  rgba(0, 102, 255, 0.35);
  --accent-text:  #FFFFFF;
  --step-badge:   #0066FF;
  --toggle-off:   #3A3A55;
  --param-val:    #FFFFFF;
  --shadow:       0 4px 20px rgba(0,0,0,.5);
  --radius:       16px;
  --radius-sm:    10px;
}

/* Light theme overrides */
[data-theme="light"] {
  --page-bg:      #F0F0F8;
  --card-bg:      #FFFFFF;
  --card-inner:   #F5F5FF;
  --text:         #111122;
  --text-2:       #555570;
  --text-3:       #999AAA;
  --border:       #E0E0F0;
  --accent:       #0055DD;
  --accent-glow:  rgba(0, 85, 221, 0.2);
  --accent-text:  #FFFFFF;
  --step-badge:   #0055DD;
  --toggle-off:   #CCCCDD;
  --param-val:    #111122;
  --shadow:       0 2px 12px rgba(0,0,0,.08);
}

/* ── Base ─────────────────────────────────────────────────────────── */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  background: var(--page-bg);
  min-height: 100dvh;
  padding-bottom: 160px;
  transition: background 0.2s, color 0.2s;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ───────────────────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #111118;   /* always dark like the iOS app */
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.header-inner {
  max-width: 680px;
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Hamburger */
.header-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: #FFF;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
}
.header-icon span {
  display: block;
  width: 20px;
  height: 2px;
  background: #FFF;
  border-radius: 1px;
}
.header-icon-gear {
  flex-direction: row;
  color: #FFF;
  opacity: 0.75;
  transition: opacity 0.15s;
}
.header-icon-gear:hover { opacity: 1; }

.header-logo {
  height: 28px;
  object-fit: contain;
  filter: invert(0); /* white logo on dark header — always */
}
[data-theme="light"] .header-logo {
  filter: invert(1); /* invert to dark for light theme header */
}

/* ── Main layout ──────────────────────────────────────────────────── */
main {
  max-width: 680px;
  margin: 0 auto;
  padding: 14px 12px 80px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Cards ────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  transition: background 0.2s, border-color 0.2s;
}

/* ═══════════════════════════════════════════════════════════════════
   WIRE CARD
═══════════════════════════════════════════════════════════════════ */
.wire-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--border);
}

.wire-card-title h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.wire-card-title p {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

/* Section titles like iOS */
.setting-title,
.coil-card-title,
.core-wires-title {
  font-size: 16px;
}

.blendstylez-mark {
  height: 36px;
  opacity: 0.35;
  object-fit: contain;
  flex-shrink: 0;
}

/* Wire selector: steps + sphere */
.wire-selector-row {
  display: flex;
  gap: 0;
}

/* ── Steps column ─────────────────────────────────────────────────── */
.steps-col {
  flex: 1;
  padding: 8px 0 4px 18px;
  min-width: 0;
}

.step-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px 11px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.step-row:last-of-type { border-bottom: none; }

.step-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--step-badge);
  color: #FFF;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.step-body {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}
.step-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
}
.step-val {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Invisible native select that covers the row */
.step-native-sel {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 16px; /* prevents iOS zoom */
  z-index: 2;
}

/* Chevron on each step row */
.step-row::after {
  content: '›';
  font-size: 18px;
  color: var(--text-3);
  padding-right: 4px;
  flex-shrink: 0;
}

.btn-add-wire {
  display: block;
  width: calc(100% - 0px);
  margin: 12px 12px 14px 0;
  padding: 10px;
  background: var(--accent);
  color: #FFF;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: 0.2px;
  box-shadow: 0 4px 12px var(--accent-glow);
  transition: background 0.15s, transform 0.1s;
}
.btn-add-wire:hover  { background: #0055DD; }
.btn-add-wire:active { transform: scale(0.97); }

/* ── Sphere column ────────────────────────────────────────────────── */
.sphere-col {
  flex: 0 0 148px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  padding: 12px 12px 12px 4px;
}

.sphere-wrap {
  width: 130px;
  height: 130px;
  border-radius: 16px;
  overflow: hidden;
  flex-shrink: 0;
}

.sphere-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.25s ease;
  display: block;
}

/* (summary strip removed) */

/* ── Core Wires header ────────────────────────────────────────────── */
.core-wires-header {
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border);
}
.core-wires-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.core-wires-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

/* ── Added wires list ─────────────────────────────────────────────── */
.wire-list { padding: 6px 14px 10px; }

.wire-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 6px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px var(--accent-glow);
}
.wire-list-item:last-child { margin-bottom: 0; }

.wire-list-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.8);
  background: transparent;
  flex-shrink: 0;
}
.wire-list-dot.shape-ribbon { border-radius: 2px; height: 6px; width: 14px; }
.wire-list-dot.shape-square { border-radius: 3px; }

.wire-list-label {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wire-list-suffix {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  flex-shrink: 0;
}
.btn-wire-remove {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 15px;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.btn-wire-remove:hover { background: rgba(255,255,255,0.2); color: #FFF; }

/* ═══════════════════════════════════════════════════════════════════
   POWER / BATTERY CARD
═══════════════════════════════════════════════════════════════════ */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
  gap: 12px;
}
.setting-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.setting-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

/* iOS-style toggle */
.ios-toggle {
  position: relative;
  display: inline-block;
  width: 51px;
  height: 31px;
  flex-shrink: 0;
  cursor: pointer;
}
.ios-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.ios-toggle-track {
  position: absolute;
  inset: 0;
  background: var(--toggle-off);
  border-radius: 999px;
  transition: background 0.2s;
}
.ios-toggle input:checked + .ios-toggle-track { background: #34C759; }
.ios-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  background: #FFF;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,0.35);
  transition: transform 0.2s;
}
.ios-toggle input:checked + .ios-toggle-track .ios-toggle-thumb {
  transform: translateX(20px);
}

.mech-panel { border-top: 1px solid var(--border); }
.mech-panel-body {
  padding: 14px 18px 16px;
}
.voltage-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.voltage-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.voltage-val {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.5px;
}
.voltage-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Power bar */
.power-track {
  position: relative;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  display: flex;
}
.bar-seg { height: 100%; min-width: 2px; transition: width 0.3s; }
.bar-blue   { background: #60A5FA; }
.bar-green  { background: #34D399; }
.bar-yellow { background: #FBBF24; }
.bar-red    { background: #F87171; }
.bar-marker {
  position: absolute;
  top: -2px;
  width: 3px;
  height: 14px;
  background: var(--text);
  border-radius: 2px;
  transform: translateX(-50%);
  transition: left 0.3s;
  box-shadow: 0 1px 4px rgba(0,0,0,.5);
  pointer-events: none;
}
.power-thresholds {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
}
.power-thr {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-3);
  font-weight: 500;
}
.thr-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════
   COIL CONFIGURATION CARD
═══════════════════════════════════════════════════════════════════ */
.coil-card-header {
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.coil-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.coil-card-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

/* Save button */
.btn-save {
  background: var(--accent);
  color: #FFF;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.btn-save:hover { background: #0055DD; }

/* Parameter rows */
.param-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
}
.param-row-split {
  flex-wrap: nowrap;
}
.coil-count-row {
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 12px 18px;
}

.param-lbl {
  font-size: 14px;
  color: var(--text);
  font-weight: 700;
  flex-shrink: 0;
  min-width: 96px;
}
.param-row-split .param-lbl { min-width: 36px; }

.param-val-group {
  flex: 1;
  display: flex;
  justify-content: flex-end;
}

/* iOS-style inline selects */
.param-sel {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: right;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
}
/* Chevron via pseudo-element is tricky with select, use a wrapper */
.param-val-group::after {
  content: '˅';
  color: var(--text-3);
  font-size: 13px;
  margin-left: 4px;
  pointer-events: none;
  align-self: center;
}

/* Coil count buttons */
.coil-btn-group {
  display: flex;
  gap: 6px;
}
.btn-coil {
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-inner);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-coil:hover { border-color: var(--accent); }
.btn-coil.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFF;
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* Divider */
.param-divider {
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}

/* Result rows */
.result-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
}
.result-item-row.last { border-bottom: none; }
.result-item-row.highlight { background: var(--card-inner); }

.result-item-lbl {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
}
.result-item-val {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-2);
  text-align: right;
  white-space: nowrap;
}
.result-item-val.accent-val {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-2);
}
.result-item-arr {
  font-size: 18px;
  color: var(--text-3);
  flex-shrink: 0;
  margin-left: 4px;
}

/* Density badge */
.density-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}
.density-low      { background: rgba(96,165,250,.18);  color: #60A5FA; }
.density-optimal  { background: rgba(52,211,153,.18);  color: #34D399; }
.density-heat     { background: rgba(251,191,36,.18);  color: #FBBF24; }
.density-overheat { background: rgba(248,113,113,.18); color: #F87171; }

/* ═══════════════════════════════════════════════════════════════════
   DECORATION CARD
═══════════════════════════════════════════════════════════════════ */
.deco-card-header {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.collapse-chevron {
  font-size: 18px;
  color: var(--text-3);
  flex-shrink: 0;
  transition: transform 0.2s;
}
.deco-card-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.3px;
}
.deco-card-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 4px;
}
.deco-list {
  padding: 2px 0 8px;
}
.deco-row {
  padding: 10px 20px 4px;
}
.deco-main-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.deco-type {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.deco-gauge {
  font-size: 15px;
  font-weight: 400;
  color: var(--text);
}
.deco-sub-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 3px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.deco-row:last-child .deco-sub-line { border-bottom: none; }
.deco-sub-label {
  font-size: 12px;
  color: var(--text-3);
  font-style: italic;
}
.deco-sub-val {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

/* ═══════════════════════════════════════════════════════════════════
   PROMO CARD (in-content)
═══════════════════════════════════════════════════════════════════ */
.promo-card-header {
  padding: 18px 18px 10px;
}
.promo-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.promo-card-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}

.promo-apps {
  padding: 4px 0;
}
.promo-app-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}
.promo-app-row:last-child { border-bottom: none; }
.promo-app-row:hover { background: var(--card-inner); }

.promo-app-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.promo-app-info {
  flex: 1;
  min-width: 0;
}
.promo-app-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.promo-app-desc {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}
.promo-badge {
  height: 30px;
  flex-shrink: 0;
}

/* Tip jar */
.tip-jar {
  padding: 14px 18px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}
.btn-tip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 28px;
  background: #FFDD00;
  color: #1A1A1A;
  border-radius: 99px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  text-decoration: none;
  box-shadow: 0 2px 12px rgba(255,221,0,.3);
  transition: transform 0.1s, box-shadow 0.15s;
}
.btn-tip:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 18px rgba(255,221,0,.4);
}
.btn-tip:active { transform: scale(0.97); }
.tip-icon { font-size: 18px; }

/* AdSense in-content slot */
.adsense-slot {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 12px;
}
.ad-placeholder {
  width: 100%;
  height: 60px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: 0.3px;
  text-align: center;
}

/* ═══════════════════════════════════════════════════════════════════
   STICKY BOTTOM BANNER
═══════════════════════════════════════════════════════════════════ */
#sticky-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  min-height: 66px;
  padding: 0;
  transition: background 0.2s;
  overflow: hidden;
}

.banner-slide {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 10px 16px;
  text-decoration: none;
  color: inherit;
  max-width: 680px;
  margin: 0 auto;
}
.banner-slide.active { display: flex; }

.banner-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.banner-coffee-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}
.banner-text {
  flex: 1;
  min-width: 0;
}
.banner-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.banner-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 1px;
}
.banner-badge {
  height: 28px;
  flex-shrink: 0;
}
.banner-cta {
  padding: 6px 16px;
  background: #FFDD00;
  color: #1A1A1A;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

/* Banner dots */
.banner-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 0 0 8px;
}
.banner-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  opacity: 0.4;
  cursor: pointer;
  transition: opacity 0.2s, background 0.2s;
}
.banner-dot.active {
  opacity: 1;
  background: var(--accent);
}

/* ── Toast ────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: #222233;
  color: #F0F0FF;
  font-size: 13px;
  padding: 9px 18px;
  border-radius: 99px;
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 300;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Empty hint ───────────────────────────────────────────────────── */
.empty-hint {
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  padding: 18px 16px;
}

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .sphere-col { flex: 0 0 120px; }
  .sphere-wrap { width: 120px; height: 120px; }
  .param-lbl { min-width: 82px; }
  .steps-col { padding-left: 14px; }
  .deco-grid { grid-template-columns: 1fr; }
}

@media (max-width: 360px) {
  .sphere-col { flex: 0 0 100px; }
  .sphere-wrap { width: 100px; height: 100px; }
  .wire-card-top { flex-direction: column; gap: 4px; }
  .blendstylez-mark { display: none; }
}
