:root {
  --bg: #06100e;
  --bg-soft: #0a1814;
  --surface: rgba(13, 29, 24, 0.82);
  --surface-strong: #10241e;
  --line: rgba(192, 238, 221, 0.11);
  --line-strong: rgba(192, 238, 221, 0.2);
  --text: #f0f8f5;
  --muted: #92aaa1;
  --muted-bright: #b7cbc3;
  --accent: #50e3a4;
  --accent-bright: #84f3c2;
  --accent-deep: #1bad74;
  --warning: #ffc66d;
  --danger: #ff7d78;
  --info: #70c7ff;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
  --radius-lg: 30px;
  --radius-md: 20px;
  --radius-sm: 13px;
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% -10%, rgba(50, 178, 126, 0.14), transparent 34rem),
    linear-gradient(160deg, #07120f 0%, #06100e 58%, #071410 100%);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.ambient {
  position: fixed;
  z-index: 0;
  width: 28rem;
  height: 28rem;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(1px);
  opacity: 0.2;
}

.ambient-one {
  top: 12%;
  right: -18rem;
  background: radial-gradient(circle, rgba(63, 226, 160, 0.34), transparent 68%);
}

.ambient-two {
  bottom: -16rem;
  left: -13rem;
  background: radial-gradient(circle, rgba(55, 139, 213, 0.18), transparent 68%);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 0 max(28px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  margin-bottom: 36px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  border: 1px solid rgba(80, 227, 164, 0.28);
  border-radius: 14px;
  color: var(--accent-bright);
  background: linear-gradient(145deg, rgba(80, 227, 164, 0.13), rgba(80, 227, 164, 0.04));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.05), 0 10px 28px rgba(0, 0, 0, 0.2);
}

.brand-mark svg {
  width: 22px;
  height: 22px;
  stroke-width: 2.2;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 0.94rem;
  letter-spacing: 0.015em;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
}

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

.api-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 35px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted-bright);
  background: rgba(9, 22, 18, 0.72);
  font-size: 0.76rem;
  font-weight: 650;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 4px rgba(146, 170, 161, 0.08);
}

.api-state.is-online .status-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(80, 227, 164, 0.1), 0 0 15px rgba(80, 227, 164, 0.5);
}

.api-state.is-error .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 125, 120, 0.1);
}

.icon-button,
.text-button {
  border: 1px solid var(--line);
  color: var(--muted-bright);
  background: rgba(9, 22, 18, 0.72);
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease, transform 160ms ease;
}

.icon-button:hover,
.text-button:hover {
  border-color: var(--line-strong);
  color: var(--text);
  background: rgba(16, 38, 31, 0.92);
}

.icon-button:active,
.text-button:active {
  transform: scale(0.96);
}

.icon-button {
  display: grid;
  width: 37px;
  height: 37px;
  padding: 0;
  place-items: center;
  border-radius: 12px;
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.hero-card,
.command-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(130deg, rgba(17, 39, 32, 0.86), rgba(8, 20, 16, 0.94)),
    var(--surface);
  box-shadow: var(--shadow), inset 0 1px rgba(255, 255, 255, 0.025);
}

.hero-card::after {
  content: "";
  position: absolute;
  right: -8rem;
  bottom: -14rem;
  width: 32rem;
  height: 32rem;
  border: 1px solid rgba(80, 227, 164, 0.06);
  border-radius: 50%;
  box-shadow: 0 0 0 50px rgba(80, 227, 164, 0.018), 0 0 0 100px rgba(80, 227, 164, 0.012);
  pointer-events: none;
}

.hero-card {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  min-height: 442px;
  padding: 54px clamp(34px, 6vw, 72px);
  align-items: center;
  gap: 30px;
}

.hero-copy,
.power-zone {
  position: relative;
  z-index: 1;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow span {
  width: 20px;
  height: 1px;
  background: currentColor;
  box-shadow: 8px 0 16px currentColor;
}

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

h1 {
  max-width: 590px;
  margin-bottom: 23px;
  font-size: clamp(2.2rem, 5.4vw, 4.55rem);
  font-weight: 720;
  letter-spacing: -0.052em;
  line-height: 1.04;
}

.hero-copy > p:last-child {
  max-width: 570px;
  margin-bottom: 0;
  color: var(--muted-bright);
  font-size: clamp(0.91rem, 1.5vw, 1.02rem);
  line-height: 1.85;
}

.power-zone {
  display: grid;
  min-height: 310px;
  place-items: center;
  align-content: center;
}

.power-halo {
  position: absolute;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(80, 227, 164, 0.14), rgba(80, 227, 164, 0.035) 45%, transparent 69%);
  opacity: 0.75;
  transform: scale(0.9);
  transition: opacity 250ms ease, transform 250ms ease;
}

.power-zone:has(.power-button:not(:disabled):hover) .power-halo,
.power-zone:has(.power-button.is-holding) .power-halo {
  opacity: 1;
  transform: scale(1.08);
}

.power-button {
  --hold-progress: 0;
  position: relative;
  display: grid;
  width: 226px;
  height: 226px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 180ms ease, filter 180ms ease;
}

