:root {
  --bg0: #06140f;
  --bg1: #0c2419;
  --ink: #e8f6ee;
  --muted: #8eaea0;
  --line: rgba(140, 190, 160, 0.18);
  --brand: #3ecf8e;
  --brand-dim: #1f7a52;
  --glow: rgba(62, 207, 142, 0.35);
  --warn: #e4c56a;
  --danger: #e0705c;
  --locked: rgba(255, 255, 255, 0.04);
  --panel: rgba(10, 36, 26, 0.72);
  --radius: 18px;
  --font: "Outfit", system-ui, sans-serif;
  --display: "Syne", "Outfit", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg0);
}

body {
  position: relative;
  overflow-x: hidden;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(62, 207, 142, 0.22), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(46, 120, 90, 0.28), transparent 50%),
    radial-gradient(ellipse 70% 50% at 50% 100%, rgba(20, 80, 55, 0.35), transparent 55%),
    linear-gradient(165deg, var(--bg0), var(--bg1) 45%, #081811);
  animation: drift 18s ease-in-out infinite alternate;
}

@keyframes drift {
  from { filter: hue-rotate(0deg) saturate(1); }
  to { filter: hue-rotate(8deg) saturate(1.08); }
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 28px 22px 12px;
  max-width: 760px;
  margin: 0 auto;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand {
  margin: 4px 0 0;
  font-family: var(--display);
  font-size: clamp(2.4rem, 8vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 0.95;
  background: linear-gradient(120deg, #f3fff8 20%, var(--brand) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.meta { display: flex; align-items: center; gap: 10px; padding-bottom: 8px; }

.badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
}

.badge.drying, .badge.preparing {
  border-color: rgba(62, 207, 142, 0.5);
  box-shadow: 0 0 20px var(--glow);
  animation: pulse 2.2s ease-in-out infinite;
}

.badge.finished { border-color: var(--warn); color: var(--warn); }
.badge.paused { border-color: var(--warn); }
.badge.cooling {
  border-color: rgba(120, 180, 220, 0.55);
  color: #a8d4f0;
}

.badge.fault {
  border-color: var(--danger);
  color: #ffb4a8;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 10px transparent; }
  50% { box-shadow: 0 0 22px var(--glow); }
}

.mqtt {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.mqtt i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  display: block;
}

.mqtt.on i {
  background: var(--brand);
  box-shadow: 0 0 10px var(--brand);
  animation: blink 1.6s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.tabs {
  display: flex;
  gap: 8px;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 18px;
}

.tab {
  flex: 1;
  padding: 12px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.tab.active {
  color: #042116;
  background: linear-gradient(135deg, #2aa86a, var(--brand));
  border-color: transparent;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.view.hidden { display: none; }

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 8px 18px calc(40px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.maint-banner {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.maint-status {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid var(--line);
}

.maint-status.on {
  border-color: rgba(62, 207, 142, 0.5);
  background: rgba(62, 207, 142, 0.12);
  color: var(--brand);
}

.maint-status.off {
  color: var(--muted);
  background: rgba(0, 0, 0, 0.2);
}

.maint-status.fault {
  border-color: rgba(224, 112, 92, 0.55);
  background: rgba(224, 112, 92, 0.15);
  color: #ffb4a8;
}

.toggle-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.slider-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hint {
  margin: 10px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

#control-note {
  margin: 0 0 12px;
  line-height: 1.35;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85rem;
  color: var(--ink);
  margin-bottom: 6px;
}

.check-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.duration-opt input[type="number"]:disabled {
  opacity: 0.4;
}

.metrics-2 { grid-template-columns: 1fr 1fr; }

.heat-panel {
  border-color: rgba(228, 197, 106, 0.25);
}

button.warn {
  background: rgba(228, 197, 106, 0.18);
  border-color: rgba(228, 197, 106, 0.55);
  color: #ffe9a8;
}

.actions-maint {
  grid-template-columns: 1.4fr 1fr;
}

.badge.maintenance {
  border-color: var(--warn);
  color: var(--warn);
}

.section-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 700;
}

.section-head p {
  margin: 4px 0 12px;
  color: var(--muted);
  font-size: 0.92rem;
}

.modes, .telemetry, .session {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  backdrop-filter: blur(10px);
}

.mode-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mode-soon {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mode-hero {
  width: 100%;
  min-height: 108px;
  padding: 22px 20px;
  background:
    radial-gradient(circle at 92% 20%, rgba(228, 197, 106, 0.28), transparent 42%),
    linear-gradient(160deg, rgba(62, 207, 142, 0.2), rgba(255, 255, 255, 0.03));
}

.mode-hero .mode-name { font-size: clamp(1.8rem, 5vw, 2.4rem); }

.mode-kicker {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 4px;
}

.leaf, .fruit {
  position: absolute;
  pointer-events: none;
  opacity: 0.55;
}

.leaf {
  width: 42px;
  height: 22px;
  border-radius: 0 70% 0 70%;
  background: linear-gradient(135deg, #3ecf8e, #1f7a52);
  transform: rotate(-28deg);
}

.l1 { top: 12%; left: 4%; }
.l2 { top: 38%; right: 6%; transform: rotate(40deg) scale(0.8); }
.l3 { bottom: 14%; left: 8%; transform: rotate(18deg) scale(1.1); }

.fruit {
  width: 16px;
  height: 22px;
  border-radius: 50% 50% 48% 48%;
  background: radial-gradient(circle at 35% 30%, #ffe08a, #e4a03a 70%);
}

.f1 { top: 22%; right: 18%; }
.f2 { bottom: 28%; right: 10%; transform: rotate(12deg) scale(0.85); }

.cycle-status {
  margin: 0 0 14px;
  padding: 14px 16px;
  border-radius: 14px;
  font-family: var(--display);
  font-size: clamp(1.35rem, 4vw, 1.8rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
}

.cycle-status.ready {
  color: #042116;
  background: linear-gradient(135deg, #f0d56a, #3ecf8e);
  border-color: transparent;
}

.cycle-status.run { color: var(--brand); }
.cycle-status.wait { color: var(--muted); font-size: 1.15rem; }

.maint-due {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(228, 197, 106, 0.55);
  background: rgba(228, 197, 106, 0.12);
  color: #ffe9a8;
  font-weight: 600;
}

.maint-due.calm {
  border-color: var(--line);
  background: rgba(0, 0, 0, 0.2);
  color: var(--muted);
  font-weight: 500;
}

.tariff {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

.tariff input {
  width: 88px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
  font: inherit;
}

.done-alert {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 16, 12, 0.72);
}

.done-alert.hidden { display: none; }

.done-card {
  width: min(420px, 100%);
  padding: 28px 22px;
  border-radius: 22px;
  background:
    radial-gradient(circle at 100% 0%, rgba(228, 197, 106, 0.35), transparent 40%),
    #10261c;
  border: 1px solid rgba(62, 207, 142, 0.45);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.done-card h2 {
  margin: 6px 0 8px;
  font-family: var(--display);
  font-size: 2rem;
}

.done-card p { margin: 0 0 18px; color: var(--muted); }
.done-card .primary { width: 100%; }

label.tariff {
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  text-transform: none;
  letter-spacing: 0;
}

label.tariff input[type="number"] {
  width: 96px;
  flex: 0 0 96px;
}

.mode {
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  border-radius: 14px;
  padding: 16px 14px;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
}

.mode:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(62, 207, 142, 0.55);
}

.mode.selected {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 1px rgba(62, 207, 142, 0.35), 0 0 24px rgba(62, 207, 142, 0.12);
  background: linear-gradient(160deg, rgba(62, 207, 142, 0.16), rgba(255, 255, 255, 0.02));
}

.mode.locked {
  background: var(--locked);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.72;
}

.mode-name {
  display: block;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
}

.mode-meta, .lock {
  display: block;
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.lock { color: var(--warn); letter-spacing: 0.04em; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.metric {
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 14px 12px;
  background: rgba(0, 0, 0, 0.18);
  position: relative;
  overflow: hidden;
}

.metric::after {
  content: "";
  position: absolute;
  inset: auto -20% -40% auto;
  width: 80px;
  height: 80px;
  background: radial-gradient(circle, var(--glow), transparent 70%);
  opacity: 0.35;
  pointer-events: none;
}

.metric small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-family: var(--display);
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.metric em {
  font-style: normal;
  font-size: 0.75rem;
  color: var(--muted);
}

.time-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.time-row > div {
  border-top: 2px solid rgba(62, 207, 142, 0.45);
  padding-top: 10px;
}

.time-row small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.time-row strong {
  display: block;
  margin-top: 6px;
  font-size: 1.25rem;
  font-weight: 650;
}

.progress-wrap { margin-bottom: 14px; }

.bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-dim), var(--brand));
  transition: width 0.35s ease;
  box-shadow: 0 0 16px var(--glow);
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.preset-row {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--brand);
}

input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
  font-size: 1rem;
  font-family: inherit;
}

output {
  font-size: 0.9rem;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

#btn-start,
#btn-maint-ack { grid-column: 1 / -1; }

button {
  font-family: inherit;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  padding: 14px 12px;
  min-height: 48px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:hover:not(:disabled) { transform: translateY(-1px); }
button:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

button.primary {
  background: linear-gradient(135deg, #2aa86a, var(--brand));
  border-color: transparent;
  color: #042116;
  box-shadow: 0 10px 30px rgba(62, 207, 142, 0.25);
}

button.danger {
  background: rgba(224, 112, 92, 0.15);
  border-color: rgba(224, 112, 92, 0.45);
  color: #ffc7bc;
}

button.ghost { background: transparent; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #10261c;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  z-index: 20;
}

.toast.hidden { display: none; }

@media (max-width: 640px) {
  .top {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 20px 16px 8px;
  }

  .meta { padding-bottom: 0; flex-wrap: wrap; }

  .tabs { padding: 0 16px; }

  .wrap { padding: 8px 16px calc(28px + env(safe-area-inset-bottom, 0px)); }

  .metrics { grid-template-columns: 1fr 1fr; }
  .time-row, .preset-row { grid-template-columns: 1fr 1fr; }
  .actions { grid-template-columns: 1fr 1fr; }
  #btn-start { grid-column: 1 / -1; }
  .actions-maint { grid-template-columns: 1fr; }

  .mode { padding: 14px 12px; min-height: 72px; }
  .mode-soon .mode { padding: 10px 8px; min-height: 0; }
  .mode-soon .mode-name { font-size: 0.92rem; }

  input[type="range"] { min-height: 32px; }
}

@media (max-width: 380px) {
  .time-row { grid-template-columns: 1fr; }
  .preset-row { grid-template-columns: 1fr; }
}
