﻿:root {
  --ink: #15201b;
  --muted: #69766f;
  --paper: #f5efe4;
  --panel: #fffaf0;
  --panel-strong: #e8ddc8;
  --copper: #bb6b2f;
  --green: #668f4d;
  --blue: #356b86;
  --gold: #c99b2d;
  --trace: rgba(90, 71, 45, 0.18);
  --shadow: 0 24px 80px rgba(44, 37, 25, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 12%, rgba(201, 155, 45, 0.24), transparent 28rem),
    radial-gradient(circle at 90% 18%, rgba(53, 107, 134, 0.2), transparent 24rem),
    linear-gradient(135deg, #efe0c4 0%, #f9f4ea 48%, #dbe6db 100%);
  font-family: Georgia, 'Times New Roman', serif;
  min-height: 100vh;
}

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

button {
  cursor: pointer;
}

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

.hero,
.board-card,
.editor-card,
.output-card {
  border: 1px solid rgba(21, 32, 27, 0.14);
  background: rgba(255, 250, 240, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  padding: 28px;
  border-radius: 28px;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: '';
  position: absolute;
  inset: auto -40px -70px 40%;
  height: 150px;
  background: repeating-linear-gradient(90deg, transparent 0 24px, var(--trace) 24px 27px);
  transform: rotate(-5deg);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--copper);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
}

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(42px, 7vw, 92px);
  line-height: 0.9;
  letter-spacing: -0.06em;
}

h2 {
  margin-bottom: 6px;
  font-size: 24px;
  letter-spacing: -0.03em;
}

.lead {
  color: var(--muted);
  max-width: 760px;
  margin-bottom: 0;
  font-size: 17px;
}

.hero-actions,
.output-head,
.board-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.hero-actions {
  position: relative;
  z-index: 1;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button,
.file-button {
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fffaf0;
  padding: 11px 16px;
  min-height: 42px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(21, 32, 27, 0.18);
}

.file-button {
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.file-button input {
  display: none;
}

button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(21, 32, 27, 0.24);
  box-shadow: none;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 20px;
  margin-top: 20px;
}

.board-card,
.editor-card,
.output-card {
  border-radius: 26px;
  padding: 22px;
}

.board-toolbar p,
.output-head p,
.selected-head p {
  color: var(--muted);
  margin-bottom: 0;
}

.board-stage {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 320px) minmax(220px, 1fr);
  gap: 16px;
  align-items: center;
  margin-top: 20px;
}

.pin-column {
  display: grid;
  gap: 8px;
}

