*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0
}

:root {
  --navy: #0f172a;
  --indigo-dark: #1e1b4b;
  --indigo-primary: #6366f1;
  --indigo-light: #818cf8;
  --gold: #eab308;
  --gold-hover: #ca8a04;
  --text-white: #f8fafc;
  --text-muted: #94a3b8;
  --border-glass: rgba(255, 255, 255, 0.08);
  --bg-glass: rgba(30, 41, 59, 0.45);
  --bg-glass-hover: rgba(30, 41, 59, 0.6);
  --green: #10b981;
  --red: #ef4444;
  --r: 12px;
  --rlg: 16px;
}

body {
  font-family: 'Inter', sans-serif;
  background: linear-gradient(135deg, var(--navy) 0%, var(--indigo-dark) 100%);
  color: var(--text-white);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

h1,
h2,
h3,
h4,
.logo {
  font-family: 'Outfit', sans-serif;
}

a {
  color: var(--indigo-light);
  text-decoration: none;
  transition: color 0.2s
}

a:hover {
  color: var(--text-white);
  text-decoration: underline
}

/* Navigation */
nav {
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-glass);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: all 0.3s ease;
}

.nav-in {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-white);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.logo span {
  color: var(--gold)
}

.logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--indigo-primary) 0%, var(--indigo-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-links span.badge {
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--green);
  padding: 4px 10px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-links span.badge::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.btn-settings {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-white);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-settings:hover {
  background: var(--indigo-primary);
  border-color: var(--indigo-light);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
}

/* Banner Alert */
.banner-alert {
  background: rgba(16, 185, 129, 0.1);
  color: #a7f3d0;
  border-bottom: 1px solid rgba(16, 185, 129, 0.2);
  text-align: center;
  padding: .65rem 1rem;
  font-size: .85rem;
  font-weight: 500;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

/* Main Layout */
.wrap {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 380px 1fr 350px;
  gap: 1.5rem;
  min-height: calc(100vh - 105px);
}

/* Glassmorphic Form Card */
.form-card {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--rlg);
  height: fit-content;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  scrollbar-width: thin;
  scrollbar-color: var(--border-glass) transparent;
}

.form-card::-webkit-scrollbar {
  width: 6px;
}

.form-card::-webkit-scrollbar-thumb {
  background-color: var(--border-glass);
  border-radius: 3px;
}

.form-head {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-glass);
  background: rgba(99, 102, 241, 0.05);
  border-radius: var(--rlg) var(--rlg) 0 0;
}

.form-head h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-white);
  margin-bottom: .25rem;
}

.form-head p {
  font-size: .8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.form-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.fg-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}

.fg label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  display: block;
}

.req {
  color: var(--red)
}

.opt {
  font-weight: 400;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0
}

select,
input[type=text],
textarea {
  width: 100%;
  border: 1px solid var(--border-glass);
  border-radius: var(--r);
  padding: 9px 12px;
  font-size: .875rem;
  font-family: 'Inter', sans-serif;
  color: var(--text-white);
  background: rgba(15, 23, 42, 0.4);
  transition: all 0.2s ease;
}

textarea {
  resize: vertical;
  line-height: 1.5
}

select:focus,
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--indigo-primary);
  background: rgba(15, 23, 42, 0.6);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
}

select option {
  background: #1e1b4b;
  color: var(--text-white);
}

.gen-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--indigo-primary) 0%, var(--indigo-light) 100%);
  color: #fff;
  border: none;
  border-radius: var(--r);
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all 0.2s;
  margin-top: .4rem;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.gen-btn:hover {
  opacity: .95;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.gen-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.err {
  font-size: .78rem;
  color: var(--red);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
  padding: 8px 12px;
  display: none;
  margin-top: .5rem;
}

/* Output Container */
.out-card {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--rlg);
  min-height: 600px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.empty {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
  gap: 2rem;
}

.empty-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
  max-width: 500px;
}

.empty-quiz {
  flex: 1;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.empty-icon {
  font-size: 3.5rem;
  filter: drop-shadow(0 0 15px rgba(99, 102, 241, 0.25));
}

.empty h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-white);
}

