:root {
  /* Colour tokens -- --primary-* is the one thing this app customises */
  --primary-color: #228c4f;
  --primary-hover: #176b3a;
  --secondary-color: #f4cf3a;
  --secondary-hover: #d8ae18;
  --success-color: #2f9e54;
  --success-hover: #247842;
  --danger-color: #e74c3c;
  --danger-hover: #c0392b;
  --text-dark: #173122;
  --text-light: #385443;
  --text-muted: #70806f;
  --input-bg: #f1f6e8;
  --container-bg-color: #ffffff;
  --main-bg-color: #f7f8ee;
  --gradient-start: #d9f2b6;
  --gradient-end: #fff2a6;
  --border-soft: #d8e6c1;
  --border-input: #b8c7a6;
  --font-sans: 'Google Sans', 'Roboto Flex', 'Inter', 'Roboto', 'Segoe UI', sans-serif;

  /* Structural tokens -- fixed across the TeachSmarts family */
  --radius-input: 8px;
  --radius-button: 8px;
  --radius-card: 16px;
  --radius-modal: 18px;
  --radius-pill: 999px;

  --space-xs: 6px;
  --space-sm: 10px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  --control-height: 44px;
  --width-app-max: 960px;
  --width-wizard-max: 900px;
  --width-landing-max: 1320px;
  --width-legal-max: 860px;

  --shadow-card: 0 12px 36px rgba(0, 0, 0, .08);
  --shadow-card-soft: 0 4px 20px rgba(0, 0, 0, .06);
  --shadow-hover-lift: 0 6px 14px rgba(0, 0, 0, .08);
  --shadow-modal: 0 28px 80px rgba(15, 23, 42, .28);

  --font-size-page-title: 2rem;
  --font-size-section: 1.5rem;
  --font-size-card-title: 1.125rem;
  --font-size-body: 1rem;
  --font-size-control: 1em;
  --font-size-helper: 0.875rem;

  --transition-fast: 0.2s ease;
  --transition-lift: 0.15s ease;

  --z-dropdown: 10;
  --z-sticky-nav: 100;
  --z-modal: 9999;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: var(--font-sans);
  color: var(--text-dark);
  background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
  min-height: 100vh;
}
h1, h2, h3, h4 { font-family: var(--font-sans); color: var(--text-dark); }
p { line-height: 1.6; }
a { color: var(--primary-color); }
.hidden { display: none !important; }

.page-frame { min-height: 100vh; }

/* --- Buttons --- */

.btn {
  background: var(--primary-color);
  color: #fff;
  font-weight: bold;
  font-size: var(--font-size-control);
  border: none;
  border-radius: var(--radius-button);
  padding: 15px 30px;
  min-height: var(--control-height);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}
.btn:hover:not([disabled]) { background: var(--primary-hover); }
.btn[disabled] { background: #bdc3c7; cursor: not-allowed; }

.btn-secondary { background: var(--secondary-color); color: var(--text-dark); }
.btn-secondary:hover:not([disabled]) { background: var(--secondary-hover); }

.btn-danger { background: var(--danger-color); }
.btn-danger:hover:not([disabled]) { background: var(--danger-hover); }

.btn-small { padding: var(--space-sm) var(--space-md); min-height: 36px; font-size: var(--font-size-helper); }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-sm); align-items: center; }

.button-group { display: flex; flex-wrap: wrap; gap: var(--space-sm); align-items: stretch; width: 100%; }
.selectable-btn {
  background: var(--input-bg);
  color: var(--text-light);
  border: 2px solid #bdc3c7;
  border-radius: var(--radius-button);
  padding: var(--space-md) var(--space-lg);
  text-align: center;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex: 1;
}
.selectable-btn.checked { background: var(--primary-color); color: #fff; border-color: var(--primary-hover); }

/* --- Inputs --- */

label { display: block; margin-bottom: var(--space-xs); font-weight: 700; color: var(--text-light); font-size: var(--font-size-helper); }
.form-group { margin-bottom: var(--space-md); }
.form-group.compact { margin-bottom: var(--space-sm); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }

input[type="text"], input[type="number"], input[type="date"], input[type="time"], select, textarea {
  width: 100%;
  padding: 15px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-input);
  background: var(--input-bg);
  font-size: var(--font-size-body);
  font-family: var(--font-sans);
  color: var(--text-dark);
}
textarea { min-height: 120px; resize: vertical; }

