:root {
  color-scheme: light;
  --desktop-bg: #eef1f4;
  --desktop-panel: #ffffff;
  --desktop-ink: #18212b;
  --desktop-muted: #687381;
  --desktop-line: #dbe1e7;
  --desktop-accent: #ff9800;
  --desktop-accent-dark: #d97706;
  --desktop-navy: #17202b;
  --desktop-error: #b42318;
  --desktop-error-bg: #fff0ee;
  --desktop-shadow: 0 24px 70px rgba(23, 32, 43, 0.14);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 0;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--desktop-bg);
  color: var(--desktop-ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[hidden] {
  display: none !important;
}

.login-view {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 152, 0, 0.16), transparent 30%),
    radial-gradient(circle at 87% 82%, rgba(38, 117, 198, 0.14), transparent 32%),
    linear-gradient(145deg, #f8fafc 0%, #e9eef3 100%);
}

.login-card {
  width: min(100%, 470px);
  padding: 38px;
  border: 1px solid rgba(219, 225, 231, 0.92);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--desktop-shadow);
}

.login-mark,
.brand-mark {
  display: grid;
  place-items: center;
  border: 2px solid var(--desktop-accent);
  color: var(--desktop-accent-dark);
  font-weight: 900;
  letter-spacing: -0.04em;
}

.login-mark {
  width: 64px;
  height: 64px;
  margin-bottom: 28px;
  border-radius: 20px;
  background: #fff8ec;
  font-size: 17px;
}

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

.login-card h1,
.desktop-head h1 {
  margin: 0;
  letter-spacing: -0.035em;
}

.login-card h1 {
  font-size: clamp(30px, 5vw, 42px);
  line-height: 1.08;
}

.login-copy {
  margin: 16px 0 28px;
  color: var(--desktop-muted);
  font-size: 15px;
  line-height: 1.75;
}

.token-field {
  display: grid;
  gap: 9px;
}

.token-field span {
  font-size: 14px;
  font-weight: 750;
}

.token-field input {
  width: 100%;
  height: 50px;
  padding: 0 15px;
  border: 1px solid var(--desktop-line);
  border-radius: 12px;
  outline: none;
  background: #f9fafb;
  color: var(--desktop-ink);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.token-field input:focus {
  border-color: var(--desktop-accent);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(255, 152, 0, 0.14);
}

.form-message {
  min-height: 21px;
  margin: 10px 0;
  color: var(--desktop-error);
  font-size: 13px;
}

.form-message.success {
  color: #16794c;
}

.login-form {
  display: grid;
}

.primary-button {
  width: 100%;
  height: 50px;
  border: 0;
  border-radius: 12px;
  background: var(--desktop-navy);
  color: #fff;
  font-weight: 800;
  transition: transform 0.16s ease, background 0.16s ease, opacity 0.16s ease;
}

.primary-button:hover {
  background: #263342;
}

.primary-button:active {
  transform: translateY(1px);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.secondary-button {
  width: 100%;
  height: 48px;
  border: 1px solid var(--desktop-line);
  border-radius: 12px;
  background: #fff;
  color: var(--desktop-ink);
  font-weight: 800;
  transition: border-color 0.16s ease, background 0.16s ease, opacity 0.16s ease;
}

.secondary-button:hover {
  border-color: #b8c2cc;
  background: #f8fafb;
}

.secondary-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.token-fallback {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--desktop-line);
}

.token-fallback summary {
  width: fit-content;
  color: var(--desktop-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.6;
}

.token-fallback summary:hover {
  color: var(--desktop-ink);
}

.token-fallback[open] summary {
  margin-bottom: 14px;
}

.security-note {
  margin: 18px 0 0;
  color: #7c8794;
  font-size: 12px;
  line-height: 1.65;
}

.desktop-app {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  width: 100%;
  height: 100%;
  min-height: 0;
}

.desktop-nav {
  position: relative;
  z-index: 2;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  padding: 24px 16px 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 24%),
    var(--desktop-navy);
  color: #f8fafc;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 25px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-mark {
  width: 43px;
  height: 43px;
  flex: 0 0 auto;
  border-radius: 13px;
  background: rgba(255, 152, 0, 0.08);
  font-size: 11px;
}

.brand-block strong,
.brand-block span {
  display: block;
}

.brand-block strong {
  font-size: 15px;
}

.brand-block span {
  margin-top: 3px;
  color: #96a2b0;
  font-size: 12px;
}

.route-nav {
  display: grid;
  gap: 7px;
  margin-top: 24px;
}

.route-button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 49px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: #b8c1cc;
  font-size: 14px;
  font-weight: 700;
  text-align: left;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.route-button:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.route-button.active {
  border-color: rgba(255, 152, 0, 0.28);
  background: rgba(255, 152, 0, 0.13);
  color: #ffc15f;
}

.nav-footer {
  display: grid;
  gap: 12px;
  margin-top: auto;
}

.session-state {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  color: #91a0ae;
  font-size: 11px;
}

.session-state i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #32c67e;
  box-shadow: 0 0 0 4px rgba(50, 198, 126, 0.12);
}

