:root {
  color-scheme: light;
  --ink: #181a1f;
  --muted: #646b78;
  --line: #d9dde5;
  --paper: #f7f5ef;
  --panel: #ffffff;
  --accent: #006c67;
  --accent-ink: #ffffff;
  --warn: #a95000;
  --shadow: 0 20px 70px rgba(24, 26, 31, 0.12);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  overflow-x: hidden;
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(24, 26, 31, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(24, 26, 31, 0.045) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
}

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

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto;
}

.workspace {
  display: flex;
  min-height: calc(100vh - 48px);
  flex-direction: column;
  gap: 16px;
}

.topbar {
  display: flex;
  min-width: 0;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 0 6px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  text-transform: uppercase;
}

h1 {
  max-width: 100%;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(36px, 6vw, 74px);
  font-weight: 500;
  letter-spacing: 0;
  line-height: 0.92;
}

.top-actions {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.language {
  display: flex;
  width: 132px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.lang {
  flex: 1 1 0;
  min-height: 32px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.lang:last-child {
  border-right: 0;
}

.lang.is-active {
  background: var(--accent);
  color: #fff;
}

.tabs {
  display: flex;
  width: 216px;
  max-width: 100%;
  min-width: 216px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.tab {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.tab:last-child {
  border-right: 0;
}

.tab.is-active {
  background: var(--ink);
  color: #fff;
}

.grid {
  display: grid;
  min-width: 0;
  flex: 1;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
}

.dropzone {
  display: grid;
  min-height: 156px;
  place-items: center;
  border: 1px dashed #aeb5bf;
  background: #fbfaf6;
  cursor: pointer;
  text-align: center;
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.drop-icon {
  display: grid;
  width: 44px;
  height: 44px;
  margin-bottom: 8px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 30px;
  line-height: 1;
}

.drop-title {
  display: block;
  font-size: 20px;
}

.drop-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

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

label {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.status {
  min-height: 42px;
  border-left: 3px solid var(--accent);
  background: #eef6f4;
  color: #164a47;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
}

.status.is-error {
  border-left-color: var(--warn);
  background: #fff1e4;
  color: #6f3600;
}

.primary,
.download {
  display: grid;
  min-height: 48px;
  place-items: center;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--accent-ink);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.primary:disabled {
  cursor: wait;
  opacity: 0.58;
}

.download {
  background: var(--accent);
  border-color: var(--accent);
}

.download.is-disabled,
.download.is-downloading {
  border-color: #aeb5bf;
  background: #aeb5bf;
  color: #f8f8f8;
  cursor: default;
}

.download.is-downloading {
  pointer-events: auto;
}

.is-hidden {
  display: none;
}

.facts {
  display: grid;
  gap: 0;
  margin: auto 0 0;
  border-top: 1px solid var(--line);
}

.facts div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.facts dt {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.facts dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.preview {
  min-height: 520px;
  padding: 16px;
}

.preview-frame {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 488px;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(45deg, #e8e8e8 25%, transparent 25%),
    linear-gradient(-45deg, #e8e8e8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e8e8e8 75%),
    linear-gradient(-45deg, transparent 75%, #e8e8e8 75%),
    #f8f8f8;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  background: #fff;
}

.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  text-transform: uppercase;
}

footer {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
}

body.verify-mode .embed-only {
  display: none;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  width: min(380px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
  padding: 14px 44px 14px 14px;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.toast.is-error {
  border-left-color: var(--warn);
}

.toast-title {
  margin-bottom: 6px;
  font-weight: 700;
}

.toast-body {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.toast-close {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}

@media (max-width: 820px) {
  .shell {
    width: calc(100vw - 20px);
    max-width: 720px;
    margin: 10px auto;
  }

  .workspace {
    min-height: calc(100vh - 20px);
  }

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

  .topbar > div {
    min-width: 0;
  }

  .top-actions {
    justify-items: stretch;
  }

  .language {
    width: 100%;
  }

  h1 {
    font-size: 30px;
    line-height: 1;
  }

  .tabs {
    min-width: 0;
    width: 100%;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .preview {
    min-height: 360px;
  }

  .preview-frame {
    min-height: 328px;
  }

  .toast {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
  }
}

@media (max-width: 520px) {
  .shell {
    max-width: 370px;
    margin-right: 10px;
    margin-left: 10px;
  }
}