.helper-text { color: var(--text-muted); font-size: var(--font-size-helper); margin-bottom: var(--space-sm); }

/* --- Card / app container --- */

.card {
  background: var(--container-bg-color);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card-soft);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
}

.app-container {
  background: var(--container-bg-color);
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: var(--space-lg);
  max-width: var(--width-app-max);
  margin: 30px auto;
}

.center-content { max-width: var(--width-wizard-max); margin-left: auto; margin-right: auto; }

.app-section { padding: var(--space-md) 0; border-top: 1px solid var(--border-soft); }
.app-section:first-of-type { border-top: none; padding-top: 0; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.user-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}
.user-email { color: var(--text-muted); font-size: var(--font-size-helper); }

.target-badge { color: var(--primary-color); font-weight: 700; font-size: var(--font-size-helper); }

.class-picker-section { max-width: var(--width-wizard-max); margin: 0 auto; }
.course-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-md); }
.course-card {
  min-height: 120px;
  padding: var(--space-lg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-input);
  background: #fff;
  color: var(--text-dark);
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-card-soft);
  transition: transform var(--transition-lift), box-shadow var(--transition-lift), border-color var(--transition-fast);
}
.course-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary-color);
  box-shadow: var(--shadow-hover-lift);
}
.course-card strong { display: block; margin-bottom: var(--space-sm); font-size: 1.1rem; overflow-wrap: anywhere; }
.course-card span { color: var(--text-muted); font-size: var(--font-size-helper); }

.workspace-toolbar {
  max-width: var(--width-wizard-max);
  margin: 0 auto var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}
.workspace-kicker {
  display: block;
  color: var(--text-muted);
  font-size: var(--font-size-helper);
  font-weight: 700;
  text-transform: uppercase;
}
.workspace-toolbar h1 { font-size: 1.75rem; overflow-wrap: anywhere; }
.inline-toggle { display: inline-flex; align-items: center; gap: var(--space-xs); margin: 0; font-size: var(--font-size-helper); }
.inline-toggle input { width: auto; }

/* --- Status box --- */

.status-box {
  margin-top: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-input);
  text-align: center;
  font-size: 1.1em;
  background: #edf9ee;
  border: 1px solid #bbe4c0;
  color: #125a2f;
}
.status-box-error, .status-box.error {
  background: #fdedec;
  border: 1px solid #fadbd8;
  color: var(--danger-hover);
}

/* --- Lesson composer --- */

.draft-posts-list, .lessons-container { display: grid; gap: var(--space-sm); }
.draft-post-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-input);
  cursor: grab;
}
.draft-post-row:active { cursor: grabbing; }
.draft-order {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--input-bg);
  color: var(--text-dark);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.lesson-card {
  background: var(--container-bg-color);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-card);
  padding: var(--space-lg);
}
.lesson-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}
.selected-files-list { display: grid; gap: var(--space-sm); min-height: 24px; }
.attachment-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-input);
  background: var(--input-bg);
}
.attachment-controls { display: flex; gap: var(--space-sm); align-items: center; }
.attachment-controls select { width: auto; padding: var(--space-xs) var(--space-sm); }
.remove-attachment-btn {
  border: 0;
  background: transparent;
  color: var(--danger-color);
  font-weight: 700;
  cursor: pointer;
}

/* --- Confirmation grid --- */

