/* Global Design System - Sage-Cream */
:root {
  --color-bg: #F4F4EE;
  --color-grid-line: #ECECE5;
  --color-card-bg: #FFFFFF;
  --color-text-main: #1D3520;
  --color-text-muted: #7E8276;
  --color-primary: #BEF264;
  /* Lime-Green */
  --color-primary-dark: #A3E233;
  --color-accent-dark: #122414;
  --color-border: #E3E4DB;
  --color-success: #4ADE80;
  --color-success-bg: #ECFDF5;
  --color-success-text: #065F46;
  --color-warning: #F59E0B;
  --color-warning-bg: #FEF3C7;
  --color-warning-text: #92400E;
  --color-toast-bg: #1D3520;
  --color-toast-text: #FFFFFF;

  --shadow-sm: 0 1px 2px 0 rgba(29, 53, 32, 0.05);
  --shadow-md: 0 4px 12px 0 rgba(29, 53, 32, 0.05), 0 1px 3px 0 rgba(29, 53, 32, 0.1);
  --shadow-lg: 0 20px 45px -5px rgba(29, 53, 32, 0.08), 0 10px 10px -5px rgba(29, 53, 32, 0.03);

  --font-display: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'Space Mono', monospace;

  --transition-smooth: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: all 0.2s ease;
}

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

body {
  background-color: var(--color-bg);
  color: var(--color-text-main);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
  min-height: 100vh;
}

/* Background gridlines */
.grid-lines {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-around;
  pointer-events: none;
  z-index: 0;
}

.grid-line {
  width: 1px;
  height: 100%;
  background-color: var(--color-grid-line);
}

/* Common Text Elements */
h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--color-accent-dark);
  line-height: 1.25;
}

h1 {
  font-size: 2.2rem;
  margin-bottom: 1.25rem;
}

h2 {
  font-size: 1.6rem;
  margin-bottom: 1rem;
}

p {
  color: var(--color-text-main);
  margin-bottom: 1rem;
}

.mono-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  color: var(--color-text-muted);
  display: inline-block;
  margin-bottom: 0.5rem;
}

/* Buttons */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  padding: 0.8rem 1.6rem;
  border-radius: 9999px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition-fast);
  font-size: 0.95rem;
}

.btn-primary {
  background-color: var(--color-accent-dark);
  color: var(--color-primary);
}

.btn-primary:hover:not(:disabled) {
  background-color: #233e26;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-primary:disabled,
.btn-success:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-success {
  background-color: var(--color-primary);
  color: var(--color-accent-dark);
}

.btn-success:hover:not(:disabled) {
  background-color: var(--color-primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--color-text-main);
  color: var(--color-text-main);
}

.btn-outline:hover {
  background-color: rgba(29, 53, 32, 0.05);
}

.btn-text {
  background: none;
  color: var(--color-text-muted);
  padding: 0.5rem 1rem;
}

.btn-text:hover {
  color: var(--color-text-main);
}

.btn-small {
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
}

/* App Header Layout */
.app-header {
  position: sticky;
  top: 0;
  background-color: rgba(244, 244, 238, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  z-index: 100;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  flex-direction: column;
}

.logo-mono {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--color-text-muted);
  line-height: 1;
}

.logo-main {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--color-accent-dark);
  line-height: 1.1;
}

/* Nav Tabs */
.app-nav {
  display: flex;
  gap: 0.5rem;
  background-color: rgba(29, 53, 32, 0.04);
  padding: 0.35rem;
  border-radius: 9999px;
  border: 1px solid rgba(29, 53, 32, 0.06);
}

.nav-tab {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.55rem 1.25rem;
  border-radius: 9999px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition-fast);
}

.nav-tab:hover {
  color: var(--color-text-main);
}

.nav-tab.active {
  background-color: var(--color-card-bg);
  color: var(--color-accent-dark);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.tab-number {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  opacity: 0.7;
}

.settings-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-main);
  padding: 0.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.settings-btn:hover {
  background-color: rgba(29, 53, 32, 0.05);
  transform: rotate(30deg);
}

.icon-gear {
  width: 20px;
  height: 20px;
}

