:root {
  color-scheme: light;
  font-family: "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #d8dde5;
  --text: #111320;
  --muted: #5f6675;
  --accent: #5138ff;
  --accent-soft: rgba(81, 56, 255, 0.08);
  --accent-dark: #2e1db3;
  --success: #0c8c5f;
  background: var(--bg);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

button {
  font: inherit;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.55rem 1.25rem;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border 150ms ease;
}

button.primary {
  background: var(--accent);
  color: #fff;
}

button.primary:hover {
  background: var(--accent-dark);
}

button.secondary {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

button.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

button.block {
  width: 100%;
}

label.upload {
  border: 1px dashed var(--border);
  padding: 0.4rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

label.upload input {
  display: none;
}

.recovery-banner {
  background: rgba(12, 140, 95, 0.1);
  border: 1px solid var(--success);
  border-radius: 0.75rem;
  padding: 0.75rem 1.25rem;
  margin-bottom: 1rem;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
}

.recovery-banner.hidden {
  display: none;
}

main.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  position: relative;
  min-height: calc(100vh - 50px);
}

.hero {
  margin-bottom: 2.5rem;
}

.hero .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.hero h1 {
  margin: 0.2rem 0 0.5rem;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.1;
}

.hero .lede {
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 50ch;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.share-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.share-card .share-label {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  margin: 0;
}

.share-card .share-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(280px, 1.4fr);
  gap: 1.5rem;
}

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

@media (max-width: 600px) {
  main.page {
    padding: 1rem 0.75rem 3rem;
  }

  .hero h1 {
    font-size: 1.6rem;
  }

  .hero .lede {
    font-size: 0.95rem;
  }

  .hero-actions {
    gap: 0.5rem;
  }

  .hero-actions button {
    font-size: 0.85rem;
    padding: 0.45rem 0.9rem;
  }

  .stage-nav {
    gap: 0.25rem;
    padding: 0.6rem;
    flex-wrap: wrap;
    justify-content: center;
  }

  .stage-tab {
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
  }

  .stage-arrow {
    font-size: 0.75rem;
  }

  .question-grid {
    grid-template-columns: 1fr;
  }

  .option-row, .focus-row {
    font-size: 0.9rem;
  }

  .thumb {
    font-size: 1.2rem;
    padding: 0.3rem;
    min-width: 2rem;
    min-height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .focus-row .thumb {
    font-size: 1.6rem;
    padding: 0.4rem;
  }

  .focus-overlay {
    padding: 1rem;
  }

  .focus-title {
    font-size: 1.1rem;
  }

  .focus-header {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .essay-main {
    padding: 1.25rem 1rem;
  }

  .essay-layout,
  .outline-layout {
    grid-template-columns: 1fr;
  }

  .panel-card {
    padding: 1rem;
  }

  .readiness-banner,
  .suggest-banner {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
}

.question-column h2 {
  margin-top: 0;
}

.question-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.question-block {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem;
  min-height: 100%;
}

.question-block legend {
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.question-block .options {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.option-row {
  display: flex;
  gap: 0.4rem;
  align-items: flex-start;
  font-size: 0.95rem;
  padding: 0.35rem 0.5rem;
  border-radius: 0.6rem;
  transition: background 150ms ease;
}

.option-row.selected {
  background: rgba(12, 140, 95, 0.08);
  border-left: 3px solid var(--success);
}

.option-row.hold {
  background: rgba(255, 183, 0, 0.08);
  border-left: 3px solid #ffb700;
}

.option-row.provisional {
  background: rgba(12, 140, 95, 0.05);
  border-left: 3px dashed var(--success);
}

.option-row.recommended {
  background: rgba(81, 56, 255, 0.06);
  border-left: 3px solid var(--accent);
}

.option-row .ai-badge {
  font-size: 0.7rem;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
  cursor: help;
}

.focus-row.recommended {
  background: rgba(81, 56, 255, 0.06);
  border-color: var(--accent);
}

.focus-row .ai-badge {
  font-size: 0.75rem;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
  cursor: help;
}

.option-row.refreshing {
  opacity: 0.5;
}

.option-row.refreshing .thumb-down {
  opacity: 1;
  color: #d32f2f;
  animation: pulse-down 0.8s ease infinite;
}

@keyframes pulse-down {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.option-row.fresh {
  animation: flash-new 1.5s ease;
}

@keyframes flash-new {
  0% { background: rgba(81, 56, 255, 0.15); }
  100% { background: transparent; }
}

/* Focus mode */
.focus-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding: 2rem 2rem 1.5rem;
  overflow-y: auto;
}

.focus-overlay.hidden {
  display: none;
}

.focus-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.focus-title {
  font-size: 1.5rem;
  font-weight: 600;
  white-space: nowrap;
}

.focus-timer-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.focus-timer-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  width: 100%;
  transition: width 0.1s linear;
}

.focus-timer-fill.urgent {
  background: #d32f2f;
}

.focus-exit {
  white-space: nowrap;
}

.focus-options {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
}

.focus-row {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.25rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 1rem;
  font-size: 1.1rem;
  transition: background 150ms ease, opacity 150ms ease;
}

.focus-row.selected {
  background: rgba(12, 140, 95, 0.08);
  border-color: var(--success);
}

.focus-row.refreshing {
  opacity: 0.5;
}

.focus-row .thumb {
  font-size: 1.4rem;
  padding: 0.3rem 0.5rem;
}

.focus-row .option-text {
  flex: 1;
  line-height: 1.4;
}

.focus-row.selected {
  background: rgba(12, 140, 95, 0.08);
  border-color: var(--success);
}

.focus-row.hold {
  background: rgba(255, 183, 0, 0.08);
  border-color: #ffb700;
}

.focus-row.provisional {
  background: rgba(12, 140, 95, 0.05);
  border-style: dashed;
  border-color: var(--success);
}

.focus-row.fresh {
  animation: flash-new 1.5s ease;
}

.focus-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.option-text {
  flex: 1;
  line-height: 1.4;
}

.thumb {
  font-size: 1rem;
  background: none;
  border: none;
  padding: 0.1rem 0.2rem;
  cursor: pointer;
  border-radius: 0.4rem;
  opacity: 0.35;
  transition: opacity 150ms ease, transform 150ms ease;
  line-height: 1;
}

.thumb:hover {
  opacity: 0.7;
  transform: scale(1.15);
}

.thumb:active {
  transform: scale(0.95);
  opacity: 1;
}

@media (pointer: coarse) {
  .thumb {
    min-width: 2.5rem;
    min-height: 2.5rem;
    font-size: 1.2rem;
  }
}

.option-row.selected .thumb-up {
  opacity: 1;
}

.option-row.hold .thumb-hold {
  opacity: 1;
}

.option-row.provisional .thumb-up {
  opacity: 0.5;
  animation: gentle-pulse 2s ease infinite;
}

@keyframes gentle-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.8; }
}

.thumb-down:hover {
  opacity: 1;
}

.suggest-banner {
  background: rgba(81, 56, 255, 0.06);
  border: 1px solid var(--accent);
  border-radius: 0.75rem;
  padding: 0.75rem 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  font-size: 0.95rem;
}

.suggest-banner.hidden {
  display: none;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.panel-header h2 {
  margin: 0;
}

.counter {
  font-size: 0.85rem;
  color: var(--muted);
}

.tag {
  font-size: 0.8rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

#summaryList {
  margin: 0;
  padding-left: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

#summaryList li {
  font-size: 0.95rem;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.control select,
.control textarea {
  font: inherit;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  padding: 0.6rem 0.8rem;
  background: #fefefe;
}

.draft-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.draft-arrow {
  padding: 0.3rem 0.7rem;
  font-size: 1rem;
  min-width: 2.2rem;
}

.ai-result {
  width: 100%;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  padding: 0.75rem;
  font: inherit;
  resize: vertical;
}

.share-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Auth */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  position: relative;
  z-index: 300;
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  padding: 3rem 2.5rem;
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.auth-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.8rem;
}

.auth-btn {
  margin-top: 1.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.auth-screen.hidden { display: none; }

.share-invite-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.share-list {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.share-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  border-radius: 0.5rem;
  font-size: 0.85rem;
}
.user-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.user-role-select {
  background: var(--bg);
}

.google-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
.google-btn:hover {
  background: #f7f8f8;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1.5rem;
}

.auth-input {
  font: inherit;
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  font-size: 1rem;
}

.auth-input:focus {
  outline: none;
  border-color: var(--accent);
}

.auth-divider {
  display: flex;
  align-items: center;
  margin: 1rem 0;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-error {
  color: #d32f2f;
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

.auth-error.hidden { display: none; }

.user-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.5rem 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  z-index: 200;
}

.user-bar.hidden { display: none; }

.user-name {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Assignment Requirements List */
.reqs-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.req-item {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  padding: 0.35rem 0.5rem;
  background: var(--bg);
  border-radius: 0.5rem;
  font-size: 0.85rem;
}

.req-item-text {
  flex: 1;
  line-height: 1.4;
}

.req-item .req-delete {
  opacity: 0.3;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-size: 0.8rem;
  line-height: 1;
}

.req-item .req-delete:hover { opacity: 1; color: #d32f2f; }

.reqs-add-row {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.3rem;
}

.req-input {
  flex: 1;
  font: inherit;
  font-size: 0.85rem;
  border: 1px dashed var(--border);
  border-radius: 0.5rem;
  padding: 0.35rem 0.6rem;
  background: transparent;
}

.req-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Project Bar */
.project-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 1rem;
  flex-wrap: wrap;
  position: relative;
  z-index: 150;
}

@media (max-width: 600px) {
  .project-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .project-bar select { max-width: none; }
}

.project-bar select {
  font: inherit;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: #fefefe;
  max-width: 200px;
}

.project-title-input {
  flex: 1;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: transparent;
  min-width: 150px;
}

.project-title-input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fefefe;
}

/* ═══ Stage Navigation ═══ */
.stage-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 1rem;
}

.stage-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  transition: all 150ms ease;
}

.stage-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.stage-tab.completed {
  border-color: var(--success);
  color: var(--success);
}

.stage-num {
  font-weight: 600;
  font-size: 0.85rem;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.stage-tab.active .stage-num {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.stage-tab.completed .stage-num {
  background: rgba(12, 140, 95, 0.1);
}

.stage-arrow {
  color: var(--muted);
  font-size: 0.9rem;
}

.stage { display: none; }
.stage.active { display: block; }

/* Readiness Banner */
.readiness-banner {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.75rem 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.readiness-banner.hidden { display: none; }

/* ═══ Stage 2: Outline Editor ═══ */
.outline-layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(280px, 1.4fr);
  gap: 1.5rem;
}

@media (max-width: 1100px) {
  .outline-layout { grid-template-columns: 1fr; }
}

.outline-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.outline-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.outline-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.25rem;
  transition: border-color 150ms;
}

.outline-section:hover {
  border-color: var(--accent);
}

.outline-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.outline-section-title {
  font-weight: 600;
  font-size: 1.1rem;
}

.outline-section-actions {
  display: flex;
  gap: 0.4rem;
}

.outline-section-actions button {
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
}

.pick-one-tag {
  background: rgba(255, 183, 0, 0.1);
  color: #b37a00;
}

.pick-multi-tag {
  background: rgba(12, 140, 95, 0.08);
  color: var(--success);
}

.outline-items {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-height: 2rem;
}

.outline-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border-radius: 0.5rem;
  font-size: 0.95rem;
  cursor: grab;
}

.outline-item:active { cursor: grabbing; }

.outline-item .drag-handle {
  color: var(--muted);
  cursor: grab;
  user-select: none;
}

.outline-item-text {
  flex: 1;
}

.outline-item .remove-item {
  opacity: 0.3;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85rem;
}

.outline-item .remove-item:hover { opacity: 1; }

.outline-note {
  width: 100%;
  border: 1px dashed var(--border);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.9rem;
  resize: vertical;
  margin-top: 0.5rem;
  min-height: 2rem;
}

.unused-picks {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.unused-pick {
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  border-radius: 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 150ms;
}

.unused-pick:hover { background: var(--accent-soft); }

.ai-note {
  background: var(--accent-soft);
  border-radius: 0.75rem;
  padding: 0.75rem;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.ai-note.hidden { display: none; }

/* ═══ Stage 3: Essay Builder ═══ */
.essay-layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(280px, 1.4fr);
  gap: 1.5rem;
}

@media (max-width: 1100px) {
  .essay-layout { grid-template-columns: 1fr; }
}

.essay-main {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  padding: 2rem 2.5rem;
  min-height: 400px;
}

.essay-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.essay-paragraph {
  padding: 0.75rem;
  margin: 0.5rem 0;
  border-left: 3px solid transparent;
  border-radius: 0.25rem;
  cursor: text;
  transition: border-color 150ms, background 150ms;
  line-height: 1.7;
  font-size: 1.05rem;
  min-height: 1.5rem;
}

.essay-paragraph:hover {
  background: rgba(81, 56, 255, 0.03);
}

.essay-paragraph.active {
  border-left-color: var(--accent);
  background: rgba(81, 56, 255, 0.04);
}

.essay-paragraph[contenteditable="true"]:focus {
  outline: none;
}

.essay-section-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-top: 1.25rem;
  margin-bottom: 0.25rem;
}

.essay-section-label:first-child {
  margin-top: 0;
}

.outline-ref {
  font-size: 0.85rem;
  line-height: 1.5;
}

.outline-ref-section {
  margin-bottom: 0.5rem;
}

.outline-ref-title {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--muted);
}

.outline-ref-items {
  padding-left: 1rem;
  margin: 0.2rem 0 0;
}

/* Welcome Screen - hidden by default */
.welcome-screen {
  position: fixed;
  top: 50px; /* Below nav bar */
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg, #f8f9fa);
  z-index: 90;
  display: none; /* Hidden by default */
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.welcome-screen.visible { display: flex; }
.welcome-screen.hidden { display: none; }

.welcome-card {
  background: white;
  border-radius: 1rem;
  padding: 2.5rem;
  max-width: 540px;
  width: 100%;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  text-align: center;
}
.welcome-card h1 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}
.welcome-subtitle {
  color: var(--muted, #6b7280);
  margin-bottom: 2rem;
}

.welcome-steps {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2rem;
  text-align: left;
}
.welcome-step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg, #f8f9fa);
  border-radius: 0.5rem;
}
.welcome-step .step-num {
  width: 1.5rem;
  height: 1.5rem;
  background: var(--accent, #6366f1);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  flex-shrink: 0;
}

.welcome-form {
  text-align: left;
  margin-bottom: 1.5rem;
}
.welcome-form label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
}
.welcome-form textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  margin-bottom: 1rem;
}
.welcome-form textarea:focus {
  outline: none;
  border-color: var(--accent, #6366f1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.welcome-alt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

/* Top Nav Bar */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: white;
  border-bottom: 1px solid var(--border, #e5e7eb);
  z-index: 250;
}
.top-nav-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.top-nav-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.nav-brand {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text, #1f2937);
  text-decoration: none;
}
.nav-brand:hover {
  color: var(--accent, #6366f1);
}
.nav-btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}
.top-nav.hidden { display: none; }

/* Loading spinner animation */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  vertical-align: middle;
  margin-right: 0.5rem;
}

/* Generating state for buttons */
.btn-generating {
  position: relative;
  pointer-events: none;
  opacity: 0.8;
}

/* Pulse animation for generating text */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.generating-text {
  animation: pulse 1.5s ease-in-out infinite;
}

/* Full-screen loading overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 500;
}
.loading-overlay.hidden { display: none; }

.loading-message {
  font-size: 1.2rem;
  color: var(--text, #1f2937);
  margin-top: 1rem;
}

.loading-spinner-large {
  width: 48px;
  height: 48px;
  border: 4px solid var(--accent, #6366f1);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.loading-steps {
  margin-top: 1.5rem;
  text-align: left;
  color: var(--muted, #6b7280);
  font-size: 0.9rem;
}
.loading-steps .step {
  padding: 0.3rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.loading-steps .step.done { color: var(--success, #10b981); }
.loading-steps .step.active { color: var(--accent, #6366f1); font-weight: 500; }
