@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap");

:root {
  --purple: #7b6cf6;
  --purple-deep: #6355e0;
  --purple-soft: #ebe8ff;
  --purple-grad: linear-gradient(135deg, #8b7cf8 0%, #6c63f0 55%, #5a52e0 100%);
  --coral: #f07a5a;
  --coral-soft: #ffe8e0;
  --teal: #3bb5af;
  --teal-soft: #dff6f4;
  --ink: #1e1e2d;
  --muted: #8b8ba0;
  --line: #ececf4;
  --card: #ffffff;
  --bg: #f3f2f8;
  --radius: 20px;
  --radius-sm: 16px;
  --radius-pill: 999px;
  --shadow: 0 8px 24px rgba(99, 85, 224, 0.08);
  --shadow-sm: 0 4px 14px rgba(30, 30, 45, 0.05);
  --font: "Plus Jakarta Sans", system-ui, sans-serif;
  --touch: 48px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  color: var(--ink);
  min-height: 100dvh;
  padding-bottom: calc(92px + var(--safe-b));
  background:
    radial-gradient(900px 480px at 0% 0%, #e4e0ff 0%, transparent 55%),
    radial-gradient(700px 420px at 100% 10%, #dceefe 0%, transparent 50%),
    linear-gradient(180deg, #efeef8 0%, var(--bg) 40%, #f7f6fb 100%);
  background-attachment: fixed;
}

.container {
  max-width: 430px;
  margin: 0 auto;
  padding: calc(18px + var(--safe-t)) 18px 24px;
  animation: fadeUp 0.4s ease both;
}

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

/* Brand + profile top */
.brand-hero {
  display: none;
}

.profile-section {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 4px 2px;
}

.profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--purple-grad);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  box-shadow: 0 6px 16px rgba(123, 108, 246, 0.3);
}

.profile-info {
  flex: 1;
  min-width: 0;
}

.profile-info h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.profile-info p {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

.app-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--purple);
  margin-bottom: 4px;
}

/* Hero CTA card (like Happening Now) */
.hero-card {
  background: var(--purple-grad);
  border-radius: 24px;
  padding: 16px;
  color: #fff;
  margin-bottom: 22px;
  box-shadow: 0 14px 32px rgba(108, 99, 240, 0.32);
  position: relative;
  overflow: hidden;
  animation: fadeUp 0.45s ease 0.05s both;
}

.hero-banner-wrap {
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  position: relative;
  z-index: 1;
}

.hero-banner-image {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: 0.02em;
  position: relative;
  z-index: 1;
}

.hero-card::after {
  content: "";
  position: absolute;
  right: -20px;
  bottom: -30px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
}

.hero-card::before {
  content: "";
  position: absolute;
  right: 30px;
  top: -40px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.hero-card-label {
  font-size: 0.78rem;
  font-weight: 500;
  opacity: 0.85;
  margin-bottom: 6px;
  position: relative;
  z-index: 1;
}

.hero-card-title {
  font-size: clamp(1.25rem, 5.5vw, 1.55rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
  white-space: nowrap;
}

.hero-card-meta {
  font-size: 0.82rem;
  opacity: 0.88;
  position: relative;
  z-index: 1;
}

/* Section */
.section {
  margin-bottom: 18px;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  letter-spacing: -0.02em;
}

.section-title i {
  color: var(--purple);
  margin-top: 0 !important;
}

/* Cards list */
.tests-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.test-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  animation: fadeUp 0.35s ease both;
}

.test-card:active {
  transform: scale(0.985);
}

.test-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.test-code {
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.test-grade {
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
}

.grade-a {
  background: #e4f8ef;
  color: #1f9a5c;
}
.grade-b {
  background: var(--purple-soft);
  color: var(--purple-deep);
}
.grade-c {
  background: #fff3d9;
  color: #c4841a;
}
.grade-d,
.grade-f {
  background: var(--coral-soft);
  color: #d45a3c;
}

.test-card-body {
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.4;
}

.test-dropdown {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: none;
}

.test-dropdown.open {
  display: block;
}

.test-detail {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.84rem;
  margin-bottom: 8px;
}

.test-detail span:first-child {
  color: var(--muted);
}

.test-detail span:last-child {
  color: var(--ink);
  font-weight: 600;
  text-align: right;
}

.empty-state {
  text-align: center;
  padding: 42px 20px;
  color: var(--muted);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.empty-state i {
  font-size: 2.2rem;
  color: var(--purple);
  opacity: 0.45;
  margin-bottom: 10px;
  margin-top: 0 !important;
}

.empty-state p {
  font-size: 0.9rem;
}

/* Bottom bar */
.bottom-menu {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  padding: 12px 18px calc(14px + var(--safe-b));
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  border-top: 1px solid rgba(123, 108, 246, 0.08);
  box-shadow: 0 -8px 24px rgba(30, 30, 45, 0.04);
}

.bottom-menu .btn-primary {
  max-width: 430px;
  margin: 0 auto;
  box-shadow: 0 10px 24px rgba(123, 108, 246, 0.35);
}

/* Buttons */
.btn-primary {
  width: 100%;
  min-height: var(--touch);
  padding: 14px 22px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--purple-grad);
  color: #fff;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn-primary i {
  margin-top: 0 !important;
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-secondary {
  min-height: var(--touch);
  padding: 12px 18px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--purple-soft);
  color: var(--purple-deep);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-secondary i {
  margin-top: 0 !important;
}

.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: none;
  background: var(--purple-soft);
  color: var(--purple-deep);
  font-size: 1.05rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.btn-icon i {
  margin-top: 0 !important;
}

.btn-full {
  margin-bottom: 16px;
}

/* Inputs */
.input-group {
  margin-bottom: 14px;
}

.input-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.input-group input,
.input-group textarea,
.matching-select,
.answer-input,
.input-answer,
.score-input {
  width: 100%;
  min-height: var(--touch);
  padding: 12px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  font-family: var(--font);
  font-size: 1rem;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-group textarea {
  min-height: 88px;
  resize: vertical;
}

.input-group input:focus,
.input-group textarea:focus,
.matching-select:focus,
.answer-input:focus,
.input-answer:focus,
.score-input:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 4px rgba(123, 108, 246, 0.15);
}

.error-message {
  display: none;
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--coral-soft);
  color: #d45a3c;
  font-size: 0.84rem;
  font-weight: 500;
}

.error-message.show {
  display: block;
}

/* Fullscreen */
.fullscreen-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  flex-direction: column;
  background: var(--bg);
}

.fullscreen-modal.open {
  display: flex;
  animation: fadeUp 0.25s ease;
}

.test-header,
.test-form-header {
  padding: calc(12px + var(--safe-t)) 14px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.test-header h3,
.test-form-header h3 {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--ink);
  flex: 1;
  text-align: center;
  letter-spacing: -0.02em;
}

.test-progress {
  min-width: 56px;
  text-align: center;
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  background: var(--purple-soft);
  color: var(--purple-deep);
  font-size: 0.75rem;
  font-weight: 700;
}

.test-progress-track {
  height: 4px;
  background: #e8e6f5;
  width: 100%;
}

.test-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--purple-grad);
  transition: width 0.25s ease;
  border-radius: 0 3px 3px 0;
}