/* Main Content Panel Manager */
.app-main-content {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 2rem 5rem 2rem;
  z-index: 1;
}

.section-panel {
  display: none;
}

.section-panel.active {
  display: block;
}

.section-container {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 4rem;
  align-items: center;
}

/* Sidebar Columns */
.info-sidebar {
  max-width: 440px;
}

.info-sidebar p {
  font-size: 1.05rem;
  color: var(--color-text-main);
  opacity: 0.9;
  margin-bottom: 1.5rem;
}

.deck-controls-hint {
  margin-top: 2rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hint-arrow {
  display: inline-block;
  animation: bounceRight 1.5s infinite;
}

@keyframes bounceRight {

  0%,
  100% {
    transform: translateX(0);
  }

  50% {
    transform: translateX(5px);
  }
}

/* Card Deck Architecture */
.card-deck-wrapper {
  perspective: 1000px;
  height: auto;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.deck-container {
  position: relative;
  width: 100%;
  max-width: 460px;
  height: auto;
}

.deck-card {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--color-card-bg);
  border-radius: 28px;
  padding: 2.25rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(29, 53, 32, 0.04);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transform-origin: center bottom;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.1),
    opacity 0.5s ease,
    z-index 0.3s;
}

/* Active State Transformations (Deck Effect) */
.deck-card.active {
  position: relative;
  height: auto;
  opacity: 1;
  pointer-events: auto;
  z-index: 10;
  transform: rotate(0deg) translate3d(0, 0, 0);
}

.deck-card.active+.deck-card {
  opacity: 0.7;
  pointer-events: none;
  z-index: 9;
  transform: rotate(2.5deg) translate3d(10px, 14px, -50px);
}

.deck-card.active+.deck-card+.deck-card {
  opacity: 0.35;
  pointer-events: none;
  z-index: 8;
  transform: rotate(-2deg) translate3d(-10px, 28px, -100px);
}

/* Slide away active card class */
.deck-card.slide-out {
  transform: translate3d(-140%, -40px, 0) rotate(-18deg) !important;
  opacity: 0 !important;
  pointer-events: none;
}

.deck-card.slide-in-rev {
  animation: slideInFromLeft 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideInFromLeft {
  from {
    transform: translate3d(-140%, -40px, 0) rotate(-18deg);
    opacity: 0;
  }

  to {
    transform: rotate(0deg) translate3d(0, 0, 0);
    opacity: 1;
  }
}

/* Card Elements */
.card-progress {
  width: 100%;
  margin-bottom: 1rem;
}

.progress-bar {
  height: 4px;
  width: 100%;
  background-color: rgba(29, 53, 32, 0.05);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background-color: var(--color-text-main);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.card-header-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.deck-card h2 {
  font-size: 1.75rem;
  margin-bottom: 1.25rem;
  color: var(--color-accent-dark);
}

.card-body {
  flex-grow: 1;
  overflow-y: auto;
  margin-bottom: 1.5rem;
  padding-right: 0.25rem;
}

/* Custom scrollbar for card body */
.card-body::-webkit-scrollbar {
  width: 4px;
}

.card-body::-webkit-scrollbar-thumb {
  background-color: rgba(29, 53, 32, 0.1);
  border-radius: 4px;
}

.card-body p {
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 1rem;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(29, 53, 32, 0.05);
  padding-top: 1.25rem;
}

.card-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* Card Specific Layouts */
.formula-block {
  background-color: rgba(190, 242, 100, 0.15);
  border-left: 4px solid var(--color-text-main);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  border-radius: 0 12px 12px 0;
  margin: 1.25rem 0;
  line-height: 1.8;
  color: var(--color-accent-dark);
}

.kw-if,
.kw-then {
  font-weight: 700;
  color: var(--color-accent-dark);
}

.var-x {
  color: #2E5232;
}

.var-y {
  color: #4B6E1F;
}

.inline-formula {
  background-color: rgba(29, 53, 32, 0.03);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  margin: 0.75rem 0;
  font-style: italic;
  font-family: var(--font-body);
  font-size: 0.9rem;
}

.science-list {
  list-style: none;
  margin-top: 0.5rem;
}

.science-list li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.science-list li::before {
  content: "➔";
  position: absolute;
  left: 0;
  color: var(--color-text-muted);
}

/* Quiz Specific Styling */
.quiz-question {
  font-weight: 600;
  margin-bottom: 1.25rem !important;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.quiz-opt {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--color-text-main);
  transition: var(--transition-fast);
}

.quiz-opt:hover {
  background-color: #FAF9F5;
  border-color: var(--color-text-muted);
  transform: translateX(4px);
}

.radio-indicator {
  min-width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--color-text-muted);
  display: inline-block;
  position: relative;
  margin-top: 2px;
}

.quiz-opt.selected .radio-indicator {
  border-color: var(--color-accent-dark);
}

.quiz-opt.selected .radio-indicator::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-accent-dark);
}

