:root {
  --bg: #f1eee7;
  --paper: rgba(255, 252, 245, 0.88);
  --ink: #18202a;
  --muted: #607080;
  --line: rgba(24, 32, 42, 0.12);
  --accent: #e45f2b;
  --accent-2: #0d9d87;
  --plate: #0b0f14;
  --plate-edge: #2b313a;
  --screen: #0f1715;
  --screen-glow: #7af7c4;
  --button: #ffffff;
  --shadow: 0 18px 50px rgba(42, 39, 34, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(228, 95, 43, 0.14), transparent 30%),
    radial-gradient(circle at top right, rgba(13, 157, 135, 0.12), transparent 24%),
    linear-gradient(180deg, #f7f3ec 0%, #efe8dd 100%);
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px;
}

.hero,
.status-bar,
.layout {
  position: relative;
  z-index: 1;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

h1,
h2 {
  margin: 0;
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(2.4rem, 5vw, 4.8rem);
  line-height: 0.96;
}

h2 {
  font-size: 1.25rem;
}

.lede {
  max-width: 680px;
  margin: 12px 0 0;
  color: var(--muted);
}

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

.button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.85rem 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease, border-color 120ms ease;
}

.button:hover:enabled {
  transform: translateY(-1px);
}

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

.button.primary {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 10px 20px rgba(24, 32, 42, 0.16);
}

.button.secondary {
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  border-color: var(--line);
}

.button.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 22px;
}

.error-banner {
  margin-bottom: 22px;
  padding: 0.95rem 1.1rem;
  border-radius: 18px;
  background: rgba(145, 33, 33, 0.09);
  border: 1px solid rgba(145, 33, 33, 0.18);
  color: #7d1f1f;
  font-weight: 600;
}

.update-banner {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 244, 222, 0.9);
  border: 1px solid rgba(228, 95, 43, 0.24);
  box-shadow: 0 14px 34px rgba(88, 63, 26, 0.1);
}

.update-banner p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
}

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

.update-actions a {
  text-decoration: none;
}

.status-pill {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 0.65rem 0.95rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 8px 22px rgba(38, 31, 24, 0.06);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #b5b9bf;
  box-shadow: 0 0 0 6px rgba(181, 185, 191, 0.2);
}

.dot.live {
  background: var(--accent-2);
  box-shadow: 0 0 0 6px rgba(13, 157, 135, 0.16);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 420px);
  gap: 22px;
  align-items: start;
}

.left-stack,
.stack {
  display: grid;
  gap: 22px;
}

.left-stack .panel:last-child .editor-form {
  gap: 18px;
}

.left-stack .picker-shell {
  grid-template-columns: minmax(180px, 220px) minmax(180px, 220px) minmax(0, 1fr);
  align-items: start;
}

.left-stack .picker-block {
  grid-column: 1 / -1;
}

.left-stack .picker-grid {
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
}

.left-stack .picker-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
}

.panel {
  background: var(--paper);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

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

.plate-panel {
  overflow: hidden;
}

.layer-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.layer-tab {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.6rem 0.85rem;
  font-weight: 700;
}

.layer-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.plate-wrap {
  border-radius: 20px;
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 255, 255, 0.12), transparent 20%),
    linear-gradient(160deg, #1e2228 0%, #0a0e13 100%);
  padding: 18px;
  min-height: 500px;
}

.plate {
  position: relative;
  aspect-ratio: 120.05 / 67.8;
  width: 100%;
}

.plate-svg,
.display-preview,
.plate-control {
  position: absolute;
}

.plate-svg {
  inset: 0;
  width: 100%;
  height: 100%;
}

