:root {
  color-scheme: dark;
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  line-height: 1.6;
  --night: #0b1020;
  --surface: #131b33;
  --field: #0e162a;
  --edge: #384463;
  --text: #eef2ff;
  --muted: #b6c0d8;
  --gold: #f5d06f;
  --cyan: #91deee;
}

*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(ellipse at 76% 0%, #24284a 0%, transparent 34rem),
    radial-gradient(ellipse at 9% 24%, #112840 0%, transparent 30rem),
    var(--night);
}

a {
  color: var(--cyan);
  text-underline-offset: 0.22em;
}

a:hover {
  color: var(--gold);
}

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

h1, h2, h3, p, dl, ol, ul {
  margin: 0;
}

h1, h2, h3 {
  line-height: 1.3;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 2.65rem);
}

h2 {
  font-size: 1.2rem;
}

h3 {
  font-size: 1rem;
}

.shell {
  width: min(72rem, 100% - 2 * clamp(1rem, 4vw, 2.5rem));
  margin-inline: auto;
}

.site-header {
  background-color: #0b1020d9;
  border-bottom: 1px solid var(--edge);
}

.header-content, .header-links, .actions, .portal-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem 1rem;
}

.header-content {
  justify-content: space-between;
  padding-block: 0.9rem;
}

.header-links {
  font-size: 0.9rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 700;
  text-decoration: none;
}

.brand-star {
  color: var(--gold);
  text-shadow: 0 0 1rem #f5d06f80;
}

.status-badge {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  border: 1px solid var(--edge);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  color: var(--muted);
  background: var(--field);
}

.status-badge::before {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.status-badge[data-state="online"] {
  color: #a1efd1;
}

.status-badge[data-state="error"] {
  color: #ffb9c8;
}

.site-main {
  padding-block: 1.6rem 4rem;
}

.portal-nav {
  gap: 0.35rem;
  border-bottom: 1px solid var(--edge);
  padding-bottom: 0.5rem;
}

.portal-nav a {
  border: 1px solid transparent;
  border-radius: 0.6rem;
  padding: 0.5rem 0.8rem;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}

.portal-nav a:hover {
  color: var(--text);
  background: var(--surface);
}

.portal-nav a[aria-current="page"] {
  border-color: #716044;
  color: var(--gold);
  background: #292641;
}

.section-heading {
  margin-block: 1.55rem 1.25rem;
}

.feedback p:not(:empty), .notice, .gallery-status:not(:empty) {
  border: 1px solid var(--edge);
  border-radius: 0.65rem;
  padding: 0.75rem 1rem;
  background: var(--field);
}

.feedback p:not(:empty), noscript .notice {
  margin-top: 1rem;
}

.feedback [data-kind="info"], .notice {
  border-color: #355a6d;
  color: #c6ecfa;
  background: #142b40;
}

.feedback [data-kind="success"] {
  border-color: #3e7369;
  color: #bef6df;
  background: #163332;
}

.feedback [data-kind="error"] {
  border-color: #894a63;
  color: #ffd2dc;
  background: #381f32;
}

.alpha-notice {
  margin-bottom: 1.15rem;
  border-color: #716044;
  color: var(--gold);
  background: #2a2539;
}

.test-banner {
  margin-bottom: 1rem;
  border-color: #716044;
  border-inline-start: 0.25rem solid var(--gold);
  color: var(--text);
  background: #2a2539;
}

.test-banner h2 {
  margin-bottom: 0.3rem;
  color: var(--gold);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}

.card-grid:not([hidden]) + .card-grid {
  margin-top: 1rem;
}

.card {
  display: grid;
  gap: 0.95rem;
  min-width: 0;
  border: 1px solid var(--edge);
  border-radius: 0.85rem;
  padding: clamp(1rem, 2.5vw, 1.5rem);
  background: var(--surface);
  overflow-wrap: anywhere;
}

.gallery-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}

.gallery-toolbar > div {
  flex: 1 1 18rem;
  max-width: 32rem;
}

.gallery-status:not(:empty) {
  margin-block: 1rem;
  color: var(--muted);
}

.gallery-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  align-items: stretch;
}

.blueprint-card {
  align-content: start;
  border-top-color: #6a6387;
}

.blueprint-card h2, .card h3 {
  color: var(--gold);
}