/* Quiz option states after check */
.quiz-opt.correct {
  background-color: var(--color-success-bg);
  border-color: var(--color-success);
  color: var(--color-success-text);
}

.quiz-opt.correct .radio-indicator {
  border-color: var(--color-success);
  background-color: var(--color-success);
}

.quiz-opt.correct .radio-indicator::after {
  content: "✓";
  color: #fff;
  font-size: 10px;
  font-weight: bold;
  position: absolute;
  top: -2px;
  left: 2px;
  background: none;
}

.quiz-opt.incorrect {
  background-color: #FEF2F2;
  border-color: #FCA5A5;
  color: #991B1B;
  opacity: 0.7;
}

.quiz-opt.incorrect .radio-indicator {
  border-color: #EF4444;
}

.quiz-feedback {
  margin-top: 1.25rem;
  padding: 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
}

.quiz-feedback.success {
  background-color: var(--color-success-bg);
  color: var(--color-success-text);
  border: 1px solid rgba(74, 222, 128, 0.2);
}

.quiz-feedback.error {
  background-color: #FEF2F2;
  color: #991B1B;
  border: 1px solid rgba(239, 68, 68, 0.1);
}

.hidden {
  display: none !important;
}

/* SECTION 2: FORMULATOR SPLIT LAYOUT */
.split-layout {
  grid-template-columns: 1.2fr 1fr;
  align-items: start;
}

.formulator-left {
  position: relative;
  min-height: 520px;
}

/* Wizard Specific Styling */
.question-desc {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  margin-bottom: 1.5rem !important;
}

.input-wrapper {
  position: relative;
  margin-top: 1rem;
}

.text-input {
  width: 100%;
  padding: 1.1rem 1.25rem;
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  font-family: var(--font-body);
  font-size: 1.05rem;
  color: var(--color-text-main);
  outline: none;
  transition: var(--transition-fast);
}

.text-input:focus {
  background-color: #FFFFFF;
  border-color: var(--color-accent-dark);
  box-shadow: 0 0 0 4px rgba(29, 53, 32, 0.05);
}

.prefix-padded {
  padding-left: 3rem;
}

.prefix-padded-large {
  padding-left: 7.8rem;
}

.prefix-label {
  position: absolute;
  left: 1.25rem;
  top: 1.15rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text-muted);
  pointer-events: none;
}

.input-char-limit {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--color-text-muted);
  display: block;
  margin-top: 0.5rem;
  margin-left: 0.25rem;
}

/* Difficulty Option Cards */
.difficulty-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.difficulty-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2rem 1.25rem;
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.difficulty-opt:hover {
  background-color: #FAF9F5;
  border-color: var(--color-text-muted);
  transform: translateY(-2px);
}

.difficulty-opt.selected {
  background-color: var(--color-success-bg);
  border-color: var(--color-accent-dark);
  box-shadow: var(--shadow-sm);
}

.opt-icon {
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
}

.opt-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-accent-dark);
  margin-bottom: 0.35rem;
}

.opt-desc {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* Glassmorphic Intercept Overlay */
.intercept-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(244, 244, 238, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 28px;
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2.25rem;
  animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.intercept-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Adjustments when Intercept Overlay is active */
#formulator-deck:has(#intercept-overlay:not(.hidden)) .deck-card.active {
  position: absolute;
  height: 100%;
}

#formulator-deck:has(#intercept-overlay:not(.hidden)) #intercept-overlay {
  position: relative;
  height: auto;
  min-height: max-content;
}

