:root {
  --bg-color: #090d16;
  --surface-color: #131b2e;
  --surface-border: #1e2942;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-blue: #38bdf8;
  --accent-green: #22c55e;
  --accent-red: #ef4444;
  --slider-thumb-size: 32px;
  --slider-height: 18px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  touch-action: manipulation;
}

.app-container {
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 16px) + 12px) 20px calc(env(safe-area-inset-bottom, 16px) + 24px) 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}

/* Header & Status */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 6px 12px;
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-red);
  transition: background 0.3s ease;
}

.status-dot.online {
  background: var(--accent-green);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.6);
}

/* Device Target Selector */
.target-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.target-select {
  width: 100%;
  height: 48px;
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  color: var(--text-main);
  font-size: 16px;
  font-weight: 500;
  border-radius: 14px;
  padding: 0 16px;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px;
}

/* Master Power Button */
.power-card {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: 20px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.power-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.power-title {
  font-size: 18px;
  font-weight: 600;
}

.power-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.power-toggle-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: #1e293b;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.power-toggle-btn svg {
  width: 30px;
  height: 30px;
  stroke: currentColor;
}

.power-toggle-btn:active {
  transform: scale(0.92);
}

.power-toggle-btn.active {
  background: var(--accent-green);
  color: #ffffff;
  box-shadow: 0 0 24px rgba(34, 197, 94, 0.5);
}

/* Mode Tabs */
.tabs-nav {
  display: flex;
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  padding: 4px;
  gap: 4px;
}

.tab-btn {
  flex: 1;
  height: 42px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: #1e293b;
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* Color Wheel Section */
.color-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 0;
  min-height: 290px;
}

.color-wheel-wrapper {
  touch-action: none;
}

/* Kelvin White Temperature Controls */
.whites-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 10px 0;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  font-weight: 600;
}

.slider-value {
  color: var(--accent-blue);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/* Custom Fat Sliders */
.fat-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: var(--slider-height);
  border-radius: 999px;
  outline: none;
  background: #1e293b;
  touch-action: none;
}

.fat-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: var(--slider-thumb-size);
  height: var(--slider-thumb-size);
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid #0f172a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.fat-slider:active::-webkit-slider-thumb {
  transform: scale(1.18);
}

.kelvin-track {
  background: linear-gradient(
    to right,
    #ff8a12, /* 1500K Candle */
    #ffab57, /* 2500K */
    #ffd2a1, /* 3500K Warm Neutral */
    #fff2e8, /* 5000K Neutral */
    #e1ecff, /* 6500K Daylight */
    #b8d5ff  /* 9000K Sky */
  );
}

.brightness-track {
  background: linear-gradient(to right, #1e293b, #f8fafc);
}

/* Preset Chips */
.presets-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.preset-chip {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  color: var(--text-main);
  padding: 10px 8px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.2s ease;
}

.preset-chip span {
  font-size: 11px;
  color: var(--text-muted);
}

.preset-chip:active {
  transform: scale(0.95);
  background: #1e293b;
}

/* Daemon Offline Warning Banner */
.offline-banner {
  display: none;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.4;
  color: #fca5a5;
}

.offline-banner.visible {
  display: block;
}