.pin {
  display: grid;
  grid-template-columns: 104px minmax(88px, 1fr) minmax(96px, 1.2fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  border-radius: 15px;
  padding: 10px 12px;
  background: rgba(255, 250, 240, 0.94);
  color: var(--ink);
  border: 1px solid rgba(21, 32, 27, 0.12);
  box-shadow: none;
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.pin:hover,
.pin.active {
  transform: translateY(-1px);
  border-color: var(--copper);
  background: #fff5dc;
}

.pin-name {
  display: grid;
  gap: 2px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 900;
  color: var(--copper);
}

.pin-number {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.pin-role-label {
  color: var(--copper);
  font-size: 15px;
  line-height: 1.05;
}

.pin-meta {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
}

.pin-fn {
  color: var(--blue);
  font-size: 12px;
  line-height: 1.2;
}

.xiao-board {
  min-height: 520px;
  border-radius: 52px;
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.15), transparent 20%),
    linear-gradient(160deg, #28251f, #0e1210 55%, #1f2a24);
  box-shadow: inset 0 0 0 6px #2f2b22, 0 30px 60px rgba(21, 32, 27, 0.28);
  display: grid;
  grid-template-rows: 88px 1fr 70px 80px;
  align-items: center;
  justify-items: center;
  padding: 26px;
  color: #f4e8c9;
  position: relative;
}

.xiao-board::before,
.xiao-board::after {
  content: '';
  position: absolute;
  top: 40px;
  bottom: 40px;
  width: 10px;
  background: repeating-linear-gradient(180deg, var(--gold) 0 14px, transparent 14px 29px);
}

.xiao-board::before {
  left: 18px;
}

.xiao-board::after {
  right: 18px;
}

.usb {
  width: 118px;
  height: 54px;
  border-radius: 12px;
  background: linear-gradient(#d8d6cf, #aaa69c);
  color: #45413a;
  display: grid;
  place-items: center;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 800;
}

.chip {
  width: 170px;
  height: 170px;
  background: #141917;
  border: 1px solid rgba(244, 232, 201, 0.2);
  border-radius: 18px;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 24px;
  line-height: 1.15;
}

.chip span {
  color: var(--gold);
}

.antenna,
.bat {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  color: var(--gold);
}

.selected-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.pin-badge {
  width: 70px;
  height: 70px;
  border-radius: 20px;
  background: var(--copper);
  color: #fffaf0;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 900;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.pin-form {
  display: grid;
  gap: 14px;
}

label,
.prefix-control {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(21, 32, 27, 0.18);
  border-radius: 14px;
  background: #fffdf6;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--copper);
  box-shadow: 0 0 0 4px rgba(187, 107, 47, 0.14);
}

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

.output-card {
  margin-top: 20px;
}

.prefix-control {
  width: min(240px, 100%);
}

#output {
  width: 100%;
  min-height: 440px;
  margin-top: 16px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  background: #162019;
  color: #f3e8cf;
  border: 0;
  border-radius: 22px;
  padding: 18px;
}

@media (max-width: 980px) {
  .hero,
  .workspace,
  .board-stage,
  .output-head {
    grid-template-columns: 1fr;
  }

  .hero {
    display: grid;
    align-items: start;
  }

  .workspace {
    display: grid;
  }

  .board-stage {
    display: grid;
  }

  .xiao-board {
    min-height: 300px;
    grid-row: 1;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .hero,
  .board-card,
  .editor-card,
  .output-card {
    animation: rise 520ms ease both;
  }

  .editor-card {
    animation-delay: 80ms;
  }

  .output-card {
    animation-delay: 140ms;
  }

  @keyframes rise {
    from {
      opacity: 0;
      transform: translateY(16px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}


.toolbar-actions,
.output-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.status-strip > div {
  border: 1px solid rgba(21, 32, 27, 0.14);
  border-radius: 20px;
  background: rgba(255, 250, 240, 0.72);
  padding: 14px 16px;
  box-shadow: 0 14px 44px rgba(44, 37, 25, 0.1);
}

.status-strip strong {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 26px;
  color: var(--copper);
}

.status-strip span,
.output-mode,
.empty-state {
  color: var(--muted);
  font-size: 13px;
}

.pin {
  grid-template-columns: 1fr;
  padding: 8px;
  gap: 8px;
}

.pin-main {
  display: grid;
  grid-template-columns: 104px minmax(88px, 1fr) minmax(96px, 1.2fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 2px;
  min-height: 0;
  color: inherit;
  background: transparent;
  border-radius: 12px;
  box-shadow: none;
  text-align: left;
}

.role-dropzone {
  min-height: 48px;
  border: 1px dashed rgba(21, 32, 27, 0.18);
  border-radius: 14px;
  padding: 7px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: flex-start;
  background: rgba(255, 253, 246, 0.58);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.role-dropzone.drag-over,
#output.drag-over {
  border-color: var(--copper);
  background: rgba(201, 155, 45, 0.16);
  transform: translateY(-1px);
}

.role-card {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 150px;
  border-radius: 13px;
  padding: 8px 10px;
  background: #23352e;
  color: #fffaf0;
  box-shadow: 0 9px 18px rgba(21, 32, 27, 0.16);
  text-align: left;
  cursor: grab;
  overflow: visible;
}

.role-card:active {
  cursor: grabbing;
}

.role-card.active {
  outline: 3px solid rgba(187, 107, 47, 0.34);
}

.role-card.dragging {
  opacity: 0.45;
}

.role-card.kind-psel { background: #2c6072; }
.role-card.kind-adc { background: #8a6b24; }
.role-card.kind-xiao_gpios { background: #7b4b29; }
.role-card.kind-literal { background: #4d5960; }

.role-name {
  font-weight: 900;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-detail {
  position: absolute;
  left: 0;
  bottom: calc(100% + 9px);
  z-index: 20;
  display: grid;
  gap: 4px;
  width: max-content;
  max-width: min(420px, 80vw);
  border: 1px solid rgba(255, 250, 240, 0.22);
  border-radius: 14px;
  background: #121916;
  color: #fffaf0;
  padding: 10px 12px;
  box-shadow: 0 18px 42px rgba(21, 32, 27, 0.34);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.role-detail::after {
  content: '';
  position: absolute;
  left: 18px;
  top: 100%;
  border: 7px solid transparent;
  border-top-color: #121916;
}

.role-card:hover .role-detail,
.role-card:focus-visible .role-detail,
.role-card.active .role-detail {
  opacity: 1;
  transform: translateY(0);
}

.role-macro,
.role-value {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.role-macro {
  color: #f4cf77;
  font-weight: 800;
}

.role-value {
  color: #d6eadf;
}

.palette-card {
  margin-top: 20px;
  border: 1px solid rgba(21, 32, 27, 0.14);
  background: rgba(255, 250, 240, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  border-radius: 26px;
  padding: 22px;
}

.palette {
  margin-top: 14px;
  min-height: 96px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.section-head h3 {
  margin: 0;
  font-size: 18px;
}

.filter-box {
  width: min(280px, 100%);
}

.role-editor {
  margin-top: 22px;
  border-top: 1px solid rgba(21, 32, 27, 0.14);
  padding-top: 18px;
}

button.danger {
  color: #8a2d1b;
  border-color: rgba(138, 45, 27, 0.28);
}

button:disabled,
input:disabled,
select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.output-mode {
  margin: 12px 0 0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.warnings {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.warnings > div {
  border-radius: 12px;
  padding: 9px 12px;
  background: rgba(138, 45, 27, 0.12);
  color: #6c2416;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

@media (max-width: 980px) {
  .status-strip {
    grid-template-columns: 1fr;
  }

  .pin-main,
  .pin {
    grid-template-columns: 1fr;
  }

  .section-head,
  .output-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