.test-body,
.test-form-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  -webkit-overflow-scrolling: touch;
}

.test-footer {
  padding: 12px 16px calc(12px + var(--safe-b));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: #fff;
  box-shadow: 0 -4px 18px rgba(30, 30, 45, 0.05);
}

.test-footer .btn-primary,
.test-footer .btn-secondary {
  flex: 1;
  width: auto;
}

#questionCounter {
  display: none !important;
}

/* Question card */
.question-card {
  background: var(--card);
  border-radius: 24px;
  padding: 22px 18px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.28s ease;
}

.question-number {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

.question-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.question-options-6 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.question-options-6 .option-btn {
  text-align: center;
  justify-content: center;
  padding: 16px 10px;
}

.option-btn {
  min-height: var(--touch);
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  transition: all 0.15s ease;
}

.option-btn:active {
  transform: scale(0.98);
}

.option-btn.selected {
  border-color: transparent;
  background: var(--purple-grad);
  color: #fff;
  box-shadow: 0 8px 18px rgba(123, 108, 246, 0.28);
}

.dual-input,
.single-input,
.score-input-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dual-input label,
.single-input label,
.score-input-group p {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.matching-hint {
  font-size: 0.86rem;
  color: var(--muted);
  margin-bottom: 14px;
  line-height: 1.4;
}

.matching-answers {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.matching-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.matching-num {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: var(--purple-grad);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
  box-shadow: 0 6px 14px rgba(123, 108, 246, 0.25);
}

.matching-select {
  appearance: auto;
}

/* Result */
.result-modal .modal-body {
  text-align: center;
}

.result-grade {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--purple);
  margin: 8px 0 18px;
  letter-spacing: -0.04em;
}

.result-details {
  text-align: left;
  background: var(--purple-soft);
  border-radius: var(--radius-sm);
  padding: 6px 16px;
}

.result-item {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid rgba(123, 108, 246, 0.12);
  font-size: 0.9rem;
}

.result-item:last-child {
  border-bottom: none;
}

.result-item span {
  color: var(--muted);
}

.result-item strong {
  color: var(--ink);
  font-weight: 700;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 2000;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: #fff;
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: fadeUp 0.25s ease;
}

.toast.error {
  background: var(--coral);
}
.toast.success {
  background: #1f9a5c;
}
.toast.info {
  background: var(--purple-deep);
}

::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-thumb {
  background: rgba(123, 108, 246, 0.25);
  border-radius: 4px;
}
