:root {
  --canvas: #f3f4f0;
  --surface: #ffffff;
  --surface-soft: #e9ece6;
  --ink: #171a17;
  --muted: #6c736b;
  --line: #d5d9d2;
  --line-strong: #a9afa6;
  --acid: #c8ff52;
  --acid-dark: #a7df31;
  --blue: #2855e7;
  --error: #d9473d;
  --shadow: rgba(23, 26, 23, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--canvas);
  color: var(--ink);
  font-family: "Onest", sans-serif;
  letter-spacing: 0;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 650;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  width: 22px;
  height: 22px;
  border: 2px solid var(--ink);
  border-radius: 4px;
  background: var(--surface);
}

.brand-mark::after {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--surface);
  border-radius: 2px;
  background: var(--acid);
  content: "";
}

.service-state {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-family: "Azeret Mono", monospace;
  font-size: 10px;
  text-transform: uppercase;
}

.state-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2ba66a;
  box-shadow: 0 0 0 4px rgba(43, 166, 106, 0.12);
}

main {
  padding: clamp(38px, 7vw, 86px) 24px 72px;
}

.capture-workspace {
  width: min(1180px, 100%);
  margin: 0 auto;
  animation: workspace-in 420ms ease-out both;
}

@keyframes workspace-in {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.workspace-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 24px;
  margin-bottom: 34px;
}

.eyebrow,
.spec {
  margin: 0 0 10px;
  color: var(--blue);
  font-family: "Azeret Mono", monospace;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(38px, 5vw, 58px);
  font-weight: 600;
  line-height: 1;
}

.spec {
  margin: 0 0 5px;
  color: var(--muted);
  font-weight: 500;
}

.capture-form {
  margin-bottom: 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 34px var(--shadow);
}

.capture-form label {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-family: "Azeret Mono", monospace;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.input-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  min-height: 56px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fbfcfa;
}

.protocol {
  padding-left: 17px;
  color: var(--muted);
  font-family: "Azeret Mono", monospace;
  font-size: 13px;
}

.input-row input {
  width: 100%;
  min-width: 0;
  height: 54px;
  padding: 0 14px 0 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-family: "Azeret Mono", monospace;
  font-size: 13px;
}

.input-row:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(40, 85, 231, 0.12);
}

.input-row button {
  align-self: stretch;
  min-width: 132px;
  border: 0;
  border-left: 1px solid var(--ink);
  background: var(--acid);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.input-row button:hover {
  background: var(--acid-dark);
}

.input-row button:disabled {
  cursor: progress;
  opacity: 0.6;
}

.form-message {
  min-height: 18px;
  margin: 7px 0 -5px;
  color: var(--error);
  font-family: "Azeret Mono", monospace;
  font-size: 10px;
}

.preview-shell {
  overflow: hidden;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  box-shadow: 0 18px 42px rgba(23, 26, 23, 0.14);
}

.preview-toolbar {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 46px;
  padding: 0 16px;
  background: var(--ink);
  color: #f7f8f5;
  font-family: "Azeret Mono", monospace;
  font-size: 9px;
  text-transform: uppercase;
}

.preview-toolbar p {
  overflow: hidden;
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-toolbar p:last-child {
  padding-left: 18px;
  color: var(--acid);
}

.window-controls {
  display: flex;
  gap: 6px;
}

.window-controls span {
  width: 8px;
  height: 8px;
  border: 1px solid #777d75;
  border-radius: 50%;
}

.preview-stage {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 8 / 5;
  place-items: center;
  overflow: hidden;
  background: var(--surface-soft);
}

.preview-stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--surface);
}

.empty-state {
  position: relative;
  display: grid;
  width: min(360px, 48%);
  aspect-ratio: 8 / 5;
  place-items: center;
  color: var(--muted);
  font-family: "Azeret Mono", monospace;
  font-size: 10px;
  text-transform: uppercase;
}

.empty-state[hidden] {
  display: none;
}

.focus-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--blue);
  border-style: solid;
}

.corner-one { top: 0; left: 0; border-width: 2px 0 0 2px; }
.corner-two { top: 0; right: 0; border-width: 2px 2px 0 0; }
.corner-three { right: 0; bottom: 0; border-width: 0 2px 2px 0; }
.corner-four { bottom: 0; left: 0; border-width: 0 0 2px 2px; }

.loader {
  display: grid;
  grid-template-columns: repeat(4, 8px);
  gap: 5px;
  align-items: center;
}

.loader[hidden] {
  display: none;
}

.loader span {
  width: 8px;
  height: 38px;
  border-radius: 2px;
  background: var(--ink);
  animation: scan 1s ease-in-out infinite alternate;
}

.loader span:nth-child(2) { animation-delay: 0.12s; }
.loader span:nth-child(3) { animation-delay: 0.24s; }
.loader span:nth-child(4) { animation-delay: 0.36s; }