.confirmation-grid {
  overflow-y: auto;
  max-height: 80vh;
  padding: 0 var(--space-sm);
  margin: 0 calc(var(--space-sm) * -1);
  scrollbar-width: none;
}
.confirmation-grid::-webkit-scrollbar { display: none; }
.confirm-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-md);
  padding: 18px 5px;
  border-bottom: 1px solid var(--border-soft);
}
.confirm-row:last-child { border-bottom: none; }
.confirm-row p { margin: 0; font-size: 1.1em; color: var(--text-dark); flex: 1; text-align: left; }
.confirm-row strong { color: var(--text-light); }
.edit-btn {
  background: none;
  border: none;
  color: var(--primary-color);
  font-weight: bold;
  font-size: 0.9em;
  text-decoration: underline;
  padding: 5px;
  cursor: pointer;
  white-space: nowrap;
}
.confirmation-actions { margin-top: var(--space-md); justify-content: flex-end; }

/* --- Drive browser --- */

.drive-browser {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-input);
  overflow: hidden;
}
.drive-browser-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
  background: #f5f5f5;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-soft);
}
.drive-nav-label { color: var(--text-light); font-size: var(--font-size-helper); font-weight: 600; }
.drive-browser-list { max-height: 250px; overflow-y: auto; background: var(--container-bg-color); }
.drive-item {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-soft);
  cursor: default;
}
.drive-item:last-child { border-bottom: none; }
.drive-item.folder { cursor: pointer; }
.drive-item.folder:hover { background: var(--input-bg); }
.drive-file-label { display: flex; align-items: center; gap: var(--space-sm); width: 100%; cursor: pointer; }

/* --- Existing posts / topics --- */

.existing-posts-list, .topics-list { display: grid; gap: var(--space-sm); }
.existing-post-item, .topic-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--container-bg-color);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-input);
}
.existing-post-main {
  display: flex;
  flex: 1 1 320px;
  flex-direction: column;
  gap: var(--space-xs);
  min-width: 0;
}
.existing-post-main strong {
  color: var(--text-dark);
  overflow-wrap: anywhere;
  word-break: normal;
}
.existing-post-main span { color: var(--text-muted); font-size: var(--font-size-helper); }
.existing-post-controls, .topic-item-controls { display: flex; gap: var(--space-sm); align-items: center; flex-wrap: wrap; }
.existing-post-controls { flex: 0 0 auto; justify-content: flex-end; min-width: min(100%, 460px); }
.existing-post-controls select { width: 280px; max-width: 100%; min-width: 180px; padding: var(--space-xs) var(--space-sm); }
.existing-post-controls .btn { flex: 0 0 auto; }

.new-topic-row { display: flex; gap: var(--space-sm); margin-bottom: var(--space-md); }
.new-topic-row input { flex: 1; }

/* --- Modals --- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(17, 24, 39, .42);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}
.modal-card {
  background: #fff;
  border-radius: var(--radius-modal);
  box-shadow: var(--shadow-modal);
  padding: var(--space-lg);
  max-height: 88vh;
  overflow-y: auto;
}
.draft-modal, .class-config-modal { width: min(720px, 100%); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-sm); margin-top: var(--space-lg); }
.class-day-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(94px, 1fr)); gap: var(--space-sm); max-height: 360px; overflow-y: auto; padding-right: var(--space-xs); }
.day-card {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-input);
  background: var(--input-bg);
  color: var(--text-light);
  padding: var(--space-sm);
  cursor: pointer;
  display: grid;
  gap: 2px;
  text-align: left;
}
.day-card.selected {
  background: var(--primary-color);
  border-color: var(--primary-hover);
  color: #fff;
}
.day-card span { font-size: var(--font-size-helper); }
.confirmation-modal { width: min(480px, 100%); text-align: center; }
.logout-confirmation-title { margin: 0 0 10px; font-size: 1.5rem; font-weight: 700; color: var(--text-dark); }
.logout-confirmation-copy { margin: 0; color: var(--text-light); font-size: 1.05rem; line-height: 1.6; }
.logout-confirmation-actions { display: flex; justify-content: center; gap: var(--space-sm); margin-top: var(--space-lg); }
.logout-confirmation-actions .btn { min-width: 160px; }

/* --- Loading / results --- */

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 248, 255, .92);
}
.page-loading { display: flex; align-items: center; justify-content: center; min-height: 40vh; color: var(--text-muted); }
.results-panel { text-align: center; padding: var(--space-2xl) var(--space-lg); }
.results-links { display: flex; flex-direction: column; gap: var(--space-sm); align-items: center; margin: var(--space-lg) 0; }

