:root {
  --bg-0: #0b1c3d;
  --bg-1: #102a5c;
  --bg-2: #1a3f8a;
  --blue: #2f7bff;
  --blue-bright: #58a6ff;
  --blue-glow: rgba(88, 166, 255, 0.55);
  --ink: #eaf1ff;
  --ink-dim: #b6c6e3;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.14);
  --error: #ff8f8f;
  --success: #7cf3b0;
  --font: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 800px at 15% -10%, rgba(88, 166, 255, 0.25), transparent 60%),
    radial-gradient(900px 600px at 110% 10%, rgba(47, 123, 255, 0.28), transparent 55%),
    radial-gradient(700px 500px at 50% 120%, rgba(88, 166, 255, 0.18), transparent 60%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1) 60%, var(--bg-2));
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.container {
  max-width: 780px;
  margin: 0 auto;
  padding: 64px 24px 48px;
}

.hero {
  text-align: center;
  margin-bottom: 40px;
}

.ring-stack {
  position: relative;
  height: 96px;
  margin-bottom: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.ring {
  position: absolute;
  border-radius: 50%;
  border: 6px solid var(--blue-bright);
  box-shadow: 0 0 24px var(--blue-glow), inset 0 0 12px rgba(255, 255, 255, 0.15);
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.2), transparent 60%);
}

.ring--1 {
  width: 68px;
  height: 68px;
  transform: translateX(-70px) rotate(-8deg);
  opacity: 0.9;
}
.ring--2 {
  width: 80px;
  height: 80px;
  border-color: #83bcff;
  z-index: 2;
}
.ring--3 {
  width: 72px;
  height: 72px;
  transform: translateX(70px) rotate(10deg);
  opacity: 0.9;
}

h1 {
  font-size: clamp(1.9rem, 5vw, 3rem);
  line-height: 1.1;
  margin: 0 0 18px;
  letter-spacing: -0.02em;
  font-weight: 800;
  background: linear-gradient(180deg, #ffffff, #bcd7ff 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lead {
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--ink-dim);
  max-width: 620px;
  margin: 0 auto 14px;
}

.sub {
  color: var(--ink-dim);
  margin: 0;
  font-size: 0.98rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 22px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.ring-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field label {
  font-size: 0.85rem;
  color: var(--ink-dim);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.field select {
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px 38px 12px 14px;
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%23b6c6e3' d='M6 8 0 0h12z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}

.field select:focus {
  border-color: var(--blue-bright);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.25);
  background-color: rgba(255, 255, 255, 0.12);
}

.field select option {
  background: #102a5c;
  color: var(--ink);
}

.btn-calc {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  color: white;
  background: linear-gradient(180deg, var(--blue-bright), var(--blue));
  padding: 13px 22px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(47, 123, 255, 0.45), inset 0 1px 0 rgba(255,255,255,0.25);
  transition: transform 0.08s ease, box-shadow 0.15s ease, filter 0.15s;
  white-space: nowrap;
}

.btn-calc:hover {
  filter: brightness(1.05);
  box-shadow: 0 10px 28px rgba(47, 123, 255, 0.55), inset 0 1px 0 rgba(255,255,255,0.25);
}

.btn-calc:active {
  transform: translateY(1px);
}

.btn-calc:disabled {
  cursor: progress;
  filter: saturate(0.7) brightness(0.9);
}

.form-error {
  margin: 12px 4px 0;
  color: var(--error);
  font-size: 0.9rem;
}

.result {
  margin-top: 28px;
  min-height: 40px;
}

.result:empty {
  display: none;
}

/* Calculating state */
.calculating {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 26px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation: fadeIn 0.25s ease;
}

.spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.15);
  border-top-color: var(--blue-bright);
  animation: spin 0.9s linear infinite;
  box-shadow: 0 0 20px var(--blue-glow);
}

.calc-title {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.01em;
}

