:root {
  color-scheme: dark;
  --bg: #120f16;
  --panel: #1b161f;
  --panel-raised: #241d29;
  --field: #151119;
  --line: #3a3040;
  --line-strong: #54435d;
  --text: #fff7fc;
  --muted: #baaabd;
  --accent: #ee63ad;
  --accent-hover: #d9539b;
  --accent-soft: #392039;
  --accent-lavender: #a98bff;
  --danger: #ff737d;
  --danger-soft: #381d25;
  --success: #72dda9;
  --focus-ring: #ffadd8;
  --radius: 10px;
}

* { box-sizing: border-box; }

html {
  min-width: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 12% 0%, rgba(238, 99, 173, .12), transparent 36rem),
    radial-gradient(circle at 92% 16%, rgba(169, 139, 255, .09), transparent 34rem),
    var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select { font: inherit; }

button,
input,
select,
.remember-control,
.check-option { -webkit-tap-highlight-color: transparent; }

button {
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: .72rem 1rem;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, opacity 140ms ease, transform 140ms ease;
  touch-action: manipulation;
}

button:hover { background: var(--accent-hover); }
button:active:not(:disabled) { transform: scale(.965); }

button:focus-visible,
input:focus-visible,
select:focus-visible,
.remember-control:has(input:focus-visible),
.check-option:has(input:focus-visible) {
  outline: 3px solid color-mix(in srgb, var(--focus-ring) 60%, transparent);
  outline-offset: 2px;
}

button:disabled { cursor: not-allowed; opacity: .45; }

button.secondary,
button.quiet {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--text);
}

button.secondary:hover,
button.quiet:hover { background: var(--panel-raised); }

button.danger {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 58%, var(--line));
  color: #ff9ba2;
}

button.danger:hover { background: #44242b; }

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: .68rem .78rem;
  background: var(--field);
  color: var(--text);
  font-size: 16px;
}

