:root {
  --red: #C8102E;
  --red-light: #fef2f2;
  --red-hover: #a00d24;
  --cream: #f9f6f3;
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --green: #16a34a;
  --green-light: #f0fdf4;
  --amber: #d97706;
  --amber-light: #fffbeb;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.04);
  --radius: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: 'DM Sans', -apple-system, sans-serif;
  background: var(--cream);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Header ─────────────────────────────────────────────────────── */

header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 20px 24px 12px;
}

header .container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.header-top {
  margin-bottom: 12px;
}

.header-logo {
  height: 120px;
  width: auto;
}

.header-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
}

header h1 span {
  color: var(--red);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-link {
  font-size: 14px;
  font-weight: 600;
  color: var(--red);
  text-decoration: none;
}

.nav-link:hover { text-decoration: underline; }

/* User info */
.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
}

.sign-out-btn {
  background: none;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
  color: var(--gray-500);
  cursor: pointer;
}

.sign-out-btn:hover {
  border-color: var(--gray-400);
  color: var(--gray-700);
}

@media (max-width: 600px) {
  .user-name { display: none; }
}

/* ── Access Gate ────────────────────────────────────────────────── */

#gate-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 65px);
}

.gate-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 48px;
  text-align: center;
  max-width: 400px;
  width: 100%;
}

.gate-logo {
  width: 120px;
  margin: 0 auto 20px;
  display: block;
}

.gate-card h2 {
  font-size: 24px;
  margin-bottom: 8px;
}

.gate-card p {
  color: var(--gray-500);
  margin-bottom: 16px;
}

.gate-subtitle {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 16px !important;
}

.google-btn-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.gate-divider {
  height: 1px;
  background: var(--gray-200);
  margin: 20px 0;
}

.gate-divider-text {
  text-align: center;
  position: relative;
  margin: 16px 0;
}

.gate-divider-text::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: var(--gray-200);
}

.gate-divider-text span {
  background: var(--white);
  padding: 0 12px;
  font-size: 13px;
  color: var(--gray-400);
  position: relative;
}

.email-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.email-form input {
  padding: 12px 16px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
  width: 100%;
}

.email-form input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-light);
}

.btn-full {
  width: 100%;
}

.success-text {
  color: var(--green);
  font-size: 13px;
  margin-top: 8px;
}

.code-form {
  display: flex;
  gap: 8px;
}

.code-form input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-align: center;
}

.code-form input:focus {
  outline: none;
  border-color: var(--red);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

#gate-form {
  display: flex;
  gap: 8px;
}

#gate-form input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-align: center;
}

#gate-form input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-light);
}

.error-text {
  color: var(--red);
  font-size: 13px;
  margin-top: 12px;
}

/* ── Buttons ────────────────────────────────────────────────────── */

.btn-primary {
  background: var(--red);
  color: var(--white);
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--red-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-large { padding: 16px 48px; font-size: 17px; }

.btn-secondary {
  background: var(--white);
  color: var(--red);
  border: 2px solid var(--red);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.btn-secondary:hover { background: var(--red-light); }

/* ── Upload View ────────────────────────────────────────────────── */

.upload-header {
  text-align: center;
  padding: 40px 0 32px;
}

.upload-header h2 { font-size: 28px; margin-bottom: 8px; }
.upload-header p { color: var(--gray-500); max-width: 500px; margin: 0 auto; }

.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}

@media (max-width: 768px) {
  .upload-grid { grid-template-columns: 1fr; }
}

/* ── Dropzone ───────────────────────────────────────────────────── */

.dropzone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius-lg);
  background: var(--white);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16/9;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--red);
  background: var(--red-light);
}

.drop-icon { font-size: 40px; margin-bottom: 12px; }

.dropzone p { color: var(--gray-500); }
.dropzone p strong { color: var(--gray-700); }
.subtle { font-size: 13px; color: var(--gray-400); }

.preview-img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius);
  object-fit: contain;
}

.clear-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--gray-800);
  color: var(--white);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Context Fields ─────────────────────────────────────────────── */

.context-col { display: flex; flex-direction: column; gap: 20px; }

.optional-tag {
  font-size: 11px;
  font-weight: 400;
  color: var(--gray-400);
  margin-left: 4px;
}