.calc-sub {
  color: var(--ink-dim);
  font-size: 0.95rem;
  min-height: 1.4em;
  transition: opacity 0.2s ease;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Result card */
.answer {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 28px 24px;
  text-align: center;
  animation: fadeIn 0.35s ease;
}

.answer .headline {
  font-size: clamp(1.6rem, 4.4vw, 2.4rem);
  margin: 8px 0 6px;
  font-weight: 800;
  letter-spacing: -0.01em;
  background: linear-gradient(180deg, #ffffff, #bcd7ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.answer .count {
  color: var(--ink-dim);
  font-size: 1rem;
  margin: 0 0 18px;
}

.answer .rings-visual {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0 18px;
}

.big-ring {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 6px solid var(--blue-bright);
  box-shadow: 0 0 22px var(--blue-glow), inset 0 0 10px rgba(255,255,255,0.2);
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.25), transparent 60%);
  position: relative;
}

.big-ring::after {
  content: attr(data-label);
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.72rem;
  color: var(--ink-dim);
  white-space: nowrap;
}

.answer .rings-visual.has-labels {
  margin-bottom: 34px;
}

.answer .quip {
  color: var(--ink-dim);
  line-height: 1.55;
  max-width: 520px;
  margin: 0 auto;
  font-size: 0.98rem;
}

.answer .details {
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--ink-dim);
  opacity: 0.85;
}

.site-footer {
  margin-top: 56px;
  text-align: center;
  color: var(--ink-dim);
  font-size: 0.85rem;
}

.site-footer a {
  color: var(--blue-bright);
  text-decoration: none;
}
.site-footer a:hover { text-decoration: underline; }

.fine-print {
  margin-top: 8px;
  opacity: 0.75;
  font-size: 0.78rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 620px) {
  .container { padding: 40px 18px 32px; }
  .ring-form {
    grid-template-columns: 1fr 1fr;
  }
  .btn-calc {
    grid-column: 1 / -1;
    padding: 14px 22px;
  }
}

/* ---------- Nav ---------- */
.site-nav {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 24px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.nav-link {
  color: var(--ink-dim);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
}

.nav-link.is-active {
  color: white;
  background: linear-gradient(180deg, var(--blue-bright), var(--blue));
  box-shadow: 0 4px 14px rgba(47, 123, 255, 0.4);
}

/* ---------- Upload / Drop zone ---------- */
.upload-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.drop-zone {
  display: block;
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: rgba(255, 255, 255, 0.03);
}

.drop-zone:hover {
  border-color: var(--blue-bright);
  background: rgba(88, 166, 255, 0.06);
}

.drop-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--ink-dim);
}

.drop-icon {
  color: var(--blue-bright);
  filter: drop-shadow(0 0 10px var(--blue-glow));
}

.drop-title {
  font-weight: 600;
  color: var(--ink);
  font-size: 1.05rem;
}

.drop-sub {
  font-size: 0.85rem;
}

.preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: 12px;
}

.preview-wrap[hidden] { display: none; }

.preview-wrap img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 10px;
  display: block;
}

.preview-meta {
  color: var(--ink-dim);
  font-size: 0.85rem;
}

.upload-form .btn-calc {
  align-self: stretch;
}

/* ---------- OCR raw text expander ---------- */
.ocr-details {
  margin-top: 20px;
  text-align: left;
  border-top: 1px solid var(--card-border);
  padding-top: 14px;
}

.ocr-details summary {
  cursor: pointer;
  color: var(--ink-dim);
  font-size: 0.85rem;
  outline: none;
}

.ocr-details summary:hover { color: var(--ink); }

.ocr-text {
  margin-top: 10px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--ink-dim);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 180px;
  overflow: auto;
}

/* ---------- Detected disc sequence ---------- */
.disc-strip {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
}

.dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  display: inline-block;
}

.dot--white {
  background: #f4f7ff;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.35);
}

.dot--blue {
  background: linear-gradient(180deg, var(--blue-bright), var(--blue));
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 8px var(--blue-glow);
}

.ocr-details .gaps {
  margin: 12px 0 4px;
  font-size: 0.85rem;
  color: var(--ink-dim);
}

.ocr-details .disclaimer {
  margin: 8px 0 0;
  font-size: 0.78rem;
  color: var(--ink-dim);
  opacity: 0.75;
}