.logout-button {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.04);
  color: #c9d1da;
  font-size: 13px;
  font-weight: 700;
}

.logout-button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.desktop-main {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: 84px minmax(0, 1fr);
  background: var(--desktop-panel);
}

.desktop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 28px;
  border-bottom: 1px solid var(--desktop-line);
  background: rgba(255, 255, 255, 0.96);
}

.desktop-head h1 {
  font-size: 26px;
  line-height: 1;
}

.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid var(--desktop-line);
  border-radius: 999px;
  background: #f8fafb;
  color: var(--desktop-muted);
  font-size: 12px;
  white-space: nowrap;
}

.connection-status::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f0a12a;
  content: "";
}

.connection-status.ready::before {
  background: #2bb673;
}

.connection-status.error::before {
  background: #d92d20;
}

.frame-host {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #f4f5f7;
}

.desktop-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.desktop-frame:not(.ready) {
  visibility: hidden;
}

.frame-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--desktop-muted);
  font-size: 13px;
}

.frame-loading span {
  width: 30px;
  height: 30px;
  border: 3px solid #d9dee5;
  border-top-color: var(--desktop-accent);
  border-radius: 50%;
  animation: desktop-spin 0.8s linear infinite;
}

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

@media (max-width: 760px) {
  .desktop-app {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .desktop-nav {
    padding: 18px 10px 14px;
  }

  .brand-block {
    justify-content: center;
    padding: 0 0 18px;
  }

  .brand-block > div:last-child,
  .route-button span,
  .session-state span,
  .logout-button span {
    display: none;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .route-button,
  .logout-button {
    justify-content: center;
    padding: 0;
  }

  .desktop-head {
    padding: 0 18px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --desktop-bg: #10161d;
    --desktop-panel: #151c24;
    --desktop-ink: #edf1f5;
    --desktop-muted: #9aa6b2;
    --desktop-line: #2b3540;
    --desktop-navy: #0d1319;
    --desktop-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  }

  .login-view {
    background:
      radial-gradient(circle at 12% 18%, rgba(255, 152, 0, 0.14), transparent 30%),
      radial-gradient(circle at 87% 82%, rgba(38, 117, 198, 0.12), transparent 32%),
      linear-gradient(145deg, #131a21 0%, #0d1319 100%);
  }

  .login-card,
  .desktop-head {
    background: rgba(21, 28, 36, 0.97);
  }

  .login-mark {
    background: rgba(255, 152, 0, 0.08);
  }

  .token-field input {
    background: #111820;
    color: var(--desktop-ink);
  }

  .secondary-button {
    border-color: var(--desktop-line);
    background: #111820;
    color: var(--desktop-ink);
  }

  .secondary-button:hover {
    border-color: #465463;
    background: #17212b;
  }

  .connection-status {
    background: #111820;
  }
}