#formulator-deck:has(#intercept-overlay:not(.hidden)) .intercept-content {
  height: auto;
}

#formulator-deck:has(#intercept-overlay:not(.hidden)) .intercept-suggestion {
  height: auto;
  gap: 1rem;
}

/* Loader Animation */
.intercept-loading {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.coaching-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: var(--color-accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.avatar-letter {
  font-size: 1.75rem;
  z-index: 2;
}

.pulse-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--color-primary);
  animation: pulse 1.8s infinite ease-in-out;
  z-index: 1;
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    opacity: 0.8;
  }

  50% {
    transform: scale(1.4);
    opacity: 0;
  }

  100% {
    transform: scale(0.95);
    opacity: 0;
  }
}

.loading-subtext {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* Suggestion Card Display */
.intercept-suggestion {
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-between;
}

.suggestion-header {
  margin-bottom: 0.75rem;
}

.coach-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--color-accent-dark);
  background-color: var(--color-primary);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 0.5rem;
}

.suggestion-header h3 {
  font-size: 1.25rem;
}

.suggestion-comparison {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-right: 0.25rem;
}

.comparison-block {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.85rem;
}

.comparison-block.original {
  background-color: var(--color-bg);
  border: 1px dashed var(--color-border);
}

.comparison-block.suggested {
  background-color: var(--color-success-bg);
  border: 1px solid rgba(74, 222, 128, 0.25);
  font-weight: 500;
  color: var(--color-success-text);
}

.comparison-title {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--color-text-muted);
  display: block;
  margin-bottom: 0.25rem;
}

.suggestion-rationale {
  font-size: 0.8rem;
  background-color: rgba(29, 53, 32, 0.03);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border-left: 2px solid var(--color-text-muted);
  margin-bottom: 1rem;
}

.suggestion-rationale strong {
  display: block;
  margin-bottom: 0.15rem;
}

.suggestion-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  border-top: 1px solid rgba(29, 53, 32, 0.05);
  padding-top: 0.75rem;
}

.suggestion-actions .btn {
  padding: 0.6rem 1.1rem;
  font-size: 0.85rem;
}

/* STICKY LIVE PREVIEW CARD */
.sticky-preview-wrapper {
  position: sticky;
  top: 110px;
  max-width: 440px;
  margin: 0 auto;
}

.preview-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: var(--color-text-muted);
  display: block;
  margin-bottom: 0.75rem;
  text-align: center;
}

.plan-preview-card {
  background: #FFFDF9;
  /* Textured Warm White */
  border: 2px solid #EAE6DD;
  border-radius: 24px;
  padding: 2.25rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  color: #2E3B2F;
}

.plan-preview-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 8px;
  background-color: var(--color-accent-dark);
}

/* Certificate Seal */
.seal-container {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  width: 76px;
  height: 76px;
  opacity: 0.15;
  pointer-events: none;
}

.seal-svg {
  width: 100%;
  height: 100%;
  animation: rotateSeal 20s linear infinite;
}

@keyframes rotateSeal {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.seal-svg text {
  font-family: var(--font-mono);
  font-size: 7.8px;
  font-weight: 700;
  fill: var(--color-accent-dark);
}

.seal-logo {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--color-accent-dark);
}

/* Preview Content */
.preview-header {
  border-bottom: 1px dashed #D6D2C4;
  padding-bottom: 0.75rem;
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preview-mono-title {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.preview-date {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--color-text-muted);
}

.preview-section {
  margin-bottom: 1.25rem;
}

.preview-section-title {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  display: block;
  margin-bottom: 0.4rem;
}

.preview-goal-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-accent-dark);
}

.highlight-border {
  border-top: 1px solid #EAE6DD;
  border-bottom: 1px solid #EAE6DD;
  padding: 1rem 0;
}

.compiled-formula {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--color-accent-dark);
}

.p-kw {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  display: block;
  margin-bottom: 0.15rem;
}

