:root {
  color-scheme: light;
  --bg-top: #fafbfd;
  --bg-bottom: #edf1f4;
  --panel: #f4f6f8;
  --panel-deep: #dde2e6;
  --panel-edge: rgba(134, 142, 150, 0.16);
  --bezel: #8d918f;
  --text: #34383d;
  --muted: #717880;
  --accent: #90969d;
  --accent-soft: #e7eaee;
  --danger: #c77468;
  --screen-bg: #060907;
  --screen-tint: rgba(96, 186, 126, 0.1);
  --shadow: 0 22px 56px rgba(103, 111, 119, 0.12);
  --page-max: 1360px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.72), transparent 26%),
    linear-gradient(180deg, var(--bg-top) 0%, #f4f7fa 42%, var(--bg-bottom) 100%);
  color: var(--text);
  font-family: "Geneva", "Trebuchet MS", sans-serif;
}

code {
  font-family: "Monaco", "SFMono-Regular", "Consolas", monospace;
}

h1,
h2,
p {
  margin: 0;
}

h2 {
  font-size: clamp(20px, 2.2vw, 28px);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 8px 12px 12px;
}

.workspace {
  margin-top: 0;
  min-height: calc(100svh - 20px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.controls {
  margin-top: 10px;
}

.card {
  padding: 18px;
  border: 1px solid var(--panel-edge);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(249, 250, 252, 0.98), rgba(239, 243, 246, 0.98)),
    linear-gradient(135deg, rgba(255, 255, 255, 0.28), transparent 50%);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.panel-heading p,
.tips p {
  color: var(--muted);
  line-height: 1.55;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-size: 14px;
}

.field input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid rgba(140, 148, 156, 0.16);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  font-size: 15px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.button {
  appearance: none;
  border: 1px solid rgba(140, 148, 156, 0.14);
  border-radius: 14px;
  padding: 11px 16px;
  background:
    linear-gradient(180deg, #fafbfc, #e5e9ed);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    0 6px 14px rgba(112, 118, 126, 0.08);
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    opacity 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    0 10px 20px rgba(112, 118, 126, 0.12);
}

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

.button-primary {
  background: linear-gradient(180deg, #fbfcfd, var(--accent-soft));
  font-weight: 700;
}

.button-danger {
  background: linear-gradient(180deg, rgba(234, 202, 196, 0.95), rgba(221, 183, 177, 0.95));
  color: #87453c;
}

.tips {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  font-size: 14px;
}

.monitor-shell {
  position: relative;
  width: min(100%, 1160px);
  margin: 0 auto;
  padding: 24px 16px 0;
  border-radius: 34px 34px 26px 26px;
  border: 1px solid rgba(141, 149, 157, 0.16);
  background:
    linear-gradient(180deg, #fbfcfd 0%, #f0f3f5 24%, #e4e8eb 70%, #d9dee2 100%);
  box-shadow:
    0 24px 66px rgba(107, 114, 121, 0.14),
    inset 0 2px 0 rgba(255, 255, 255, 0.64),
    inset 0 -14px 22px rgba(122, 128, 134, 0.1);
}

.monitor-shell::after {
  content: "";
  position: absolute;
  inset: auto 34px 112px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(138, 146, 154, 0.12), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.monitor-handle {
  position: absolute;
  top: 10px;
  left: 50%;
  width: 150px;
  height: 14px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: linear-gradient(180deg, #e9edf1, #d5dce2);
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.55),
    inset 0 -2px 3px rgba(118, 126, 134, 0.14);
}

.monitor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 8px 12px;
}

.monitor-mark {
  display: grid;
  gap: 3px;
}

.monitor-brand {
  font-size: 18px;
  letter-spacing: 0.14em;
  color: #5f666d;
  font-weight: 700;
}

.monitor-subtitle {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(95, 102, 109, 0.66);
}

.monitor-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-wrap {
  min-width: 136px;
  padding: 9px 12px;
  border-radius: 14px;
  border: 1px solid rgba(142, 150, 157, 0.14);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.status-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.status-wrap strong {
  display: block;
  color: var(--text);
  font-size: 15px;
}

.monitor-leds {
  display: flex;
  gap: 8px;
}

.led {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.led-green {
  background: radial-gradient(circle at 35% 35%, #deffe0, #49ab5d 66%, #235f2f 100%);
}

.led-amber {
  background: radial-gradient(circle at 35% 35%, #ffefca, #d39a3d 66%, #7d4e16 100%);
}

.monitor-bezel {
  padding: 12px;
  border-radius: 24px;
  background: linear-gradient(180deg, #a1a5a3, var(--bezel));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -2px 0 rgba(95, 102, 106, 0.22);
}

.monitor-screen {
  position: relative;
  display: flex;
  justify-content: center;
  overflow: hidden;
  padding: 12px;
  border-radius: 28px 28px 22px 22px / 20px 20px 14px 14px;
  background:
    radial-gradient(circle at 50% 36%, var(--screen-tint), transparent 44%),
    linear-gradient(180deg, #0c130e, var(--screen-bg));
  box-shadow:
    inset 0 0 0 1px rgba(149, 212, 168, 0.08),
    inset 0 0 42px rgba(0, 0, 0, 0.72);
}

.monitor-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 24%, transparent 70%, rgba(255, 255, 255, 0.04)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 16%, transparent 84%, rgba(255, 255, 255, 0.04));
}

.screen-glow {
  position: absolute;
  inset: 10% 13%;
  border-radius: 24px;
  pointer-events: none;
  background: radial-gradient(circle at 50% 45%, rgba(77, 193, 125, 0.08), transparent 56%);
}

.player-stage {
  width: 100%;
  max-width: min(calc(64svh * 4 / 3), calc((100svh - 228px) * 4 / 3));
  aspect-ratio: 4 / 3;
  min-height: 0;
  max-height: min(64svh, calc(100svh - 228px));
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid rgba(143, 220, 167, 0.12);
  background:
    linear-gradient(180deg, rgba(8, 12, 10, 0.96), rgba(3, 6, 4, 0.98)),
    radial-gradient(circle at 50% 35%, rgba(84, 208, 122, 0.1), transparent 32%);
}

.player-stage::before {
  content: "等待加载 bundle";
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: rgba(238, 242, 232, 0.42);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.player-stage > * {
  position: relative;
  z-index: 1;
}

.player-stage:not(:empty)::before {
  display: none;
}

.monitor-chin {
  display: grid;
  grid-template-columns: 58px 1fr 80px;
  gap: 14px;
  align-items: center;
  padding: 10px 8px 0;
}

.monitor-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 8px 0 4px;
}

.monitor-save-button {
  min-width: 150px;
  border-radius: 16px;
  padding: 8px 18px;
  background: linear-gradient(180deg, #fafbfc, #e3e7eb);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 8px 16px rgba(112, 118, 126, 0.1);
}

.monitor-log-button {
  min-width: 88px;
  border-radius: 16px;
}

.rainbow-badge {
  display: flex;
  align-items: stretch;
  width: 40px;
  height: 48px;
  padding: 7px 8px;
  gap: 3px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.24);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.rainbow-badge span {
  flex: 1;
  border-radius: 999px;
}

.rainbow-badge span:nth-child(1) {
  background: #56b2e9;
}

.rainbow-badge span:nth-child(2) {
  background: #58bd7d;
}

.rainbow-badge span:nth-child(3) {
  background: #f4da62;
}

.rainbow-badge span:nth-child(4) {
  background: #f2994a;
}

.rainbow-badge span:nth-child(5) {
  background: #d86ea8;
}

.speaker-grill {
  height: 32px;
  border-radius: 12px;
  background:
    radial-gradient(circle, rgba(132, 139, 145, 0.82) 20%, transparent 22%) 0 0 / 9px 9px,
    linear-gradient(180deg, rgba(232, 236, 240, 0.96), rgba(208, 214, 220, 0.96));
  border: 1px solid rgba(129, 137, 144, 0.24);
}

.drive-slot {
  width: 80px;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, #bcc4cb, #8f989f);
  box-shadow:
    inset 0 2px 3px rgba(82, 90, 97, 0.22),
    inset 0 -1px 0 rgba(255, 255, 255, 0.18);
}

.monitor-stand {
  width: 148px;
  height: 24px;
  margin: 0 auto;
  background: linear-gradient(180deg, #e2e6ea, #c6cdd3);
  clip-path: polygon(16% 0, 84% 0, 72% 100%, 28% 100%);
}

.monitor-base {
  width: 250px;
  height: 14px;
  margin: -1px auto 0;
  border-radius: 999px 999px 14px 14px;
  background: linear-gradient(180deg, #bdc5cc, #9ea7af);
}

.log-output {
  margin-top: 14px;
  min-height: 280px;
  max-height: calc(100vh - 160px);
  overflow: auto;
  padding: 16px;
  border-radius: 18px;
  background: rgba(9, 12, 10, 0.94);
  color: #cde8cd;
  border: 1px solid rgba(132, 188, 130, 0.16);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
}

.log-drawer {
  position: fixed;
  top: 16px;
  right: 16px;
  bottom: 16px;
  width: min(420px, calc(100vw - 32px));
  z-index: 30;
  padding: 16px;
  border-radius: 22px;
  border: 1px solid rgba(132, 141, 149, 0.16);
  background:
    linear-gradient(180deg, rgba(249, 250, 252, 0.98), rgba(237, 241, 245, 0.98)),
    linear-gradient(135deg, rgba(255, 255, 255, 0.22), transparent 50%);
  box-shadow: 0 30px 90px rgba(109, 116, 124, 0.16);
  transform: translateX(calc(100% + 24px));
  transition: transform 220ms ease;
}

.log-drawer.is-open {
  transform: translateX(0);
}

.log-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.kicker {
  margin-bottom: 8px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
}

.log-close {
  appearance: none;
  border: 1px solid rgba(132, 141, 149, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--text);
  padding: 9px 12px;
  font-family: inherit;
  cursor: pointer;
}

@media (max-width: 1080px) {
  .controls-grid {
    grid-template-columns: 1fr;
  }

  .monitor-shell {
    width: min(100%, 1020px);
  }

  .player-stage {
    max-width: min(calc(60svh * 4 / 3), calc((100svh - 196px) * 4 / 3));
    max-height: min(60svh, calc(100svh - 196px));
  }
}

@media (max-width: 720px) {
  .page {
    padding: 8px 8px 14px;
  }

  .workspace {
    min-height: calc(100svh - 14px);
    align-items: flex-start;
  }

  .card {
    padding: 16px;
    border-radius: 18px;
  }

  .panel-heading,
  .monitor-head,
  .monitor-status {
    flex-direction: column;
    align-items: flex-start;
  }

  .status-wrap {
    min-width: 0;
    width: 100%;
  }

  .monitor-shell {
    padding: 22px 12px 0;
    border-radius: 28px 28px 22px 22px;
  }

  .monitor-bezel,
  .monitor-screen {
    padding: 10px;
  }

  .player-stage {
    max-width: 100%;
    max-height: none;
  }

  .monitor-chin {
    grid-template-columns: 48px 1fr 66px;
    gap: 10px;
  }

  .monitor-actions {
    padding: 8px 0 4px;
    gap: 10px;
  }

  .monitor-save-button {
    min-width: 132px;
    padding: 8px 16px;
  }

  .monitor-log-button {
    min-width: 78px;
  }

  .rainbow-badge {
    width: 34px;
    height: 42px;
    padding: 6px 7px;
  }

  .speaker-grill {
    height: 26px;
  }

  .drive-slot {
    width: 66px;
    height: 10px;
  }

  .monitor-stand {
    width: 122px;
    height: 20px;
  }

  .monitor-base {
    width: 198px;
    height: 13px;
  }

  .log-drawer {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: 62px;
    width: auto;
  }
}