.empty p {
  font-size: .88rem;
  color: var(--text-muted);
  max-width: 400px;
}

.feats {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  margin-top: .8rem;
  text-align: left;
  max-width: 500px;
}

.feat {
  font-size: .83rem;
  color: #34d399;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.feat::before {
  content: '✓';
  color: #34d399;
  font-weight: bold;
}

.feat.warn {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.15);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: .78rem;
  display: block;
}

.feat.warn::before {
  content: none;
}

.feat.danger {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.15);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .78rem;
  line-height: 1.5;
  display: block;
}

.feat.danger::before {
  content: none;
}

.loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: 3rem;
}

.spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 4px solid rgba(99, 102, 241, 0.1);
  border-top-color: var(--indigo-primary);
  animation: spin .9s linear infinite;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

@keyframes spin {
  to {
    transform: rotate(360deg)
  }
}

@keyframes dots {

  0%,
  20% {
    content: '.'
  }

  40% {
    content: '..'
  }

  60%,
  100% {
    content: '...'
  }
}

.ldots::after {
  content: '.';
  animation: dots 1.2s steps(3, end) infinite
}

.loading p {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-white)
}

.loading small {
  font-size: .8rem;
  color: var(--text-muted)
}

/* Result State & Preview */
.res-top {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(99, 102, 241, 0.05);
  flex-wrap: wrap;
  gap: .5rem;
}

.res-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-white);
}

.res-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.abtn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all 0.2s;
  border: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.abtn:hover {
  opacity: .9
}

.abtn:disabled {
  opacity: .4;
  cursor: not-allowed
}

.abtn.ghost {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-white);
  border: 1px solid var(--border-glass);
}

.abtn.ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

.abtn.green {
  background: #059669;
  color: #fff;
}

.abtn.purple {
  background: #7c3aed;
  color: #fff;
}

/* Preview Table Styles */
.preview {
  padding: 1.5rem;
  overflow-x: auto;
  background: #0f172a;
}

.preview table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
  line-height: 1.6;
  color: #cbd5e1;
}

.preview th,
.preview td {
  border: 1px solid #334155;
  padding: 9px 12px;
  vertical-align: top;
}

.preview th {
  background: #1e1b4b;
  color: var(--text-white);
  font-weight: 600;
  font-size: .8rem;
  text-align: center;
}

.preview .sec td {
  background: rgba(99, 102, 241, 0.15);
  color: var(--indigo-light);
  font-weight: 700;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.preview .lbl {
  background: rgba(255, 255, 255, 0.02);
  font-weight: 600;
  color: #e2e8f0;
  width: 200px;
  min-width: 180px;
}

.preview .lbl-flow {
  background: rgba(99, 102, 241, 0.05);
  font-weight: 600;
  color: var(--indigo-light);
  width: 200px;
  min-width: 180px;
}

.preview .note {
  color: var(--text-muted);
  font-style: italic;
}

.preview .placeholder {
  background: rgba(234, 179, 8, 0.08);
  border: 1px solid rgba(234, 179, 8, 0.2);
  color: #fef08a;
  font-style: italic;
}

.preview .flow-cell {
  line-height: 1.7;
}

.preview .flow-step {
  display: block;
  margin-bottom: 12px;
}

.preview .flow-step-title {
  display: block;
  font-weight: 700;
  color: var(--indigo-light);
  margin-bottom: 4px;
}

.preview .flow-step-body {
  display: block;
  color: #94a3b8;
  padding-left: 8px;
}

/* Settings Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  padding: 1rem;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #1e1b4b;
  border: 1px solid var(--border-glass);
  border-radius: var(--rlg);
  padding: 2rem;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: all 0.3s ease;
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-card h2 {
  font-size: 1.3rem;
  color: var(--text-white);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.modal-card label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.4rem;
}

.modal-card input {
  margin-bottom: 1.25rem;
}

.modal-card select {
  margin-bottom: 1.5rem;
}

.modal-btns {
  display: flex;
  gap: 0.75rem;
}

.modal-btn-save {
  flex: 1;
  background: var(--indigo-primary);
  border: none;
  padding: 10px;
  color: white;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.modal-btn-save:hover {
  background: var(--indigo-light);
}

.modal-btn-close {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  padding: 10px;
  color: var(--text-white);
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.modal-btn-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Informative Sections */
.info-section {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--rlg);
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.info-section h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--indigo-light);
  margin-bottom: 0.75rem;
}