.p-val {
  font-weight: 600;
  color: var(--color-accent-dark);
  border-bottom: 1.5px dashed var(--color-border);
  padding: 0 0.1rem;
  display: inline-block;
  line-height: 1.2;
}

.small-formula {
  font-size: 0.9rem;
}

.plan-preview-card.contract-signed {
  border-color: #2E5232;
  box-shadow: 0 10px 25px rgba(46, 82, 50, 0.05);
}

.plan-preview-card.contract-signed::after {
  content: "APPROVED";
  position: absolute;
  bottom: 2.2rem;
  left: 2rem;
  transform: rotate(-12deg);
  border: 3px double var(--color-success);
  color: var(--color-success);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.4rem;
  padding: 0.2rem 1rem;
  letter-spacing: 0.1em;
  opacity: 0.95;
  pointer-events: none;
  border-radius: 6px;
}

.preview-footer {
  border-top: 1px dashed #D6D2C4;
  padding-top: 1rem;
  margin-top: 1.5rem;
}

.footer-note {
  font-size: 0.7rem;
  font-style: italic;
  color: var(--color-text-muted);
  line-height: 1.3;
  margin-bottom: 1rem;
}

.signature-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.signature-label {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: var(--color-text-muted);
}

.signature-val {
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
  font-weight: 700;
  color: #166534;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* POST-FORMULATION ACTIVE COACHING DASHBOARD */
.coach-dashboard {
  animation: fadeIn 0.4s ease forwards;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
}

.dashboard-header h2 {
  font-size: 1.4rem;
}

.icon-refresh {
  animation: none;
}

.btn-small:hover .icon-refresh {
  animation: rotateInfinite 1.5s linear infinite;
}

@keyframes rotateInfinite {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* System Prompt Accordion */
.system-prompt-accordion {
  border: 1px solid var(--color-border);
  background-color: rgba(29, 53, 32, 0.02);
  border-radius: 16px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.accordion-toggle {
  width: 100%;
  background: none;
  border: none;
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-text-main);
  transition: var(--transition-fast);
}

.accordion-toggle:hover {
  background-color: rgba(29, 53, 32, 0.04);
}

.accordion-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.accordion-arrow {
  font-size: 0.7rem;
  transition: transform 0.3s ease;
  color: var(--color-text-muted);
}

.system-prompt-accordion.open .accordion-arrow {
  transform: rotate(180deg);
}

.accordion-content {
  padding: 0 1.25rem 1.25rem 1.25rem;
  border-top: 1px solid var(--color-border);
  animation: slideDown 0.3s ease forwards;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.accordion-desc {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

.code-box {
  position: relative;
  background-color: var(--color-accent-dark);
  border-radius: 12px;
  padding: 1rem 3.5rem 1rem 1rem;
}

.code-box pre {
  margin: 0;
  overflow-x: auto;
}

.code-box code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
  white-space: pre-wrap;
  word-break: break-all;
}

.btn-copy {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background-color: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-copy:hover {
  background-color: rgba(255, 255, 255, 0.25);
}

.btn-copy.copied {
  background-color: var(--color-success);
  color: var(--color-accent-dark);
}

/* CHATBOT CONTAINER */
.chatbot-container {
  background: var(--color-card-bg);
  border-radius: 24px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  height: 380px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  padding: 0.9rem 1.25rem;
  background-color: var(--color-accent-dark);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chat-avatar {
  font-size: 1.25rem;
  background-color: rgba(255, 255, 255, 0.1);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-title-info h3 {
  color: #fff;
  font-size: 0.95rem;
}

.api-status-badge {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.15rem;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.status-label {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: rgba(255, 255, 255, 0.5);
  font-weight: 700;
  text-transform: uppercase;
}

.api-status-badge.online .status-dot {
  background-color: var(--color-success);
  box-shadow: 0 0 8px var(--color-success);
}

.api-status-badge.online .status-label {
  color: rgba(255, 255, 255, 0.85);
}

.api-status-badge.offline .status-dot {
  background-color: var(--color-warning);
  box-shadow: 0 0 8px var(--color-warning);
}

.api-status-badge.offline .status-label {
  color: rgba(255, 255, 255, 0.85);
}

.chat-messages {
  flex-grow: 1;
  padding: 1.25rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background-color: rgba(29, 53, 32, 0.08);
  border-radius: 4px;
}

.msg {
  max-width: 82%;
  padding: 0.75rem 1rem;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.5;
  animation: messageEnter 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes messageEnter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg-assistant {
  background-color: var(--color-bg);
  color: var(--color-text-main);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.msg-user {
  background-color: var(--color-accent-dark);
  color: var(--color-primary);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}

.msg-system {
  background-color: var(--color-warning-bg);
  border: 1px dashed rgba(245, 158, 11, 0.2);
  color: var(--color-warning-text);
  max-width: 95%;
  align-self: center;
  border-radius: 12px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-align: center;
}

/* Typing Bubble Indicator */
.typing-bubble {
  display: flex;
  gap: 4px;
  padding: 0.85rem 1.1rem;
  align-items: center;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background-color: var(--color-text-muted);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {

  0%,
  100%,
  80% {
    transform: translateY(0);
  }

  40% {
    transform: translateY(-5px);
  }
}

.chat-input-area {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 0.75rem;
}

.chat-text-input {
  flex-grow: 1;
  border: 1px solid var(--color-border);
  border-radius: 9999px;
  padding: 0.6rem 1.25rem;
  outline: none;
  font-family: var(--font-body);
  font-size: 0.9rem;
  background-color: var(--color-bg);
  transition: var(--transition-fast);
}

.chat-text-input:focus {
  background-color: #fff;
  border-color: var(--color-accent-dark);
}

.chat-send-btn {
  background-color: var(--color-accent-dark);
  color: var(--color-primary);
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.chat-send-btn:hover {
  background-color: #233e26;
  transform: scale(1.05);
}

.icon-send {
  width: 16px;
  height: 16px;
  margin-left: 2px;
}

/* SECTION 3: HELPERS PREVIEW GRID */
.helpers-intro {
  max-width: 680px;
  margin: 0 auto 3rem auto;
  text-align: center;
}

.helpers-intro p {
  font-size: 1.05rem;
  color: var(--color-text-muted);
}

.helpers-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
}

.helper-card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 24px;
  padding: 2.25rem;
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: var(--transition-smooth);
}

.helper-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
}

.helper-card.locked {
  opacity: 0.75;
}

.helper-status-badge {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-warning-text);
  background-color: var(--color-warning-bg);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.helper-icon {
  font-size: 2.25rem;
  margin-bottom: 1.25rem;
}

.helper-card h3 {
  font-size: 1.25rem;
  margin-bottom: 0.35rem;
}

.helper-theory {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  margin-bottom: 1.25rem;
}

.helper-formula-demo {
  background-color: var(--color-bg);
  padding: 0.85rem;
  border-radius: 12px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.5;
  margin-bottom: 1.25rem;
  color: var(--color-text-main);
  border-left: 3px solid var(--color-border);
}

.helper-formula-demo .highlight {
  font-weight: 700;
  color: var(--color-accent-dark);
}

.helper-desc {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* NATIVE DIALOG WINDOW STYLING */
.app-dialog {
  border: none;
  border-radius: 24px;
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--color-card-bg);
  box-shadow: 0 25px 50px -12px rgba(29, 53, 32, 0.25);
  outline: none;
  z-index: 200;
}

.app-dialog::backdrop {
  background-color: rgba(29, 53, 32, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: backdropFadeIn 0.3s ease forwards;
}

@keyframes backdropFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.75rem;
}

.dialog-header h2 {
  font-size: 1.35rem;
}

.dialog-close-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0.25rem;
  transition: var(--transition-fast);
}

.dialog-close-btn:hover {
  color: var(--color-text-main);
}

.dialog-body {
  margin-bottom: 1.5rem;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 1rem 0 1.15rem;
}

.preset-btn {
  min-height: 4rem;
  align-items: flex-start;
  justify-content: center;
  padding: 0.8rem 0.9rem;
  text-align: left;
  line-height: 1.1;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

.preset-btn span {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-text-main);
}

.preset-btn small {
  display: block;
  margin-top: 0.25rem;
  color: var(--color-text-muted);
  font-size: 0.72rem;
  line-height: 1.2;
}

.preset-btn:hover {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 10px 20px rgba(29, 53, 32, 0.08);
}

.settings-form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.settings-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
}

.settings-desc {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

.field-hint {
  margin-top: 0.1rem;
  font-size: 0.74rem;
  line-height: 1.35;
  color: var(--color-text-muted);
}

.inline-code {
  display: inline-block;
  padding: 0.08rem 0.35rem;
  border-radius: 999px;
  background: rgba(120, 145, 126, 0.14);
  color: var(--color-text-main);
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.key-input-wrapper {
  display: flex;
  gap: 0.5rem;
}

.key-input-wrapper .text-input {
  padding: 0.8rem 1rem;
  font-size: 0.95rem;
  font-family: var(--font-mono);
}

.api-links {
  margin-top: 0.25rem;
}

.external-link {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-decoration: underline;
  transition: var(--transition-fast);
}

.external-link:hover {
  color: var(--color-accent-dark);
}

.settings-status-box {
  background-color: var(--color-bg);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
}

.status-text.text-neutral {
  color: var(--color-text-muted);
}

.status-text.text-success {
  color: var(--color-success-text);
  font-weight: bold;
}

.status-text.text-error {
  color: #991B1B;
  font-weight: bold;
}

.dialog-footer {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--color-border);
  padding-top: 1.25rem;
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--color-toast-bg);
  color: var(--color-toast-text);
  padding: 0.8rem 1.6rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: toastPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.25) forwards;
}

@keyframes toastPop {
  from {
    bottom: 1rem;
    opacity: 0;
  }

  to {
    bottom: 2rem;
    opacity: 1;
  }
}

/* Responsive Scaling */
@media (max-width: 992px) {
  .section-container {
    grid-template-columns: 1fr;
    gap: 3rem;
  }

  .info-sidebar {
    max-width: 100%;
    text-align: center;
    margin: 0 auto;
  }

  .deck-controls-hint {
    justify-content: center;
  }

  .sticky-preview-wrapper {
    position: static;
    max-width: 100%;
  }

  .helpers-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

@media (max-width: 768px) {
  .header-container {
    flex-direction: column;
    gap: 1.25rem;
    padding: 1rem;
  }

  .app-main-content {
    padding: 1.5rem 1rem 4rem 1rem;
  }

  .difficulty-options {
    grid-template-columns: 1fr;
  }

  .deck-card {
    padding: 1.5rem;
  }
}

/* --- Redesign and Intro Slideshow additions --- */
.intro-slideshow-container {
  max-width: 680px;
  margin: 4rem auto;
  position: relative;
}

.intro-slide {
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  display: none;
  flex-direction: column;
  justify-content: flex-start;
  min-height: auto;
}

.intro-slide h2 {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 1.5rem;
  font-family: var(--font-display);
  color: var(--color-accent-dark);
}

.intro-slide p {
  font-size: 1.2rem;
  line-height: 1.8;
  color: var(--color-text-main);
  opacity: 0.95;
  margin-bottom: 2.5rem;
}

.intro-slide.active {
  display: flex;
  animation: fadeIn 0.4s ease forwards;
}

.slide-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(29, 53, 32, 0.08);
  padding-top: 1.5rem;
}
  border-top: 1px solid rgba(29, 53, 32, 0.05);
  padding-top: 1.5rem;
  margin-top: 2rem;
}

.slide-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* Dashboard Sidebar Toggle & 2/3 Layout */
#practice-wizard-view.dashboard-active {
  grid-template-columns: 2fr 1fr;
}

#practice-wizard-view.hide-sidebar {
  grid-template-columns: 1fr;
}

#practice-wizard-view.hide-sidebar .formulator-right {
  display: none;
}

/* Adjust Chat Messages Area Height */
.chatbot-container {
  height: 420px;
}

/* Key settings toggle prompt styling inside Dialog */
.app-dialog .system-prompt-accordion {
  border: 1px solid var(--color-border);
  background-color: rgba(29, 53, 32, 0.02);
  border-radius: 16px;
  overflow: hidden;
}