/* ── Shared App Theme ───────────────────────────────────────────
   Imported by all inner pages. Overrides :root variables to match
   the landing page warm palette and injects the sticky app-nav.
   ─────────────────────────────────────────────────────────────── */

/* Font (same as landing page) */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

/* ── CSS Variable Overrides ─────────────────────────────────────
   These beat the :root blocks in page-specific <style> tags because
   shared.css is loaded AFTER the inline <style> via <link>.       */
:root {
  --bg:            #fdf8f3;
  --surface:       #ffffff;
  --surface-warm:  #f5f0e8;
  --border:        #d0d0d0;
  --text:          #1a1a1a;
  --text-muted:    #4a4a4a;
  --primary:       #1a1a1a;
  --primary-dark:  #000000;
  --primary-light: #f5f0e8;
  --accent:        #32cd32;
  --counselor-bg:  #f5f0e8;
  --student-bg:    #1a1a1a;
  --student-text:  #fdf8f3;
  --font: 'JetBrains Mono', monospace;
}

/* ── Dark Mode ──────────────────────────────────────────────────── */
html.theme-dark {
  --bg:            #1a1a1a;
  --surface:       #2a2a2a;
  --surface-warm:  #333333;
  --border:        #4a4a4a;
  --text:          #fdf8f3;
  --text-muted:    #d0d0d0;
  --primary:       #fdf8f3;
  --primary-dark:  #ffffff;
  --primary-light: #333333;
  --counselor-bg:  #2a2a2a;
  --student-bg:    #fdf8f3;
  --student-text:  #1a1a1a;
}

/* ── Base font ──────────────────────────────────────────────────── */
body { font-family: var(--font) !important; }

/* ── Dark mode button fixes ─────────────────────────────────────
   In dark mode --primary is cream (#fdf8f3), so btn-primary gets a
   cream background — but its text is hardcoded #fff, making it
   invisible. Switch to green accent with dark text instead.       */
html.theme-dark .btn-primary {
  background: var(--accent) !important;
  color: #1a1a1a !important;
}
html.theme-dark .btn-primary:hover:not(:disabled) {
  background: #28b428 !important;
  color: #1a1a1a !important;
}
/* btn-secondary hover: default goes to --primary bg + white text, both light in dark mode */
html.theme-dark .btn-secondary:hover {
  background: var(--accent) !important;
  color: #1a1a1a !important;
  border-color: var(--accent) !important;
}
/* cta-reviewer hover uses --primary bg + white text */
html.theme-dark .btn-cta-reviewer:hover {
  background: var(--accent) !important;
  color: #1a1a1a !important;
  border-color: var(--accent) !important;
}

/* ── Assessment-page hero recolour ──────────────────────────────
   Beats the hardcoded #1e40af/#3b82f6 gradient in inline <style>.  */
.hero {
  background: linear-gradient(135deg, var(--surface-warm) 0%, var(--bg) 100%) !important;
  color: var(--text) !important;
}
.hero h1, .hero p { color: var(--text) !important; }
.hero-back {
  color: var(--text-muted) !important;
  text-decoration: none;
}
.hero-back:hover { color: var(--text) !important; }

/* ── App Nav ────────────────────────────────────────────────────── */
.app-nav {
  background: var(--surface-warm);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
  backdrop-filter: blur(10px);
}

.app-nav-inner {
  padding: 0 28px 0 9px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 52px;
  gap: 1rem;
}

.app-nav-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
  font-family: var(--font);
  flex-shrink: 0;
}
.app-nav-logo-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent);
  color: #08130c;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px -4px rgba(50, 205, 50, 0.45);
}
.app-nav-logo-mark svg { width: 13px; height: 13px; }

.app-nav-right {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.app-nav-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font);
}

.app-nav-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  object-fit: cover;
}

.app-nav-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  transition: border-color 0.2s ease, color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  min-width: 28px;
  white-space: nowrap;
}
.app-nav-btn:hover {
  border-color: var(--text);
  color: var(--text);
}