.ref-dropzone {
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  background: var(--gray-50);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ref-dropzone:hover, .ref-dropzone.dragover {
  border-color: var(--red);
  background: var(--red-light);
}

.ref-dropzone p { font-size: 13px; color: var(--gray-400); margin: 0; }
.ref-dropzone p strong { color: var(--gray-500); font-size: 13px; }

.ref-dropzone .preview-img {
  max-height: 80px;
  border-radius: 4px;
}

.ref-dropzone .clear-btn {
  width: 22px;
  height: 22px;
  font-size: 13px;
}

.field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.required { color: var(--red); }

.field input, .field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
  color: var(--gray-800);
}

.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-light);
}

.field-hint {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 4px;
}

.submit-row { text-align: center; padding-bottom: 48px; }

/* ── Loading ────────────────────────────────────────────────────── */

#loading-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 65px);
}

.loading-card {
  text-align: center;
  padding: 48px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 24px;
}

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

.loading-card h2 { font-size: 22px; margin-bottom: 8px; }

/* ── Results ────────────────────────────────────────────────────── */

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 32px 0 24px;
}

.results-header h2 { font-size: 28px; }

.results-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 32px;
  padding-bottom: 48px;
}

@media (max-width: 868px) {
  .results-grid { grid-template-columns: 1fr; }
}

/* Left column: thumbnail + score */

.package-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.result-thumbnail {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
}

.result-title {
  padding: 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
  border-top: 1px solid var(--gray-100);
}

.overall-score-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px;
  text-align: center;
  margin-top: 16px;
}

.overall-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.overall-number {
  font-size: 56px;
  font-weight: 700;
  color: var(--red);
  line-height: 1;
  margin: 8px 0 4px;
}

.overall-max {
  font-size: 18px;
  color: var(--gray-400);
}

/* Score bars */

.score-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.score-row {
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.score-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.score-layer-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
}

.score-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--red);
}

.score-bar-track {
  height: 8px;
  background: var(--gray-100);
  border-radius: 4px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  background: var(--red);
  border-radius: 4px;
  transition: width 0.6s ease;
}

/* AI Detection */

.ai-detection-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.ai-detection-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.ai-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-500);
}

.ai-badge {
  font-size: 13px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 12px;
}

.ai-badge.ai-low {
  background: var(--green-light);
  color: var(--green);
}

.ai-badge.ai-mid {
  background: var(--amber-light);
  color: var(--amber);
}

.ai-badge.ai-high {
  background: var(--red-light);
  color: var(--red);
}

.ai-bar-track {
  height: 6px;
  background: var(--gray-100);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.ai-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}

.ai-note {
  font-size: 11px;
  color: var(--gray-400);
}

/* Highlights */

.highlight-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 600px) {
  .highlight-row { grid-template-columns: 1fr; }
}

.highlight-card {
  padding: 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.highlight-card.strength {
  background: var(--green-light);
  border: 1px solid #bbf7d0;
}

.highlight-card.opportunity {
  background: var(--amber-light);
  border: 1px solid #fde68a;
}

.highlight-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.strength .highlight-label { color: var(--green); }
.opportunity .highlight-label { color: var(--amber); }

.highlight-card p {
  font-size: 14px;
  color: var(--gray-700);
  line-height: 1.5;
}

/* Change These Immediately */

.changes-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px;
  margin-bottom: 24px;
  border-left: 4px solid var(--red);
}

.changes-card h3 {
  font-size: 16px;
  color: var(--red);
  margin-bottom: 16px;
  font-weight: 700;
}

.changes-list {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.changes-list li {
  font-size: 14px;
  color: var(--gray-700);
  line-height: 1.6;
}

.changes-list li strong {
  color: var(--gray-900);
}

/* Full feedback */

.feedback-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px;
}

.feedback-card h3 {
  font-size: 16px;
  margin-bottom: 16px;
  color: var(--gray-800);
}

.feedback-text {
  font-size: 14px;
  color: var(--gray-600);
  line-height: 1.8;
  white-space: pre-wrap;
}

.feedback-text strong { color: var(--gray-800); }

/* ── Footer ─────────────────────────────────────────────────────── */

footer {
  border-top: 1px solid var(--gray-200);
  padding: 24px;
  text-align: center;
  margin-top: 48px;
}

footer .container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.footer-logo {
  height: 40px;
  width: auto;
  opacity: 0.6;
}

footer p {
  font-size: 12px;
  color: var(--gray-400);
}

/* ── Error Toast ────────────────────────────────────────────────── */

.error-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--red);
  color: var(--white);
  padding: 14px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 999;
  max-width: 500px;
  text-align: center;
}