.info-section p {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.7;
  margin-bottom: 0.75rem;
}

.info-section ol {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.8;
  padding-left: 1.25rem;
}

/* Footer */
footer {
  text-align: center;
  padding: 2.5rem 1.5rem;
  font-size: .8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-glass);
  margin-top: 4rem;
  background: rgba(15, 23, 42, 0.5);
}

footer a {
  color: var(--text-muted);
  margin: 0 10px;
}

footer a:hover {
  color: var(--text-white);
}

@media(max-width:960px) {
  .wrap {
    grid-template-columns: 1fr
  }

  .form-card {
    position: static;
    max-height: none
  }
}

/* Portal Dashboard Styles */
.dashboard-wrap {
  max-width: 1000px;
  margin: 40px auto;
  padding: 0 1.5rem;
  text-align: center;
}

.dashboard-header {
  margin-bottom: 3rem;
}

.dashboard-header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text-white);
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, var(--text-white) 30%, var(--indigo-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.dashboard-header p {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto;
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.portal-card {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--rlg);
  padding: 2.25rem 1.5rem;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  text-decoration: none;
}

.portal-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(255, 255, 255, 0.03), transparent 60%);
  pointer-events: none;
}

.portal-card:hover {
  transform: translateY(-8px);
  background: var(--bg-glass-hover);
  border-color: rgba(99, 102, 241, 0.25);
}

.portal-icon {
  font-size: 3.2rem;
  margin-bottom: 1.25rem;
  transition: transform 0.3s ease;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.3));
}

.portal-card:hover .portal-icon {
  transform: scale(1.15) rotate(3deg);
}

.portal-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-white);
  margin-bottom: 0.5rem;
}

.portal-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1.25rem;
  flex-grow: 1;
}

.portal-grades {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  transition: all 0.2s;
}

/* Glow Effects on Hover */
.portal-card.primary:hover {
  box-shadow: 0 15px 35px -5px rgba(16, 185, 129, 0.25);
  border-color: rgba(16, 185, 129, 0.4);
}

.portal-card.primary:hover .portal-grades {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.portal-card.intermediate:hover {
  box-shadow: 0 15px 35px -5px rgba(59, 130, 246, 0.25);
  border-color: rgba(59, 130, 246, 0.4);
}

.portal-card.intermediate:hover .portal-grades {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.3);
  color: #60a5fa;
}

.portal-card.junior:hover {
  box-shadow: 0 15px 35px -5px rgba(168, 85, 247, 0.25);
  border-color: rgba(168, 85, 247, 0.4);
}

.portal-card.junior:hover .portal-grades {
  background: rgba(168, 85, 247, 0.15);
  border-color: rgba(168, 85, 247, 0.3);
  color: #c084fc;
}

.portal-card.senior:hover {
  box-shadow: 0 15px 35px -5px rgba(234, 179, 8, 0.25);
  border-color: rgba(234, 179, 8, 0.4);
}

.portal-card.senior:hover .portal-grades {
  background: rgba(234, 179, 8, 0.15);
  border-color: rgba(234, 179, 8, 0.3);
  color: #fde047;
}

/* Back link in nav */
.btn-back-portal {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid var(--border-glass);
  background: rgba(255, 255, 255, 0.02);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-back-portal:hover {
  color: var(--text-white);
  border-color: var(--indigo-light);
  background: rgba(99, 102, 241, 0.1);
  text-decoration: none;
}
@media(max-width:960px) { .empty { flex-direction: column; } .empty-quiz { max-width: 100%; margin-top: 2rem; } }


@media(max-width:1300px) { .wrap { grid-template-columns: 380px 1fr; } .quiz-sidebar { grid-column: 1 / -1; } }