.power-button:not(:disabled):hover {
  transform: translateY(-3px);
  filter: brightness(1.05);
}

.power-button:not(:disabled):active,
.power-button.is-holding {
  transform: scale(0.975);
}

.power-button:focus-visible {
  outline: 3px solid rgba(132, 243, 194, 0.58);
  outline-offset: 7px;
}

.power-button:disabled {
  cursor: not-allowed;
  filter: saturate(0.4);
  opacity: 0.62;
}

.power-progress {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(var(--accent-bright) calc(var(--hold-progress) * 1turn), rgba(157, 205, 187, 0.11) 0);
  box-shadow: 0 0 40px rgba(80, 227, 164, calc(var(--hold-progress) * 0.32));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 0);
  mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 0);
}

.power-face {
  position: absolute;
  inset: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  border: 1px solid rgba(192, 238, 221, 0.13);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 32%, rgba(80, 227, 164, 0.11), transparent 46%),
    linear-gradient(145deg, #122a22, #091b16);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.08),
    inset 0 -12px 28px rgba(0, 0, 0, 0.22),
    0 22px 45px rgba(0, 0, 0, 0.35);
}

.power-face svg {
  width: 49px;
  height: 49px;
  margin-bottom: 17px;
  color: var(--accent-bright);
  stroke-width: 1.65;
  filter: drop-shadow(0 0 13px rgba(80, 227, 164, 0.32));
}

.power-face strong {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.power-face small {
  max-width: 140px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.69rem;
  line-height: 1.35;
}

.power-hint {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
}

.status-section {
  margin-top: 44px;
}

.section-heading,
.command-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.section-heading {
  margin-bottom: 19px;
}

.section-heading .eyebrow,
.command-header .eyebrow {
  margin-bottom: 8px;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 3vw, 2rem);
  letter-spacing: -0.035em;
}

.text-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 650;
}

.text-button svg {
  width: 15px;
  height: 15px;
}

.text-button.is-loading svg {
  animation: spin 850ms linear infinite;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
}

.metric-card {
  display: flex;
  min-width: 0;
  min-height: 142px;
  padding: 23px 20px;
  align-items: flex-start;
  gap: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(11, 26, 21, 0.68);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.02);
  transition: border-color 180ms ease, transform 180ms ease, background 180ms ease;
}

.metric-card:hover {
  border-color: rgba(192, 238, 221, 0.17);
  background: rgba(14, 33, 27, 0.78);
  transform: translateY(-2px);
}

.metric-icon {
  display: grid;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(80, 227, 164, 0.12);
  border-radius: 13px;
  color: var(--accent);
  background: rgba(80, 227, 164, 0.065);
}

.metric-icon svg {
  width: 20px;
  height: 20px;
}

.seen-icon {
  color: var(--info);
  border-color: rgba(112, 199, 255, 0.12);
  background: rgba(112, 199, 255, 0.06);
}

.signal-icon {
  color: #c4a4ff;
  border-color: rgba(196, 164, 255, 0.12);
  background: rgba(196, 164, 255, 0.06);
}

.cooldown-icon {
  color: var(--warning);
  border-color: rgba(255, 198, 109, 0.12);
  background: rgba(255, 198, 109, 0.06);
}

.metric-card > div {
  min-width: 0;
}

.metric-card span:not(.metric-icon),
.command-body span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.69rem;
  letter-spacing: 0.045em;
}

.metric-card strong,
.metric-card small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-card strong {
  margin-bottom: 8px;
  font-size: 0.98rem;
  font-weight: 680;
}

.metric-card small {
  color: var(--muted);
  font-size: 0.68rem;
}

.value-online {
  color: var(--accent-bright);
}

.value-offline {
  color: var(--danger);
}

.command-card {
  margin-top: 14px;
  padding: 28px 30px 25px;
  border-radius: var(--radius-md);
  background: rgba(11, 26, 21, 0.7);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.02);
}

.command-badge {
  display: inline-flex;
  align-items: center;
  min-height: 29px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted-bright);
  background: rgba(255, 255, 255, 0.025);
  font-size: 0.68rem;
  font-weight: 700;
}

.command-badge.is-active {
  border-color: rgba(112, 199, 255, 0.22);
  color: var(--info);
  background: rgba(112, 199, 255, 0.06);
}

.command-badge.is-success {
  border-color: rgba(80, 227, 164, 0.22);
  color: var(--accent-bright);
  background: rgba(80, 227, 164, 0.06);
}

.command-badge.is-warning {
  border-color: rgba(255, 198, 109, 0.22);
  color: var(--warning);
  background: rgba(255, 198, 109, 0.06);
}

.command-badge.is-error {
  border-color: rgba(255, 125, 120, 0.22);
  color: var(--danger);
  background: rgba(255, 125, 120, 0.06);
}

.command-body {
  display: grid;
  grid-template-columns: 1.45fr 1fr 0.7fr;
  gap: 24px;
  margin-top: 27px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.command-body > div {
  min-width: 0;
}

.command-body strong {
  display: block;
  overflow: hidden;
  color: var(--muted-bright);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.76rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-detail {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.6;
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 26px 4px 0;
  color: #6f887f;
  font-size: 0.66rem;
}

footer span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

footer i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-deep);
}

