:root {
  color-scheme: light;
  --bg: #eef2f5;
  --panel: #ffffff;
  --ink: #182230;
  --muted: #67747f;
  --line: #dfe5ea;
  --accent: #0f766e;
  --accent-hover: #0d635c;
  --accent-soft: #ebf6f4;
  --danger: #b42318;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgb(16 34 48 / 8%);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(650px 360px at 12% 0%, rgb(15 118 110 / 10%), transparent 70%),
    var(--bg);
  color: var(--ink);
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  display: grid;
  justify-content: center;
  align-items: start;
  padding: max(18px, env(safe-area-inset-top)) 14px max(28px, env(safe-area-inset-bottom));
}

.shell {
  width: min(540px, 100%);
  display: grid;
  gap: 12px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #334155;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 700;
  letter-spacing: .01em;
}

.brand-mark {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgb(15 118 110 / 15%);
  flex: 0 0 auto;
}

.brand span:last-child,
.repo-link span { white-space: nowrap; }

.repo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgb(255 255 255 / 72%);
  color: #475569;
  text-decoration: none;
  transition: background .18s ease, color .18s ease, border-color .18s ease;
}

.repo-link:hover {
  color: var(--accent);
  border-color: rgb(15 118 110 / 40%);
  background: white;
}

.panel {
  border: 1px solid rgb(226 232 240 / 90%);
  border-radius: var(--radius);
  background: rgb(255 255 255 / 92%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

#builder {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.field-label,
.field label {
  color: #475569;
  font-size: 12px;
  font-weight: 650;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mode {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  color: #475569;
  cursor: pointer;
  user-select: none;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}

.mode input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.mode:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.mode:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input[type="text"] {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  color: var(--ink);
  font: inherit;
  letter-spacing: .08em;
  transition: border-color .15s ease, background .15s ease;
}

input[type="text"]:focus {
  outline: 0;
  border-color: var(--accent);
  background: white;
}

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

.actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

button {
  min-height: 38px;
  padding: 8px 15px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

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

button.ghost:hover:not(:disabled) {
  color: var(--accent);
  border-color: rgb(15 118 110 / 45%);
  background: #f8fafc;
}

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

.status {
  min-height: 18px;
  padding: 0 2px;
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.status:not(:empty) {
  background: rgb(255 255 255 / 74%);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.status.error {
  color: var(--danger);
  border-color: rgb(180 35 24 / 25%);
  background: rgb(180 35 24 / 5%);
}

.result {
  padding: 14px;
}

.result-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.ok-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #059669;
  box-shadow: 0 0 0 3px rgb(5 150 105 / 14%);
}

dl {
  margin: 0;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 8px 10px;
  font-size: 13px;
}

dt { color: var(--muted); }
dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

#output-hash {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  white-space: normal;
}

#download {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 38px;
  margin-top: 12px;
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  background: #182230;
  color: white;
  text-decoration: none;
  font-weight: 650;
  transition: background .15s ease;
}

#download:hover { background: #0b1220; }

.notice {
  padding: 11px 12px;
  border: 1px solid rgb(180 35 24 / 22%);
  border-radius: var(--radius-sm);
  background: rgb(180 35 24 / 5%);
  color: var(--danger);
}

footer {
  padding: 0 4px;
  color: #64748b;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

@media (max-width: 420px) {
  body { padding-left: 10px; padding-right: 10px; }
  #builder { padding: 14px; }
  .actions { grid-template-columns: 1fr; }
  dl { grid-template-columns: 1fr; gap: 3px; }
  dt { margin-top: 6px; }
  footer { padding: 0 2px; }
}

/* On desktop, make the interface conform to the available viewport. */
@media (min-width: 768px) {
  body {
    grid-template-columns: min(880px, calc(100% - 48px));
    padding: 28px;
    align-items: start;
  }

  .shell {
    width: min(880px, 100%);
    min-height: auto;
    grid-template-rows: auto auto auto;
  }

  main {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .panel {
    display: flex;
    flex-direction: column;
  }

  #builder {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px 18px;
    align-content: start;
  }

  .field { align-self: start; }

  .actions {
    grid-column: 1 / -1;
    align-self: end;
    align-items: end;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .result { flex: 0 0 auto; }
}

@media (min-width: 1000px) {
  #builder {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