.loader p {
  grid-column: 1 / -1;
  margin: 5px 0 0;
  color: var(--muted);
  font-family: "Azeret Mono", monospace;
  font-size: 9px;
  text-align: center;
  text-transform: uppercase;
}

@keyframes scan {
  from { transform: scaleY(0.35); background: var(--blue); }
  to { transform: scaleY(1); background: var(--acid-dark); }
}

.result-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 14px;
  padding: 15px 2px 0;
}

.result-bar[hidden] {
  display: none;
}

.result-bar dl {
  display: flex;
  gap: clamp(26px, 6vw, 72px);
  margin: 0;
}

.result-bar dl div {
  min-width: 72px;
}

.result-bar dt,
.result-bar dd {
  margin: 0;
  font-family: "Azeret Mono", monospace;
  font-size: 9px;
  text-transform: uppercase;
}

.result-bar dt {
  margin-bottom: 5px;
  color: var(--muted);
}

.result-actions {
  display: flex;
  gap: 8px;
}

.secondary,
.refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
}

.secondary:hover,
.refresh:hover {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--surface);
}

.refresh {
  width: 38px;
  padding: 0;
  font-size: 18px;
}

.embed-panel {
  margin-top: clamp(46px, 7vw, 82px);
  padding-top: clamp(28px, 4vw, 44px);
  border-top: 1px solid var(--line-strong);
}

.embed-panel[hidden] {
  display: none;
}

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

.embed-heading .eyebrow {
  margin-bottom: 6px;
}

.embed-heading h2 {
  margin: 0;
  font-size: clamp(26px, 4vw, 38px);
  font-weight: 600;
  line-height: 1.05;
}

.embed-heading > p {
  max-width: 300px;
  margin: 0;
  color: var(--muted);
  font-family: "Azeret Mono", monospace;
  font-size: 9px;
  text-align: right;
  text-transform: uppercase;
}

.format-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
  background: var(--surface-soft);
}

.format-tabs button {
  min-width: 0;
  min-height: 44px;
  border: 0;
  border-right: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-family: "Azeret Mono", monospace;
  font-size: 10px;
}

.format-tabs button:last-child {
  border-right: 0;
}

.format-tabs button[aria-selected="true"] {
  background: var(--blue);
  color: #fff;
}

.format-tabs button:focus-visible {
  position: relative;
  z-index: 1;
  outline: 3px solid var(--acid-dark);
  outline-offset: -3px;
}

.code-output {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 98px;
  min-height: 78px;
  overflow: hidden;
  border: 1px solid var(--ink);
  border-radius: 0 0 7px 7px;
  background: var(--ink);
}

.code-output pre {
  display: flex;
  align-items: center;
  min-width: 0;
  margin: 0;
  padding: 17px 19px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.code-output code {
  color: #f0f2ec;
  font-family: "Azeret Mono", monospace;
  font-size: 11px;
  white-space: pre;
}

.code-output button {
  border: 0;
  border-left: 1px solid #4f554e;
  background: var(--acid);
  color: var(--ink);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.code-output button:hover {
  background: var(--acid-dark);
}

footer {
  display: flex;
  justify-content: space-between;
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 0 0 34px;
  color: var(--muted);
  font-family: "Azeret Mono", monospace;
  font-size: 8px;
}

footer p {
  margin: 0;
}

@media (max-width: 720px) {
  .topbar {
    min-height: 62px;
    padding: 0 18px;
  }

  .service-state span:last-child,
  .spec {
    display: none;
  }

  .brand {
    gap: 9px;
    font-size: 12px;
  }

  .brand-mark {
    width: 20px;
    height: 20px;
  }

  main {
    padding: 30px 16px 48px;
  }

  .workspace-heading {
    display: block;
    margin-bottom: 26px;
  }

  h1 {
    font-size: 40px;
    line-height: 1.02;
  }

  .capture-form {
    padding: 12px;
  }

  .input-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .input-row button {
    grid-column: 1 / -1;
    min-height: 48px;
    border-top: 1px solid var(--ink);
    border-left: 0;
  }

  .preview-toolbar {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .preview-toolbar p:last-child {
    display: none;
  }

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

  .result-bar dl {
    justify-content: space-between;
    gap: 8px;
  }

  .result-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 38px;
  }

  .embed-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .embed-heading > p {
    max-width: none;
    text-align: left;
  }

  .format-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .format-tabs button:nth-child(2) {
    border-right: 0;
  }

  .format-tabs button:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line-strong);
  }

  .code-output {
    grid-template-columns: minmax(0, 1fr) 72px;
  }

  .code-output pre {
    padding: 14px;
  }

  footer {
    width: calc(100% - 32px);
    font-size: 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