/* ── User dropdown menu ─────────────────────────────────────────── */
.app-nav-user-menu {
  position: relative;
}

.app-nav-user-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 8px 0 6px;
  height: 28px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  transition: border-color 0.2s ease, color 0.2s ease;
}
.app-nav-user-trigger:hover {
  border-color: var(--text);
  color: var(--text);
}

.app-nav-caret {
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.app-nav-user-trigger[aria-expanded="true"] .app-nav-caret {
  transform: rotate(180deg);
}

.app-nav-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 150px;
  background: var(--surface-warm);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 1001;
}
.app-nav-dropdown[hidden] { display: none; }

.app-nav-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 5px;
  padding: 8px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  text-decoration: none;
  white-space: nowrap;   /* never wrap an item; the menu widens to fit the longest one */
  transition: background 0.15s ease, color 0.15s ease;
}
.app-nav-dropdown-item:hover {
  background: var(--surface);
  color: var(--text);
}

@media (max-width: 500px) {
  .app-nav-user span { display: none; }
  .app-nav-btn[data-label] { font-size: 0; }
}

.app-nav-dropdown-sep { height: 1px; background: var(--border); margin: 4px 2px; }

/* ── Share-my-essays modal (injected by shared.js) ──────────────────
   Self-contained, te- prefixed so it never collides with page styles.  */
.te-modal-overlay {
  position: fixed; inset: 0; z-index: 4000;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 7vh 1rem 1rem;
}
.te-modal-overlay[hidden] { display: none; }
.te-modal {
  width: 100%; max-width: 520px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  overflow: hidden; font-family: var(--font);
}
.te-modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; padding: 1.1rem 1.25rem 0.9rem; border-bottom: 1px solid var(--border);
}
.te-modal-title { font-size: 1rem; font-weight: 800; color: var(--text); }
.te-modal-title small { display: block; font-weight: 500; font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }
.te-modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.2rem; line-height: 1; cursor: pointer; }
.te-modal-close:hover { color: var(--text); }
.te-modal-body { padding: 1.1rem 1.25rem 1.25rem; }