.plate-body {
  fill: url(#bodyGlow);
  stroke: rgba(255, 255, 255, 0.09);
  stroke-width: 0.4;
}

.display-cutout {
  fill: url(#screenGlow);
  stroke: rgba(122, 247, 196, 0.2);
  stroke-width: 0.35;
}

.display-preview {
  left: 69.42%;
  top: 14.63%;
  width: 22.24%;
  height: 43.36%;
  border-radius: 14px;
  overflow: hidden;
  background:
    radial-gradient(circle at top, rgba(122, 247, 196, 0.1), transparent 32%),
    linear-gradient(180deg, #13201c 0%, #08100d 100%);
  box-shadow: inset 0 0 0 1px rgba(122, 247, 196, 0.14);
}

.display-noise {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.02)),
    linear-gradient(transparent 50%, rgba(0, 0, 0, 0.14) 50%);
  background-size: 100% 2px, 100% 4px;
  opacity: 0.25;
}

.display-content {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100%;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px;
  color: var(--screen-glow);
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
}

.display-layer {
  font-size: clamp(1.4rem, 2.6vw, 2.6rem);
  font-weight: 700;
}

.display-name,
.display-hint {
  opacity: 0.9;
  font-size: 0.85rem;
}

.plate-control {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #eef4f8;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.06), transparent 24%),
    linear-gradient(180deg, #252c34 0%, #11161c 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 14px 20px rgba(0, 0, 0, 0.2);
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.plate-control:hover {
  transform: translateY(-2px);
}

.plate-control.key {
  border-radius: 12px;
}

.plate-control.encoder {
  border-radius: 999px;
  align-items: center;
  justify-content: center;
  text-align: center;
  background:
    radial-gradient(circle at 40% 35%, rgba(255, 255, 255, 0.16), transparent 16%),
    radial-gradient(circle at center, #313840 0%, #151a21 76%);
}

.plate-control.selected {
  border-color: rgba(228, 95, 43, 0.95);
  box-shadow:
    inset 0 0 0 1px rgba(228, 95, 43, 0.8),
    0 0 0 5px rgba(228, 95, 43, 0.18),
    0 18px 28px rgba(0, 0, 0, 0.26);
}

.plate-control-id {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(238, 244, 248, 0.6);
}

.plate-control-label {
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-weight: 700;
  line-height: 1.05;
  font-size: clamp(0.82rem, 1.3vw, 1rem);
  overflow-wrap: anywhere;
}

.editor-form,
.field-group {
  display: grid;
  gap: 14px;
}

.picker-shell {
  display: grid;
  gap: 16px;
}

.picker-summary {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.picker-summary-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.picker-block {
  display: grid;
  gap: 14px;
}

.picker-tabs,
.function-modes {
  align-items: center;
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
  gap: 10px;
}

.picker-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
}

.picker-chip {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  min-height: 52px;
  padding: 0.8rem 0.7rem;
  font-weight: 700;
  line-height: 1.05;
  text-align: center;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.picker-chip:hover {
  transform: translateY(-1px);
}

.picker-chip.active {
  background: rgba(228, 95, 43, 0.12);
  border-color: rgba(228, 95, 43, 0.55);
  box-shadow: 0 0 0 4px rgba(228, 95, 43, 0.12);
}

.picker-chip.muted {
  color: var(--muted);
}

.picker-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.picker-note code {
  background: rgba(24, 32, 42, 0.06);
  border-radius: 8px;
  padding: 0.12rem 0.35rem;
}

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

.field {
  display: grid;
  gap: 8px;
}

.field label {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--muted);
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.76);
  padding: 0.85rem 0.95rem;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

input[type="color"] {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.76);
  padding: 0.35rem;
}

input[type="range"] {
  width: 100%;
}

.range-readout {
  font-size: 0.84rem;
  color: var(--muted);
}

.mods-grid,
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mod-chip,
.segment {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.55rem 0.8rem;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.mod-chip.active,
.segment.active {
  background: rgba(13, 157, 135, 0.12);
  border-color: rgba(13, 157, 135, 0.42);
  color: #076b5c;
}

.actions-row {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
}

.hidden {
  display: none;
}

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

  .left-stack,
  .stack {
    grid-template-columns: 1fr;
  }

  .left-stack .picker-shell {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 18px;
  }

  .hero,
  .panel-head,
  .field-row {
    grid-template-columns: 1fr;
    display: grid;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .plate-wrap {
    min-height: 320px;
  }
}
