:root {
  --bg: #eceff3;
  --ink: #1a2332;
  --muted: #64748b;
  --accent: #0f9a97;
  --accent-dark: #0b7b79;
  --line: #d5dbe3;
  --paper: #ffffff;
  --ok: #0f766e;
  --danger: #b91c1c;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: 0.75rem 1rem 1.15rem;
}

main {
  width: min(100%, 1100px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

h1 {
  margin: 0 0 0.45rem;
  font-size: 1.12rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  color: #0f172a;
}

.stage {
  width: 100%;
  display: flex;
  justify-content: center;
  overflow: visible;
}

.cassette {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 760px);
  margin: 0 auto;
  filter: drop-shadow(0 18px 28px rgba(15, 23, 42, 0.16));
}

.disc {
  position: relative;
  flex: 0 0 auto;
  width: min(90vw, 760px);
  aspect-ratio: 1;
  min-width: 340px;
}

.disc-shell {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.disc-art {
  width: 100%;
  height: 100%;
  display: block;
}

.udi-label {
  position: absolute;
  /* Stay inside the circular face (r ≈ 82/100 of the disc). */
  left: 18%;
  right: 18%;
  top: 28%;
  bottom: 28%;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 0.85rem 0.9rem;
  box-shadow: none;
}


.udi-matrix {
  flex: 0 0 auto;
  width: clamp(260px, 50%, 300px);
  max-height: 100%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  background: transparent;
  padding: 0.35rem;
}

.udi-matrix canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  display: block;
}

.udi-hri {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.45rem;
  padding-top: 2px;
}

.udi-hri p {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(0.62rem, 1.35vw, 0.84rem);
  line-height: 1.25;
  color: #111827;
  letter-spacing: -0.02em;
  white-space: nowrap;
}



.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.btn {
  appearance: none;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.7rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 650;
  cursor: pointer;
  min-width: 8.5rem;
  transition: background 0.15s, border-color 0.15s, transform 0.05s, box-shadow 0.15s;
}

.btn:hover { background: #f8fafc; border-color: #94a3b8; }
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 16px rgba(15, 154, 151, 0.28);
}

.btn.primary:hover { background: var(--accent-dark); }

.btn.ghost { background: transparent; }

.btn[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.customize {
  width: min(100%, 560px);
  margin: 1rem auto 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem 1.05rem 1.15rem;
}

.ctrl {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.ctrl-label {
  display: grid;
  gap: 0.12rem;
  font-weight: 650;
  font-size: 0.9rem;
}

.ctrl-label small {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.76rem;
}

.ai {
  color: var(--accent-dark);
  font-family: var(--mono);
  font-size: 0.85em;
}

input[type="text"],
input[type="date"] {
  width: 100%;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: var(--ink);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font-size: 1rem;
  font-family: var(--mono);
}

input:focus {
  outline: 2px solid rgba(15, 154, 151, 0.35);
  border-color: var(--accent);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

.guidelines {
  margin: -0.1rem 0 0.95rem;
  padding: 0.65rem 0.75rem;
  background: #f0fbfa;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  color: #334155;
  font-size: 0.82rem;
  line-height: 1.45;
}

.customize-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}

.customize-actions .btn {
  min-width: 0;
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
}

.field-readout .label {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
}

.field-readout code {
  display: block;
  font-family: var(--mono);
  font-size: 0.78rem;
  background: #f1f5f9;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  word-break: break-all;
  color: #0f172a;
}

.status {
  min-height: 1.2rem;
  margin: 0.7rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }

footer {
  margin-top: 1.15rem;
  text-align: center;
  color: var(--muted);
}

.disclaimer {
  margin: 0;
  max-width: 40rem;
  margin-inline: auto;
  font-size: 0.7rem;
  line-height: 1.5;
  font-weight: 400;
  color: var(--muted);
}

.repo {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
}

footer a { color: var(--accent-dark); }

.tracking-note {
  margin: 0 auto 0.6rem;
  max-width: 40rem;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--muted);
  font-weight: 600;
}

/* Phones: zoom into the cassette face so a 280px+ matrix fits on screen. */
@media (max-width: 720px) {
  body { padding: 0.75rem 0 1.25rem; overflow-x: hidden; }

  h1 { padding-inline: 0.8rem; }

  .stage {
    width: 100vw;
    overflow: hidden;
  }

  .cassette {
    flex-direction: column;
    width: 100%;
    filter: drop-shadow(0 10px 18px rgba(15, 23, 42, 0.14));
  }

  .disc {
    width: min(160vw, 620px);
    min-width: 0;
  }

  .udi-label {
    left: 20%;
    right: 20%;
    top: 24%;
    bottom: 22%;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.4rem;
    padding: 0.7rem 0.55rem 0.5rem;
  }

  .udi-matrix {
    width: clamp(280px, 74vw, 360px);
  }

  .udi-hri {
    width: 100%;
    align-items: center;
    text-align: center;
    gap: 0.15rem;
  }

  .udi-hri p {
    font-size: clamp(0.68rem, 3.2vw, 0.85rem);
  }

  .actions, .customize, .status, footer {
    padding-inline: 0.8rem;
  }

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

@media (max-width: 380px) {
  .udi-matrix {
    width: clamp(260px, 80vw, 320px);
  }
}

@media (max-height: 940px) and (min-width: 721px) {
  .disc { width: min(90vw, calc(100vh - 200px), 720px); }
}