/* --- Landing page --- */

#auth-panel {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(217, 242, 182, .96), rgba(255, 242, 166, .92)),
    radial-gradient(circle at 18% 12%, rgba(34, 140, 79, .18), transparent 34%),
    radial-gradient(circle at 82% 20%, rgba(244, 207, 58, .2), transparent 32%);
}

.landing-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 40px;
}
.landing-header-brand { font-family: var(--font-sans); font-weight: 700; font-size: 1.5rem; color: var(--text-dark); }

.landing-shell {
  display: flex;
  max-width: var(--width-landing-max);
  margin: 0 auto;
  padding: 40px;
  gap: 50px;
  align-items: center;
}
.landing-left, .landing-right { flex: 1; }
.landing-left { display: flex; flex-direction: column; align-items: center; text-align: center; padding-right: 40px; }
.landing-right { display: flex; flex-direction: column; align-items: flex-start; padding-left: 40px; gap: var(--space-md); }
.landing-right h2 { width: 100%; margin-bottom: var(--space-xs); text-align: center; }

.landing-logo { width: 350px; height: 350px; object-fit: contain; display: block; margin: 0 auto var(--space-md); }
.landing-left h1 { font-size: 1.5rem; margin-bottom: var(--space-sm); }
.landing-tagline { font-size: 1.5rem; color: var(--text-light); margin-bottom: var(--space-lg); max-width: 580px; }

.feature-box {
  background: #fff;
  border-radius: var(--radius-input);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-card-soft);
  font-size: 1.1rem;
  width: 100%;
  transition: transform var(--transition-lift), box-shadow var(--transition-lift);
}
.feature-box:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover-lift); }
.feature-box h3 { margin-bottom: var(--space-xs); color: var(--text-dark); }
.feature-box p { color: var(--text-light); font-size: 1.1rem; }

.landing-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 16px 40px 24px;
}
.landing-footer a { color: var(--primary-color); margin: 0 6px; text-decoration: none; }
.landing-footer a:hover { text-decoration: underline; }

/* --- Legal pages --- */

.legal-page { min-height: 100vh; }
.legal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 40px;
}
.legal-back-link { color: var(--primary-color); font-size: var(--font-size-helper); text-decoration: none; }
.legal-card {
  max-width: var(--width-legal-max);
  margin: 0 auto 40px;
  background: var(--container-bg-color);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card-soft);
  padding: 40px 44px 48px;
}
.legal-card h1 { font-size: 2rem; margin-bottom: var(--space-lg); }
.legal-card h2 { font-size: 1.25rem; margin: var(--space-lg) 0 var(--space-sm); }
.legal-card p { font-size: 1rem; line-height: 1.6; color: var(--text-light); margin-bottom: var(--space-sm); }
.legal-draft-notice {
  background: var(--input-bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-input);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-helper);
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
}
.legal-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 16px 40px 24px;
}
.legal-footer a { color: var(--primary-color); margin: 0 6px; }

/* --- Responsive --- */

@media (max-width: 1100px) {
  .landing-shell { flex-direction: column; }
  .landing-left, .landing-right { padding-left: 0; padding-right: 0; }
}

@media (max-width: 768px) {
  .app-container { border-radius: var(--radius-card); padding: var(--space-md); margin: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .user-info-row, .section-header, .workspace-toolbar, .draft-post-row { flex-direction: column; align-items: stretch; }
  .existing-post-controls { justify-content: flex-start; min-width: 0; }
  .existing-post-controls select { width: 100%; }
}

@media (max-width: 640px) {
  .landing-header, .legal-header { padding: 20px; }
  .legal-card { margin: 0 16px 40px; padding: 28px 20px 32px; }
}
