
:root {
  --bg: oklch(14% 0.02 250);
  --bg-2: oklch(18% 0.03 250);
  --text-primary: oklch(96% 0.01 250);
  --text-secondary: oklch(78% 0.02 250);
  --accent-coral: oklch(65% 0.15 20);
  --accent-coral-glow: oklch(65% 0.15 20 / 0.3);
  --card-bg: oklch(18% 0.03 250 / 0.86);
  --card-border: oklch(80% 0.02 250 / 0.15);
  --font-sans: "Manrope", 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Ensure [hidden] always wins over display: flex/grid from component CSS */
[hidden] { display: none !important; }

html {
  min-height: 100vh;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text-primary);
  font-family: var(--font-sans);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px 16px;
  background:
    radial-gradient(circle at top right, oklch(65% 0.15 20 / 0.18), transparent 35%),
    radial-gradient(circle at 80% 20%, oklch(65% 0.15 20 / 0.08), transparent 28%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  background-attachment: fixed;
}

.page-container {
  width: min(1040px, 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(580px, 100%);
}

.badge {
  background: oklch(20% 0.03 250);
  border: 1px solid oklch(80% 0.02 250 / 0.18);
  color: oklch(90% 0.02 250);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 9999px;
  width: fit-content;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 800;
  line-height: 1.1;
  color: oklch(98% 0 0);
  letter-spacing: -0.025em;
  margin: 0;
}

.lede {
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.6;
}

main {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 800px) {
  main {
    grid-template-columns: 1fr 1.15fr;
    align-items: start;
  }
  /* Lock right panel height so results render in-place without causing page scroll */
  .content-right {
    max-height: calc(100svh - 200px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 6px;
    scrollbar-width: thin;
    scrollbar-color: oklch(80% 0.02 250 / 0.25) transparent;
  }
  .content-right::-webkit-scrollbar {
    width: 4px;
  }
  .content-right::-webkit-scrollbar-track {
    background: transparent;
  }
  .content-right::-webkit-scrollbar-thumb {
    background: oklch(80% 0.02 250 / 0.2);
    border-radius: 10px;
  }
  .content-right::-webkit-scrollbar-thumb:hover {
    background: var(--accent-coral);
  }
}

.content-left, .content-right {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

form {
  display: grid;
  gap: 16px;
  padding: 24px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(16px);
}

label {
  display: grid;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

input, select, button {
  font: inherit;
  font-size: 0.9rem;
  border-radius: 10px;
  padding: 10px 14px;
  transition: all 250ms cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
}

input, select {
  border: 1px solid oklch(80% 0.02 250 / 0.18);
  background: oklch(13% 0.02 250 / 0.9);
  color: var(--text-primary);
  outline: none;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a0a8b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 16px;
  padding-right: 40px;
}

input::placeholder {
  color: oklch(60% 0.02 250);
}

input:focus, select:focus {
  border-color: var(--accent-coral);
  box-shadow: 0 0 0 3px oklch(65% 0.15 20 / 25%);
}

button {
  border: 0;
  background: linear-gradient(135deg, oklch(62% 0.18 20), oklch(55% 0.18 15));
  color: white;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--accent-coral-glow);
}

button:hover:not(:disabled) {
  background: linear-gradient(135deg, oklch(66% 0.19 20), oklch(58% 0.19 15));
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--accent-coral-glow);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

#status {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

#result {
  display: grid;
  gap: 16px;
  padding: 28px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(16px);
  animation: fadeIn 300ms ease-out;
}

#result[hidden] {
  display: none;
}

#result h2 {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

#result p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.achievement-badge {
  display: inline-block;
  background: oklch(65% 0.15 20 / 0.15);
  border: 1px solid oklch(65% 0.15 20 / 0.35);
  color: oklch(92% 0.08 20);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
}

#result label {
  margin-top: 8px;
}

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

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: oklch(25% 0.05 250);
  color: white;
  padding: 12px 24px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
  opacity: 0;
  z-index: 1000;
  pointer-events: none;
  font-weight: 600;
}
#toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
#toast.error {
  background: oklch(58% 0.18 20);
}
#toast.success {
  background: oklch(48% 0.14 150);
}

.btn-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

#lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
#lightbox.open {
  opacity: 1;
  pointer-events: auto;
}
.lb-backdrop {
  position: absolute;
  inset: 0;
  background: oklch(8% 0.02 250 / 88%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.lb-body {
  position: relative;
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  transform: scale(0.92);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
#lightbox.open .lb-body {
  transform: scale(1);
}
.lb-body canvas {
  display: block;
  max-width: 92vw;
  max-height: 90vh;
  width: auto;
  height: auto;
}

.lb-close {
  position: absolute;
  top: -16px;
  right: -16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: oklch(65% 0.15 20);
  color: white;
  border: 2px solid #000;
  font-size: 20px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  padding: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  transition: transform 0.2s ease, background 0.2s ease;
}
.lb-close:hover {
  background: oklch(70% 0.18 20);
  transform: scale(1.1);
}

.placeholder-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 42px 28px;
  background: radial-gradient(circle at top right, oklch(65% 0.15 20 / 0.08), transparent 70%), var(--card-bg);
  border: 1px dashed oklch(80% 0.02 250 / 0.22);
  border-radius: 20px;
  backdrop-filter: blur(16px);
  gap: 12px;
  color: var(--text-secondary);
  transition: border-color 0.3s ease;
}
.placeholder-card:hover {
  border-color: oklch(65% 0.15 20 / 0.4);
}

.placeholder-icon {
  font-size: 2.5rem;
  margin-bottom: 4px;
  filter: drop-shadow(0 4px 12px oklch(65% 0.15 20 / 0.3));
}

.placeholder-card h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.placeholder-card p {
  display: grid;
  gap: 16px;
  padding: 28px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(16px);
  animation: fadeIn 300ms ease-out;
}

#result[hidden] {
  display: none;
}

#result h2 {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

#result p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.achievement-badge {
  display: inline-block;
  background: oklch(65% 0.15 20 / 0.15);
  border: 1px solid oklch(65% 0.15 20 / 0.35);
  color: oklch(92% 0.08 20);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
}

#result label {
  margin-top: 8px;
}

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

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: oklch(25% 0.05 250);
  color: white;
  padding: 12px 24px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
  opacity: 0;
  z-index: 1000;
  pointer-events: none;
  font-weight: 600;
}
#toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
#toast.error {
  background: oklch(58% 0.18 20);
}
#toast.success {
  background: oklch(48% 0.14 150);
}

.btn-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

#lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
#lightbox.open {
  opacity: 1;
  pointer-events: auto;
}
.lb-backdrop {
  position: absolute;
  inset: 0;
  background: oklch(8% 0.02 250 / 88%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.lb-body {
  position: relative;
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  transform: scale(0.92);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
#lightbox.open .lb-body {
  transform: scale(1);
}
.lb-body canvas {
  display: block;
  max-width: 92vw;
  max-height: 90vh;
  width: auto;
  height: auto;
}

.lb-close {
  position: absolute;
  top: -16px;
  right: -16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: oklch(65% 0.15 20);
  color: white;
  border: 2px solid #000;
  font-size: 20px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  padding: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  transition: transform 0.2s ease, background 0.2s ease;
}
.lb-close:hover {
  background: oklch(70% 0.18 20);
  transform: scale(1.1);
}

.placeholder-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 42px 28px;
  background: radial-gradient(circle at top right, oklch(65% 0.15 20 / 0.08), transparent 70%), var(--card-bg);
  border: 1px dashed oklch(80% 0.02 250 / 0.22);
  border-radius: 20px;
  backdrop-filter: blur(16px);
  gap: 12px;
  color: var(--text-secondary);
  transition: border-color 0.3s ease;
}
.placeholder-card:hover {
  border-color: oklch(65% 0.15 20 / 0.4);
}

.placeholder-icon {
  font-size: 2.5rem;
  margin-bottom: 4px;
  filter: drop-shadow(0 4px 12px oklch(65% 0.15 20 / 0.3));
}

.placeholder-card h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.placeholder-card p {
  font-size: 0.9rem;
  line-height: 1.45;
  max-width: 34ch;
}

/* Segmented Toggle Control - Impeccable Design */
.data-source-toggle {
  display: flex;
  background: oklch(20% 0.03 250 / 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 6px;
  border-radius: 9999px;
  border: 1px solid oklch(80% 0.02 250 / 0.1);
  margin-bottom: 24px;
  gap: 0;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
}

.toggle-option {
  flex: 1;
  text-align: center;
  position: relative;
  cursor: pointer;
  border-radius: 9999px;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  user-select: none;
}

.toggle-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-option span {
  font-size: 0.95rem;
  font-weight: 700;
  color: oklch(75% 0.02 250);
  position: relative;
  z-index: 2;
  transition: color 0.3s ease;
  letter-spacing: 0.02em;
}

.toggle-option:has(input:checked) {
  background: linear-gradient(135deg, oklch(65% 0.2 30), oklch(55% 0.22 260));
  box-shadow: 0 6px 16px oklch(60% 0.2 145 / 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

.toggle-option:has(input:checked) span {
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.toggle-option:hover:not(:has(input:checked)) {
  background: oklch(90% 0.02 250 / 0.05);
}

.toggle-option:hover:not(:has(input:checked)) span {
  color: #fff;
}

/* Lightbox Modal for Certificate Preview */
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#lightbox.open {
  opacity: 1;
  pointer-events: auto;
}

.lb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.lb-body {
  position: relative;
  max-width: 92vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.lb-close {
  position: absolute;
  top: -44px;
  right: 0;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.2s ease;
}

.lb-close:hover,
.lb-close:focus-visible {
  background: rgba(255, 255, 255, 0.35);
}

#lbCanvas {
  max-width: 100%;
  max-height: 80vh;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
}