form, .form-field {
  display: grid;
  gap: 0.4rem;
}

.divided {
  border-top: 1px solid var(--edge);
  padding-top: 0.95rem;
}

label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
}

input, button {
  min-height: 2.65rem;
  border: 1px solid var(--edge);
  border-radius: 0.5rem;
  color: var(--text);
  font: inherit;
}

input {
  width: 100%;
  min-width: 0;
  padding: 0.45rem 0.65rem;
  background: var(--field);
}

input::placeholder {
  color: var(--muted);
}

input.linked-token {
  border-color: var(--gold);
}

form input {
  margin-bottom: 0.35rem;
}

button {
  padding: 0.4rem 0.85rem;
  background: #223052;
  cursor: pointer;
  font-weight: 700;
}

form button {
  justify-self: start;
}

button:hover:not(:disabled) {
  border-color: var(--cyan);
  background: #2b4064;
}

button.primary {
  border-color: var(--gold);
  color: var(--night);
  background: var(--gold);
}

button.primary:hover:not(:disabled) {
  border-color: #ffe3a2;
  background: #ffe3a2;
}

button:disabled {
  opacity: 0.63;
  cursor: wait;
}

.facts {
  display: grid;
  grid-template-columns: minmax(5.5rem, max-content) minmax(0, 1fr);
  gap: 0.35rem 0.8rem;
}

.facts dt, .muted, .record-detail {
  color: var(--muted);
}

.facts dd {
  margin: 0;
}

.record-list {
  padding: 0;
  list-style: none;
}

.record-list li {
  display: grid;
  gap: 0.15rem 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr));
  border-bottom: 1px solid var(--edge);
  padding-block: 0.48rem;
}

.record-list li:last-child {
  border-bottom: 0;
}

.list-heading {
  margin-top: 0.9rem;
  margin-bottom: 0.3rem;
}

.steps {
  padding-inline-start: 1.35rem;
}

.steps li + li {
  margin-top: 0.5rem;
}

.auth-center {
  display: grid;
  justify-items: center;
}

.auth-card {
  width: min(28rem, 100%);
}

.auth-card form button.primary,
.auth-dialog form button.primary {
  width: 100%;
  justify-self: stretch;
  margin-top: 0.35rem;
}

.auth-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  border-top: 1px solid var(--edge);
  padding-top: 0.95rem;
}

.link-btn {
  min-height: auto;
  border: 0;
  padding: 0.25rem 0.4rem;
  background: transparent;
  color: var(--cyan);
  font-size: 0.9rem;
  font-weight: 600;
}

.link-btn:hover:not(:disabled) {
  background: transparent;
  color: var(--gold);
  text-decoration: underline;
}

.auth-links .link-btn {
  grid-column: 1 / -1;
  justify-self: center;
}

.auth-dialog {
  width: min(29rem, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 1px solid var(--edge);
  border-radius: 0.95rem;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1.4rem 3.5rem #00000099;
}

.auth-dialog::backdrop {
  background: #060913cc;
  backdrop-filter: blur(4px);
}

.dialog-body, .dialog-step {
  display: grid;
  gap: 0.95rem;
}

.dialog-body {
  padding: clamp(1rem, 2.5vw, 1.5rem);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.dialog-close {
  min-height: 2.2rem;
  min-width: 2.2rem;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
}

.dialog-footer {
  display: flex;
  justify-content: center;
  border-top: 1px solid var(--edge);
  padding-top: 0.75rem;
}

.dialog-feedback:not(:empty) {
  border: 1px solid var(--edge);
  border-radius: 0.65rem;
  padding: 0.7rem 0.9rem;
  font-size: 0.92rem;
}

.dialog-feedback[data-kind="info"] {
  border-color: #355a6d;
  color: #c6ecfa;
  background: #142b40;
}

.dialog-feedback[data-kind="success"] {
  border-color: #3e7369;
  color: #bef6df;
  background: #163332;
}

.dialog-feedback[data-kind="error"] {
  border-color: #894a63;
  color: #ffd2dc;
  background: #381f32;
}

@media (max-width: 43rem) {
  .card-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 24rem) {
  .header-content, .header-links {
    gap: 0.5rem 0.75rem;
  }

  .portal-nav a {
    padding-inline: 0.5rem;
  }
}
