:root {
  color-scheme: light;
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface-strong: #f8faf9;
  --ink: #17211d;
  --muted: #68736e;
  --line: #d9e0dc;
  --teal: #0f766e;
  --teal-dark: #0b5f59;
  --coral: #d65f42;
  --amber: #b7791f;
  --blue: #3867b7;
  --shadow: 0 18px 48px rgba(23, 33, 29, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(15, 118, 110, 0.05) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  font-size: 28px;
  font-weight: 750;
}

h2 {
  font-size: 16px;
}

h3 {
  font-size: 14px;
  font-weight: 750;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 14px;
  gap: 8px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

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

.button.primary {
  background: var(--teal);
  color: #fff;
}

.button.primary:hover {
  background: var(--teal-dark);
}

.button.ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.button.ghost:hover {
  border-color: #a6b5af;
}

.workspace {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 18px;
  align-items: start;
}

.controls-panel,
.json-panel,
.output-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(23, 33, 29, 0.06);
}

.controls-panel {
  position: sticky;
  top: 18px;
  padding: 16px;
}

.control-group {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.control-group label,
.switch-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  background: var(--surface-strong);
  color: var(--ink);
}

select:focus,
button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  outline-offset: 2px;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  border-top: 1px solid var(--line);
}

.switch {
  position: relative;
  display: inline-flex;
  width: 48px;
  height: 26px;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: #c7d0cc;
  transition: background 160ms ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  transition: transform 160ms ease;
}

.switch input:checked + span {
  background: var(--teal);
}

.switch input:checked + span::after {
  transform: translateX(22px);
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 14px 0;
}

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

.mini-stat {
  min-height: 64px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.mini-stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.mini-stat strong {
  display: block;
  margin-top: 7px;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.content-panel {
  display: grid;
  gap: 18px;
}

.preview-band {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  align-items: stretch;
}

.phone-preview {
  min-height: 360px;
  border-radius: 30px;
  padding: 12px;
  background: #151b19;
  box-shadow: var(--shadow);
}

.phone-speaker {
  width: 64px;
  height: 5px;
  margin: 4px auto 12px;
  border-radius: 999px;
  background: #39433f;
}

.phone-screen {
  position: relative;
  display: grid;
  align-content: end;
  min-height: 314px;
  overflow: hidden;
  border-radius: 22px;
  padding: 22px;
  background:
    radial-gradient(circle at 18% 20%, rgba(214, 95, 66, 0.45), transparent 34%),
    linear-gradient(145deg, #0f766e, #243a50 52%, #1b2320);
  color: #fff;
}

.screen-time {
  font-size: 13px;
  font-weight: 700;
  opacity: 0.85;
}

.screen-model {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.screen-meta {
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.signal-row {
  display: flex;
  gap: 6px;
  margin-top: 26px;
}

.signal-row span {
  display: block;
  width: 32px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.summary-item {
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(23, 33, 29, 0.06);
}

.summary-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-item strong {
  display: block;
  margin-top: 10px;
  font-size: 16px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.summary-item.accent-teal {
  border-top: 4px solid var(--teal);
}

.summary-item.accent-coral {
  border-top: 4px solid var(--coral);
}

.summary-item.accent-amber {
  border-top: 4px solid var(--amber);
}

.summary-item.accent-blue {
  border-top: 4px solid var(--blue);
}

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

.output-section {
  overflow: hidden;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-strong);
}

.section-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field-list {
  display: grid;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(116px, 170px) minmax(0, 1fr);
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid #edf1ef;
}

.field-row:last-child {
  border-bottom: 0;
}

.field-key {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.field-value {
  color: var(--ink);
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.json-panel {
  overflow: hidden;
}

#jsonOutput {
  max-height: 430px;
  min-height: 240px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  background: #111817;
  color: #d9f2e9;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  min-width: 180px;
  max-width: calc(100% - 32px);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  border-radius: var(--radius);
  padding: 10px 14px;
  background: #17211d;
  color: #fff;
  box-shadow: var(--shadow);
  text-align: center;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1100px) {
  .workspace,
  .preview-band {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    position: static;
  }

  .phone-preview {
    width: min(280px, 100%);
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1480px);
    padding-top: 14px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    justify-content: stretch;
  }

  .button {
    flex: 1 1 130px;
  }

  .summary,
  .output-grid {
    grid-template-columns: 1fr;
  }

  .field-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