.te-share-row { display: flex; gap: 0.5rem; }
.te-field { flex: 1; min-width: 0; }
.te-field-rel { flex: 0 0 170px; max-width: 170px; }
.te-field-label { display: block; font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 6px; }
.te-input, .te-select {
  font-family: var(--font); font-size: 0.8rem; width: 100%; height: 38px;
  padding: 0 0.7rem; border: 1px solid var(--border); border-radius: 7px;
  background: var(--bg); color: var(--text); outline: none;
}
.te-input:focus, .te-select:focus { border-color: var(--accent); }
.te-input::placeholder { color: var(--text-muted); }
.te-field-hint { font-size: 0.66rem; color: var(--text-muted); margin-top: 6px; line-height: 1.5; }
.te-field-hint.err { color: #d33; }
html.theme-dark .te-field-hint.err { color: #e08a8a; }

.te-share-actions { display: flex; justify-content: flex-end; margin-top: 0.9rem; }
.te-btn { font-family: var(--font); font-size: 0.78rem; font-weight: 600; border-radius: 6px; padding: 0 1rem; height: 36px; cursor: pointer; border: 1px solid transparent; }
.te-btn-primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.te-btn-primary:hover:not(:disabled) { background: #000; }
.te-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
html.theme-dark .te-btn-primary { background: var(--accent); color: #10240f; border-color: var(--accent); }
html.theme-dark .te-btn-primary:hover:not(:disabled) { background: #28b428; }

.te-share-list-title { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin: 1.4rem 0 0.6rem; }
.te-reviewer-row { display: flex; align-items: center; gap: 0.7rem; padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); margin-bottom: 0.5rem; }
.te-avatar { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 800; background: var(--accent); color: #10240f; }
.te-reviewer-meta { flex: 1; min-width: 0; }
.te-reviewer-email { font-size: 0.78rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.te-reviewer-rel { font-size: 0.66rem; color: var(--text-muted); }
.te-icon-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.95rem; padding: 4px; border-radius: 5px; flex-shrink: 0; }
.te-icon-btn:hover { color: #d33; background: rgba(221, 51, 51, 0.08); }
html.theme-dark .te-icon-btn:hover { color: #ffb4b4; background: rgba(224, 138, 138, 0.12); }

/* ── Credits & Usage popup ──────────────────────────────────────── */
.te-credits-modal { max-width: 480px; max-height: 85vh; display: flex; flex-direction: column; }
.te-credits-body { overflow-y: auto; flex: 1; padding: 0; }

.tc-sect { font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-muted); font-weight: 700; padding: 0 1.25rem; margin: 16px 0 8px; display: block; }
.tc-divider { border: none; border-top: 1px solid var(--border); margin: 18px 1.25rem 0; }
.tc-loading { padding: 36px; text-align: center; color: var(--text-muted); font-size: 12px; }

.tc-banner { font-size: 11px; padding: 10px 1.25rem; line-height: 1.5; }
.tc-banner-warn { background: #fff4e6; border-bottom: 1px solid #f0c98a; color: #7a4a00; }
.tc-banner-danger { background: #fdecec; border-bottom: 1px solid #f0a3a3; color: #991b1b; }
html.theme-dark .tc-banner-warn { background: #2a1f00; border-bottom-color: #6b4e00; color: #f0c060; }
html.theme-dark .tc-banner-danger { background: #200808; border-bottom-color: #7a2020; color: #f08080; }

.tc-bal-hero { margin: 12px 1.25rem 0; background: linear-gradient(135deg, var(--surface-warm), var(--surface)); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.tc-bal-label { font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); font-weight: 700; margin-bottom: 3px; }
.tc-bal-amount { font-size: 1.9rem; font-weight: 800; letter-spacing: -1px; line-height: 1; }
.tc-bal-amount small { font-size: 11px; font-weight: 600; color: var(--text-muted); letter-spacing: 0; }
.tc-bal-meta { font-size: 10px; color: var(--text-muted); margin-top: 4px; }
.tc-bal-split { display: flex; gap: 16px; margin-left: auto; }
.tc-bal-split-item .k { font-size: 9px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); }
.tc-bal-split-item .v { font-size: 14px; font-weight: 800; margin-top: 2px; }

.tc-gauge-wrap { padding: 0 1.25rem; }
.tc-gauge-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; font-size: 10px; color: var(--text-muted); }
.tc-gauge-row strong { color: var(--text); }
.tc-gauge-track { height: 6px; border-radius: 99px; background: var(--surface-warm); border: 1px solid var(--border); overflow: hidden; }
.tc-gauge-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), #28a428); transition: width .3s; }
.tc-gauge-fill.warn { background: linear-gradient(90deg, #f59e0b, #d97706); }
.tc-gauge-fill.danger { background: linear-gradient(90deg, #dc2626, #b91c1c); }

.tc-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding: 8px 1.25rem 0; }
.tc-tile { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--bg); }
.tc-tile-label { font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .07em; font-weight: 700; display: flex; align-items: center; }
.tc-tile-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; margin-right: 5px; }
.tc-tile-val { font-size: 15px; font-weight: 800; margin-top: 4px; }
.tc-tile-sub { font-size: 9px; color: var(--text-muted); }

.tc-promo-row { display: flex; gap: 7px; padding: 0 1.25rem; }
.tc-promo-input { flex: 1; font-family: var(--font); font-size: 12px; font-weight: 700; border: 1px solid var(--border); border-radius: 7px; padding: 9px 10px; background: var(--bg); color: var(--text); text-transform: uppercase; letter-spacing: .1em; outline: none; transition: border-color .15s; }
.tc-promo-input:focus { border-color: var(--accent); }
.tc-promo-input::placeholder { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text-muted); }
.tc-promo-btn { font-family: var(--font); font-size: 11px; font-weight: 700; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text); padding: 0 14px; cursor: pointer; white-space: nowrap; transition: .13s; }
.tc-promo-btn:hover { background: var(--surface-warm); }
.tc-promo-feedback { margin: 6px 1.25rem 0; font-size: 10px; padding: 7px 10px; border-radius: 6px; display: none; line-height: 1.4; }
.tc-promo-feedback.ok { display: block; background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.tc-promo-feedback.err { display: block; background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
html.theme-dark .tc-promo-feedback.ok { background: #0a2018; border-color: #1a5a38; color: #6fddaa; }
html.theme-dark .tc-promo-feedback.err { background: #200808; border-color: #5a1818; color: #f08080; }

.tc-pass-hero { margin: 8px 1.25rem 0; border: 1.5px solid var(--accent); border-radius: 9px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; cursor: pointer; background: linear-gradient(135deg, rgba(50,205,50,.06), var(--surface)); position: relative; transition: .13s; }
.tc-pass-hero:hover { background: linear-gradient(135deg, rgba(50,205,50,.12), var(--surface)); }
.tc-pass-badge { position: absolute; top: -1px; right: -1px; background: var(--accent); color: #0a3d0a; font-size: 8px; font-weight: 800; letter-spacing: .04em; padding: 2px 8px; border-radius: 0 8px 0 6px; }
.tc-pass-name { font-size: 12px; font-weight: 800; }
.tc-pass-desc { font-size: 10px; color: var(--text-muted); margin-top: 2px; line-height: 1.4; }
.tc-pass-price { margin-left: auto; text-align: right; flex-shrink: 0; }
.tc-pass-price-amount { font-size: 16px; font-weight: 800; }
.tc-pass-price-note { font-size: 9px; color: var(--text-muted); }

.tc-packs { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; padding: 7px 1.25rem 0; }
.tc-pack { border: 1px solid var(--border); border-radius: 8px; padding: 11px 10px; text-align: center; cursor: pointer; background: var(--bg); transition: .13s; }
.tc-pack:hover { border-color: var(--text-muted); background: var(--surface); }
.tc-pack-credits { font-size: 17px; font-weight: 800; }
.tc-pack-unit { font-size: 9px; color: var(--text-muted); font-weight: 600; letter-spacing: .04em; margin-top: 1px; }
.tc-pack-price { font-size: 13px; font-weight: 700; margin-top: 5px; }
.tc-pack-per { font-size: 8px; color: var(--text-muted); margin-top: 1px; }

.tc-buy-note { font-size: 9px; color: var(--text-muted); padding: 6px 1.25rem 0; line-height: 1.6; margin: 0; }

.tc-grants { padding: 0 1.25rem; }
.tc-grant-row { display: flex; align-items: center; gap: 9px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 10px; }
.tc-grant-row:last-child { border-bottom: none; }
.tc-grant-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.tc-grant-desc { flex: 1; color: var(--text-muted); }
.tc-grant-date { color: var(--text-muted); font-size: 9px; white-space: nowrap; }
.tc-grant-amt { font-weight: 700; font-size: 11px; white-space: nowrap; }
.tc-grant-amt.pos { color: var(--accent); }
.tc-grant-amt.neg { color: #dc2626; }
html.theme-dark .tc-grant-amt.neg { color: #f87171; }

.tc-footer { padding: 12px 1.25rem 16px; border-top: 1px solid var(--border); margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tc-footer-note { font-size: 9px; color: var(--text-muted); line-height: 1.5; }
.tc-footer-link { font-size: 10px; font-weight: 700; color: var(--text-muted); text-decoration: none; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; white-space: nowrap; flex-shrink: 0; transition: .12s; }
.tc-footer-link:hover { color: var(--text); background: var(--surface-warm); }
