:root {
  --bg: #0a0f15;
  --panel: #101821;
  --panel-2: #0c131b;
  --border: #213040;
  --text: #e6edf3;
  --muted: #8b9bab;
  --accent: #4cc2ff;
  --accent-strong: #1f8fcc;
  --ok: #3fb950;
  --error: #f85149;
  --warn: #d29922;
  --radius: 14px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

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

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(76, 194, 255, 0.08), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(63, 185, 80, 0.05), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

h1,
h2,
p {
  margin: 0;
}

code {
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #0a1118;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 14, 20, 0.75);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background:
    linear-gradient(135deg, var(--accent) 0%, #1f6feb 55%, #123a6b 100%);
  box-shadow: 0 0 0 1px rgba(76, 194, 255, 0.35), 0 8px 28px rgba(31, 111, 235, 0.25);
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  border-radius: 3px;
  transform: skewY(-12deg);
}

.brand h1 {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.2px;
}

.brand h1 span {
  color: var(--accent);
}

.brand p {
  color: var(--muted);
  font-size: 12px;
  margin-top: 1px;
}

.status {
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.status.ok {
  color: var(--ok);
  border-color: rgba(63, 185, 80, 0.45);
  background: rgba(63, 185, 80, 0.08);
}

.status.error {
  color: var(--error);
  border-color: rgba(248, 81, 73, 0.45);
  background: rgba(248, 81, 73, 0.08);
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 370px minmax(0, 1fr);
  gap: 18px;
  padding: 18px 24px 22px;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(18, 27, 37, 0.96), rgba(13, 20, 28, 0.96));
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.panel {
  padding: 18px;
  align-self: start;
}

.panel h2,
.preview-head h2 {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: #c8d6e4;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

label.full {
  margin-top: 12px;
}

input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:hover {
  border-color: #2b4054;
}

input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(76, 194, 255, 0.15);
}

details {
  margin-top: 14px;
  border-top: 1px dashed var(--border);
  padding-top: 10px;
}

summary {
  cursor: pointer;
  color: #b8c7d6;
  font-size: 12px;
  user-select: none;
}

summary:hover {
  color: var(--accent);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 18px;
  align-items: center;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: linear-gradient(180deg, #69d0ff, var(--accent));
  color: #04121c;
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  transition: transform 80ms ease, filter 120ms ease, border-color 120ms ease;
}

button:hover,
.button:hover {
  filter: brightness(1.06);
}

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

button:disabled {
  cursor: progress;
  filter: grayscale(0.35) brightness(0.85);
}

.button.secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
  font-weight: 550;
}

.button.secondary:hover {
  border-color: #35506a;
  background: rgba(76, 194, 255, 0.05);
}

.note {
  margin-top: 16px;
  padding: 11px 12px;
  border-left: 3px solid var(--warn);
  border-radius: 8px;
  background: rgba(210, 153, 34, 0.07);
  color: #b9c6d3;
  font-size: 12.5px;
}

.error {
  margin-top: 12px;
  padding: 11px 12px;
  border: 1px solid rgba(248, 81, 73, 0.4);
  border-radius: 8px;
  background: rgba(248, 81, 73, 0.08);
  color: #ffb4ae;
  font-size: 12.5px;
  white-space: pre-wrap;
  word-break: break-word;
}

.preview-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 18px;
}

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

.preview-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stats span {
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(10, 16, 23, 0.6);
  color: #b9c6d3;
  font-size: 11.5px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.preview {
  flex: 1;
  min-height: 440px;
  display: grid;
  place-items: center;
  padding: 18px;
  border: 1px solid #2c3c4e;
  border-radius: 11px;
  background-color: #ffffff;
  background-image:
    linear-gradient(rgba(20, 40, 60, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 40, 60, 0.045) 1px, transparent 1px);
  background-size: 10mm 10mm;
  overflow: auto;
}

.preview img {
  display: block;
  max-width: 100%;
  max-height: 68vh;
  width: auto;
  height: auto;
}

.legend {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 11px;
  color: var(--muted);
  font-size: 12px;
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 2px;
  vertical-align: -1px;
}

.swatch.cut {
  background: #000;
}

.swatch.notes {
  background: #cc0000;
}

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

.footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11.5px;
}

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

  .preview {
    min-height: 320px;
  }

  .topbar {
    padding: 14px 16px;
  }
}

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

  .stats {
    justify-content: flex-start;
  }

  .preview-head {
    flex-direction: column;
  }
}