.auth-dialog {
  width: min(470px, calc(100% - 30px));
  margin: auto;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 25px;
  color: var(--text);
  background: #0d211b;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.65);
}

.auth-dialog::backdrop {
  background: rgba(1, 8, 6, 0.79);
  backdrop-filter: blur(8px);
}

.auth-dialog form {
  padding: 35px;
}

.dialog-mark {
  display: grid;
  width: 51px;
  height: 51px;
  margin-bottom: 25px;
  place-items: center;
  border: 1px solid rgba(80, 227, 164, 0.2);
  border-radius: 16px;
  color: var(--accent-bright);
  background: rgba(80, 227, 164, 0.08);
}

.dialog-mark svg {
  width: 25px;
  height: 25px;
}

.auth-dialog h2 {
  margin-bottom: 11px;
  font-size: 1.65rem;
}

.dialog-copy {
  margin-bottom: 25px;
  color: var(--muted);
  font-size: 0.79rem;
  line-height: 1.7;
}

.auth-dialog label {
  display: block;
  margin-bottom: 9px;
  color: var(--muted-bright);
  font-size: 0.72rem;
  font-weight: 650;
}

.token-field {
  display: flex;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: rgba(4, 14, 11, 0.68);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.token-field:focus-within {
  border-color: rgba(80, 227, 164, 0.5);
  box-shadow: 0 0 0 3px rgba(80, 227, 164, 0.08);
}

.token-field input {
  min-width: 0;
  flex: 1;
  padding: 13px 14px;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.79rem;
}

.token-field input::placeholder {
  color: #536b62;
}

.token-field button {
  padding: 0 14px;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 0.7rem;
}

.remember-token-option {
  display: flex !important;
  align-items: flex-start;
  gap: 10px;
  margin: 13px 0 0 !important;
  color: var(--muted-bright) !important;
  cursor: pointer;
}

.remember-token-option input {
  width: 17px;
  height: 17px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.remember-token-option span {
  display: grid;
  gap: 3px;
}

.remember-token-option strong {
  font-size: 0.73rem;
}

.remember-token-option small {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 400;
  line-height: 1.45;
}

.form-error {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 0.7rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 17px;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  padding: 0 15px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.73rem;
  font-weight: 700;
  transition: opacity 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.primary-button:active,
.secondary-button:active {
  transform: scale(0.97);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.primary-button {
  border: 1px solid var(--accent);
  color: #04130d;
  background: linear-gradient(135deg, var(--accent-bright), var(--accent));
}

.secondary-button {
  border: 1px solid var(--line-strong);
  color: var(--muted-bright);
  background: transparent;
}

#clear-token-button {
  margin-right: auto;
  color: var(--danger);
}

.toast {
  position: fixed;
  z-index: 20;
  right: max(22px, env(safe-area-inset-right));
  bottom: max(22px, env(safe-area-inset-bottom));
  max-width: min(390px, calc(100% - 44px));
  padding: 13px 17px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  color: var(--text);
  background: rgba(16, 38, 31, 0.96);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
  font-size: 0.76rem;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-error {
  border-color: rgba(255, 125, 120, 0.3);
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 900px) {
  .hero-card {
    grid-template-columns: 1fr;
    padding-top: 45px;
    text-align: center;
  }

  .hero-copy {
    display: flex;
    align-items: center;
    flex-direction: column;
  }

  .hero-copy .eyebrow {
    justify-content: center;
  }

  .power-zone {
    min-height: 290px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .app-shell {
    width: min(100% - 24px, 1120px);
    padding-top: max(14px, env(safe-area-inset-top));
  }

  .topbar {
    margin-bottom: 20px;
  }

  .api-state {
    width: 35px;
    padding: 0;
    justify-content: center;
  }

  .api-state span:last-child {
    display: none;
  }

  .hero-card {
    min-height: auto;
    padding: 38px 20px 29px;
    border-radius: 24px;
  }

  h1 {
    max-width: 350px;
    font-size: clamp(2.05rem, 12vw, 3.2rem);
  }

  .hero-copy > p:last-child {
    font-size: 0.83rem;
    line-height: 1.75;
  }

  .power-zone {
    min-height: 258px;
  }

  .power-halo {
    width: 240px;
    height: 240px;
  }

  .power-button {
    width: 202px;
    height: 202px;
  }

  .power-face {
    inset: 14px;
  }

  .power-face svg {
    width: 43px;
    height: 43px;
    margin-bottom: 14px;
  }

  .status-section {
    margin-top: 34px;
  }

  .metric-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .metric-card {
    min-height: 109px;
    padding: 20px;
    align-items: center;
  }

  .command-card {
    padding: 25px 20px 22px;
  }

  .command-body {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
    padding-left: 2px;
  }

  .auth-dialog form {
    padding: 28px 21px 22px;
  }

  .dialog-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  #clear-token-button {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-right: 0;
  }
}

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