input::placeholder { color: #797d87; }
input[type="checkbox"] { width: 20px; min-height: 20px; height: 20px; margin: 0; accent-color: var(--accent); }

.heart-field {
  position: fixed;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.heart-field span {
  position: absolute;
  bottom: -42px;
  color: rgba(238, 99, 173, .16);
  font-size: clamp(14px, 3vw, 26px);
  animation: heart-drift 14s linear infinite;
}

.heart-field span:nth-child(1) { left: 5%; animation-delay: -3s; animation-duration: 17s; }
.heart-field span:nth-child(2) { left: 18%; animation-delay: -11s; animation-duration: 21s; }
.heart-field span:nth-child(3) { left: 34%; animation-delay: -6s; animation-duration: 15s; }
.heart-field span:nth-child(4) { left: 49%; animation-delay: -14s; animation-duration: 23s; }
.heart-field span:nth-child(5) { left: 63%; animation-delay: -8s; animation-duration: 18s; }
.heart-field span:nth-child(6) { left: 76%; animation-delay: -1s; animation-duration: 20s; }
.heart-field span:nth-child(7) { left: 88%; animation-delay: -12s; animation-duration: 16s; }
.heart-field span:nth-child(8) { left: 96%; animation-delay: -4s; animation-duration: 22s; }

main {
  position: relative;
  z-index: 1;
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) calc(84px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

h1,
h2,
h3,
p { margin-top: 0; }

h1,
h2,
h3 { letter-spacing: -.025em; }
h1 { margin-bottom: 0; font-size: clamp(1.7rem, 8vw, 2.5rem); line-height: 1.08; }
h2 { margin-bottom: 0; font-size: 1.15rem; }
h3 { margin: 28px 0 10px; font-size: 1rem; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.login-panel {
  width: min(440px, 100%);
  margin: clamp(28px, 12svh, 110px) auto 0;
  padding: 24px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .28);
  animation: panel-arrive 480ms cubic-bezier(.2, .8, .2, 1) both;
}

.login-heading { margin-bottom: 26px; }
.login-heading h1 span { display: inline-block; color: var(--accent); animation: heartbeat 2.8s ease-in-out infinite; }
.login-heading p { margin: 8px 0 0; color: var(--muted); }
.login-panel form { display: grid; gap: 14px; }

label {
  display: grid;
  min-width: 0;
  gap: 7px;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 600;
}

.remember-control {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  min-height: 52px;
  gap: 10px;
  margin: 0 -4px;
  padding: 5px 4px;
  color: var(--text);
  cursor: pointer;
}

.remember-control > span { display: grid; gap: 1px; min-width: 0; }
.remember-control strong { font-size: .94rem; }
.remember-control span span { color: var(--muted); font-size: .8rem; font-weight: 400; }
.login-button { width: 100%; }
.error { min-height: 1.4em; margin: -2px 0 0; color: #ff9ba2; overflow-wrap: anywhere; }

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 0 20px;
  border-bottom: 1px solid var(--line);
}

.product-name { margin: 0 0 10px; color: #f0a8d0; font-size: .9rem; font-weight: 750; }
.product-name::before { content: "♥"; display: inline-block; margin-right: 7px; color: var(--accent); animation: heartbeat 2.8s ease-in-out infinite; }
.status-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.timer { margin: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.header-actions { display: flex; flex: 0 0 auto; gap: 8px; }
.header-actions button { min-width: 74px; }
#sound-toggle[aria-pressed="false"] { color: var(--muted); }

.command-bar {
  display: grid;
  gap: 14px;
  padding: 22px 0 16px;
  border-bottom: 1px solid var(--line);
}

.control-fields { display: grid; grid-template-columns: minmax(0, .7fr) minmax(0, .9fr); gap: 10px; }
.control-fields .wide { grid-column: 1 / -1; }
.target-picker { min-width: 0; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.target-picker legend { padding: 0 6px; color: var(--muted); font-size: .84rem; font-weight: 600; }
.check-grid { display: grid; gap: 4px; color: var(--muted); }
.check-option {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  min-height: 44px;
  gap: 9px;
  padding: 5px 2px;
  color: var(--text);
  overflow-wrap: anywhere;
  cursor: pointer;
}

.command-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.command-actions .primary-action,
.command-actions .danger { grid-column: 1 / -1; }
.command-actions .primary-action { position: relative; overflow: hidden; }
.command-actions .primary-action::after {
  content: "♥";
  position: absolute;
  right: 13px;
  color: rgba(255, 255, 255, .72);
  animation: heartbeat 2.3s ease-in-out infinite;
}

#action-message {
  min-height: 1.45em;
  margin: 10px 0 4px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

nav {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 5px max(6px, env(safe-area-inset-right)) calc(5px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 96%, transparent);
}

nav button {
  min-width: 0;
  min-height: 52px;
  border: 0;
  border-radius: 7px;
  padding: 6px 4px;
  background: transparent;
  color: var(--muted);
  font-size: .78rem;
}

nav button:hover { background: var(--panel); }
nav button.selected { background: var(--accent-soft); color: #ffd4ec; }

.view { min-width: 0; min-height: 300px; padding-top: 22px; animation: view-enter 260ms ease-out both; }
.love-note {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 0 10px;
  margin: 0 0 18px;
  padding: 16px;
  overflow: hidden;
  border: 1px solid rgba(238, 99, 173, .38);
  border-radius: var(--radius);
  background: linear-gradient(110deg, rgba(238, 99, 173, .13), rgba(169, 139, 255, .08));
}
.love-note::after {
  content: "♥  ♥  ♥";
  position: absolute;
  right: -7px;
  bottom: -13px;
  color: rgba(238, 99, 173, .12);
  font-size: 2.4rem;
  letter-spacing: .2rem;
  transform: rotate(-8deg);
}
.love-heart { grid-row: 1 / 3; color: var(--accent); font-size: 1.55rem; line-height: 1.2; animation: heartbeat 2.2s ease-in-out infinite; }
.love-note p { margin: 0; color: #ffe9f5; font-size: 1.04rem; font-weight: 700; }
.love-note cite { margin-top: 4px; color: var(--muted); font-size: .78rem; font-style: normal; }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 28px; }
.metric-grid article { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); animation: metric-arrive 420ms cubic-bezier(.2, .8, .2, 1) both; }
.metric-grid article:nth-child(2) { animation-delay: 45ms; }
.metric-grid article:nth-child(3) { animation-delay: 90ms; }
.metric-grid article:nth-child(4) { animation-delay: 135ms; }
.metric-grid article:nth-child(5) { animation-delay: 180ms; }
.metric-grid article:last-child { grid-column: 1 / -1; }
.metric-grid span { display: block; color: var(--muted); font-size: .78rem; }
.metric-grid strong { display: block; margin-top: 5px; font-size: 1.05rem; overflow-wrap: anywhere; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.section-heading > * { min-width: 0; }
.badge { max-width: 58%; padding: .25rem .5rem; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); font-size: .75rem; text-align: right; overflow-wrap: anywhere; }
.list { display: grid; min-width: 0; gap: 8px; }
.list.empty { padding: 18px 14px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.list-item { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.list-item > * { min-width: 0; }
.list-item > span { color: var(--muted); font-size: .84rem; overflow-wrap: anywhere; }
.list-item small { display: block; margin-top: 3px; color: var(--muted); overflow-wrap: anywhere; }
.status-online { color: var(--success) !important; }
.status-offline,
.status-degraded { color: var(--danger) !important; }
.proposal-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.proposal-actions button { width: 100%; }
.split-top { margin-top: 28px; }
.inline-controls,
.filter-bar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 11px; align-items: end; margin-bottom: 12px; }

.usage-chart { margin: 0 0 16px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.chart-stage { position: relative; width: 100%; height: 150px; overflow: hidden; border-radius: 7px; background: rgba(15, 10, 18, .72); isolation: isolate; }
.chart-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
#usage-sparkline { z-index: 1; }
#usage-bloom { z-index: 0; image-rendering: auto; filter: blur(5px) brightness(1.5) saturate(1.5); opacity: .55; mix-blend-mode: plus-lighter; }
.usage-chart figcaption { margin-top: 10px; color: var(--muted); font-size: .82rem; }

.burst-heart {
  position: fixed;
  z-index: 80;
  top: 50%;
  left: 50%;
  color: #ff8fc8;
  font-size: 1.25rem;
  pointer-events: none;
  animation: heart-burst 820ms cubic-bezier(.2, .75, .25, 1) var(--burst-delay, 0ms) both;
}

body[data-control-state="active"] #state::after,
body[data-control-state="paused"] #state::after,
body[data-control-state="cooldown"] #state::after {
  content: "♥";
  display: inline-block;
  margin-left: 9px;
  color: var(--accent);
  font-size: .72em;
  animation: heartbeat 1.7s ease-in-out infinite;
}

@keyframes panel-arrive {
  from { opacity: 0; transform: translateY(16px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

@keyframes metric-arrive {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes heartbeat {
  0%, 28%, 100% { transform: scale(1); }
  12% { transform: scale(1.16); }
  20% { transform: scale(.96); }
}

@keyframes heart-drift {
  0% { opacity: 0; transform: translate3d(0, 0, 0) rotate(-8deg) scale(.7); }
  12% { opacity: 1; }
  50% { transform: translate3d(18px, -52svh, 0) rotate(10deg) scale(1); }
  88% { opacity: .9; }
  100% { opacity: 0; transform: translate3d(-10px, -112svh, 0) rotate(-12deg) scale(.82); }
}

@keyframes heart-burst {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(.45); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--burst-x)), -145px) rotate(18deg) scale(1.25); }
}

@media (min-width: 600px) {
  main { padding: 28px 24px 48px; }
  .login-panel { padding: 30px; }
  .control-fields { grid-template-columns: 120px 150px minmax(240px, 1fr); }
  .control-fields .wide { grid-column: auto; }
  .check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 14px; }
  .command-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .command-actions .primary-action,
  .command-actions .danger { grid-column: auto; }
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric-grid article:last-child { grid-column: auto; }
  .list-item { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .inline-controls { grid-template-columns: 180px minmax(240px, 1fr) auto; }
  .filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  nav {
    position: static;
    display: flex;
    gap: 2px;
    margin-top: 6px;
    padding: 0;
    border-top: 0;
    border-bottom: 1px solid var(--line);
    background: transparent;
  }
  nav button { min-height: 46px; border-radius: 0; padding: 9px 15px; border-bottom: 2px solid transparent; font-size: .9rem; }
  nav button.selected { background: transparent; border-bottom-color: var(--accent); color: var(--text); }
}

@media (max-width: 599px) {
  .app-header { align-items: stretch; flex-direction: column; }
  .header-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .header-actions button { width: 100%; min-width: 0; }
}

@media (min-width: 900px) {
  main { padding-top: 36px; }
  .command-bar { grid-template-columns: minmax(0, 1fr); }
  .command-actions { grid-template-columns: repeat(6, auto); justify-content: start; }
  .command-actions button { min-width: 126px; }
  .metric-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
  .filter-bar { grid-template-columns: 140px 180px 220px minmax(180px, 1fr); }
}

@media (max-width: 380px) {
  main { padding-right: max(10px, env(safe-area-inset-right)); padding-left: max(10px, env(safe-area-inset-left)); }
  .control-fields,
  .command-actions { grid-template-columns: minmax(0, 1fr); }
  .control-fields .wide,
  .command-actions .primary-action,
  .command-actions .danger { grid-column: auto; }
  nav button { font-size: .72rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .heart-field { display: none; }
}
