:root {
  --indigo: #2D2654;
  --indigo-light: #EDE9FE;
  --mint: #C8E6C9;
  --bg: #F4F6F9;
  --card: #FFFFFF;
  --text: #1E2029;
  --muted: #555B6E;
  --green: #2E7D32;
  --danger: #C62828;
  --border: #E2E6EF;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}

.hidden {
  display: none !important;
}

.app-shell {
  max-width: 680px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: var(--indigo);
  color: #FFFFFF;
  padding: 18px 20px;
  position: sticky;
  top: 0;
  z-index: 20;
}

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

.icon-back-btn {
  background: rgba(255, 255, 255, 0.14);
  color: #FFFFFF;
  border: none;
  border-radius: 10px;
  width: 36px;
  height: 36px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
}

.app-header h1 {
  font-size: 20px;
  font-weight: 700;
}

.app-header p {
  font-size: 12.5px;
  color: #D5D0F0;
  margin-top: 3px;
}

/* Views */
.view-container {
  flex: 1;
  padding: 18px 18px 92px;
  display: flex;
  flex-direction: column;
}

.home-center {
  justify-content: center;
  padding-bottom: 24px;
}

.home-footer-guide {
  margin-top: 24px;
  text-align: center;
}

/* Cards & Controls */
.card {
  background: var(--card);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.06);
  margin-bottom: 14px;
}

.selector-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.eyebrow-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #6B7280;
}

.clean-select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  background: #FFFFFF;
}

.stats-green {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--green);
  margin-top: 6px;
}

.mt-6 { margin-top: 6px; }
.mb-8 { margin-bottom: 8px; }
.mb-10 { margin-bottom: 10px; }
.mb-12 { margin-bottom: 12px; }

/* Buttons */
.btn {
  width: 100%;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease;
}

.btn:active { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-lg {
  height: 52px;
  font-size: 15px;
  margin-bottom: 12px;
}

.btn-md {
  height: 46px;
  font-size: 14px;
}

.btn-sm {
  height: 40px;
  font-size: 13.5px;
  padding: 0 16px;
  width: auto;
}

.btn-xs {
  height: 32px;
  font-size: 12px;
  padding: 0 12px;
  width: auto;
  border-radius: 8px;
}

.btn-primary {
  background: var(--indigo);
  color: #FFFFFF;
}

.btn-mint {
  background: var(--mint);
  color: var(--text);
}

.btn-outline-sm {
  height: 36px;
  font-size: 12.5px;
  background: #FFFFFF;
  color: var(--indigo);
  border: 1.5px solid var(--indigo);
  border-radius: 10px;
}

.btn-outline-danger-sm {
  height: 36px;
  font-size: 12.5px;
  background: #FFFFFF;
  color: var(--danger);
  border: 1.5px solid var(--danger);
  border-radius: 10px;
}

.text-action-btn {
  background: none;
  border: none;
  color: var(--indigo);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 8px;
  cursor: pointer;
}

.btn-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.btn-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

/* Progress & Question Cards */
.progress-card {
  background: #FFFFFF;
  border-radius: 12px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--indigo);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--indigo-light);
  border-top-color: var(--indigo);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.question-card {
  background: #FFFFFF;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 2px 6px rgba(16, 24, 40, 0.05);
  margin-bottom: 12px;
}

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

.q-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--indigo);
}

.q-card-title.solved {
  color: var(--green);
}

.q-card-actions {
  display: flex;
  gap: 6px;
}

.mini-btn {
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text);
  cursor: pointer;
}

.q-preview-img {
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid #F0F2F7;
  cursor: pointer;
  display: block;
}

/* Sticky Bottom Bar */
.sticky-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 680px;
  margin: 0 auto;
  background: #FFFFFF;
  padding: 12px 18px;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.07);
  z-index: 15;
}

.sticky-bottom-bar .btn-lg {
  margin-bottom: 0;
}

/* Paste Code View */
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  resize: vertical;
}

.preview-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 340px;
}

#htmlPreviewFrame {
  width: 100%;
  flex: 1;
  min-height: 300px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #FFFFFF;
}

.badge-solved {
  background: #E8F5E9;
  color: #1B5E20;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-box {
  background: #FFFFFF;
  border-radius: 16px;
  padding: 18px;
  width: 100%;
  max-width: 440px;
  max-height: 88dvh;
  overflow-y: auto;
}

.modal-box-wide, .modal-box-guide {
  max-width: 540px;
  background: var(--bg);
}

.modal-box h3 {
  font-size: 17px;
  margin-bottom: 6px;
}

.modal-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 12px;
}

.text-input {
  width: 100%;
  height: 42px;
  border: 1.5px solid var(--indigo);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 14px;
  margin-bottom: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.inspect-img-wrap {
  max-height: 320px;
  overflow-y: auto;
  background: #FFFFFF;
  border-radius: 10px;
  padding: 8px;
  border: 1px solid var(--border);
}

.inspect-img-wrap img {
  width: 100%;
  height: auto;
  display: block;
}

/* 5-Step Card Guide */
.guide-banner {
  background: var(--indigo);
  color: #FFFFFF;
  padding: 16px;
  border-radius: 14px;
  margin-bottom: 12px;
}

.guide-banner h3 {
  font-size: 18px;
  margin-bottom: 4px;
}

.guide-banner p {
  font-size: 12.5px;
  color: #E0DCF5;
  line-height: 1.45;
}

.guide-step-card {
  background: #FFFFFF;
  border-radius: 14px;
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  box-shadow: 0 2px 6px rgba(16, 24, 40, 0.05);
  margin-bottom: 10px;
}

.step-badge {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: var(--indigo-light);
  color: var(--indigo);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.guide-step-card h4 {
  font-size: 14.5px;
  color: var(--text);
  margin-bottom: 3px;
}

.guide-step-card p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

.guide-tip-box {
  background: #E8F5E9;
  color: #1B5E20;
  font-size: 12.5px;
  line-height: 1.45;
  padding: 12px;
  border-radius: 12px;
}

/* Toast */
.toast-banner {
  position: fixed;
  bottom: 82px;
  left: 50%;
  transform: translateX(-50%);
  background: #1E2029;
  color: #FFFFFF;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  max-width: 90%;
  text-align: center;
  z-index: 60;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Print Rules */
#printContainer {
  display: none;
}

@media print {
  @page {
    size: A4;
    margin: 14mm;
  }
  body {
    background: #FFFFFF !important;
  }
  #appShell, .modal-backdrop, .toast-banner {
    display: none !important;
  }
  #printContainer {
    display: block !important;
    background: #FFFFFF;
    color: #111111;
  }
}