/* Scoping Studio: styles
   Palette: soft peach, sky blue, lavender accents on warm off-white.
*/

:root {
  --bg: #FBF8F4;
  --surface: #FFFFFF;
  --ink: #1F2433;
  --ink-soft: #4A5063;
  --ink-faint: #7C8497;
  --line: #ECE7DF;
  --line-soft: #F4EFE7;

  --peach: #F8C9B0;
  --peach-soft: #FCE6D8;
  --sky: #B8D8E8;
  --sky-soft: #DDECF3;
  --lavender: #CFC4E2;
  --lavender-soft: #E9E2F1;

  --accent: #5B6CB0;
  --accent-hover: #4A5A99;
  --accent-soft: #E5E9F5;

  --error: #B0413E;
  --shadow-sm: 0 1px 2px rgba(31, 36, 51, 0.04), 0 2px 8px rgba(31, 36, 51, 0.04);
  --shadow-md: 0 4px 12px rgba(31, 36, 51, 0.06), 0 12px 32px rgba(31, 36, 51, 0.06);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(circle at 15% 8%, var(--peach-soft) 0%, transparent 38%),
    radial-gradient(circle at 88% 12%, var(--sky-soft) 0%, transparent 40%),
    radial-gradient(circle at 75% 92%, var(--lavender-soft) 0%, transparent 42%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 160ms ease;
}

a:hover {
  border-bottom-color: var(--accent);
}

/* Layout shell */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 48px 24px 24px;
}

.screen {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  animation: fadeIn 320ms ease;
}

.screen.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 56px 56px 48px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--line-soft);
}

.card.wide {
  max-width: 860px;
}

/* Typography */
h1, h2, h3 {
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 12px;
}

h1 {
  font-size: 32px;
  line-height: 1.2;
}

h2 {
  font-size: 22px;
  line-height: 1.3;
  margin-bottom: 8px;
}

.lede {
  font-size: 18px;
  color: var(--ink-soft);
  margin: 0 0 28px;
  line-height: 1.5;
}

.body-text {
  color: var(--ink-soft);
  margin: 0 0 28px;
}

.meta-text {
  color: var(--ink-faint);
  font-size: 14px;
  margin: 16px 0 0;
}

.error-text {
  color: var(--error);
  font-size: 14px;
  margin: 12px 0 0;
}

.field-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
  margin: 16px 0 8px;
}

.question-tag {
  display: inline-block;
  background: var(--peach-soft);
  color: #8A5A3F;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 6px 12px;
  border-radius: 999px;
  margin: 0 0 16px;
}

.question-text {
  font-size: 28px;
  line-height: 1.3;
  font-weight: 500;
  margin: 0 0 8px;
}

.question-hint {
  color: var(--ink-faint);
  font-size: 15px;
  margin: 0 0 14px;
  font-style: italic;
}

.why-wrap {
  margin: 0 0 24px;
}

.why-toggle {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px dashed transparent;
  transition: border-color 160ms ease;
}

.why-toggle:hover,
.why-toggle:focus-visible {
  border-bottom-color: var(--accent);
  outline: none;
}

.why-rationale {
  margin: 12px 0 0;
  padding: 14px 16px;
  background: var(--sky-soft);
  border-left: 3px solid var(--sky);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 14.5px;
  color: var(--ink-soft);
  line-height: 1.55;
  animation: fadeIn 240ms ease;
}

/* Inputs */
.text-input,
.answer-input {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  transition: border-color 180ms ease, box-shadow 180ms ease;
  resize: vertical;
  line-height: 1.55;
}

.answer-input {
  min-height: 130px;
}

.answer-helpers {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
  min-height: 28px;
}

.btn-sample {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--ink-soft);
  padding: 5px 12px;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 180ms ease;
}

.btn-sample:hover {
  background: var(--peach-soft);
  color: var(--ink);
  border-color: var(--peach);
  border-style: solid;
}

.btn-sample:focus-visible {
  outline: none;
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.sample-icon {
  color: var(--peach);
  margin-right: 2px;
}

.text-input:focus,
.answer-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

/* Buttons */
.button-row {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.btn-primary,
.btn-secondary {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  border-radius: 999px;
  padding: 12px 24px;
  cursor: pointer;
  transition: all 180ms ease;
  border: 1.5px solid transparent;
  letter-spacing: -0.005em;
}

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

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--line);
}

.btn-secondary:hover {
  border-color: var(--ink-soft);
  color: var(--ink);
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
}

.btn-link:hover {
  text-decoration: underline;
}

.btn-link-small {
  background: none;
  border: none;
  color: var(--ink-faint);
  font-family: var(--font-sans);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
}

.btn-link-small:hover {
  color: var(--ink-soft);
}

/* Choice grid */
.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.choice-card {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-sans);
  transition: all 200ms ease;
}

.choice-card h2 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--ink);
}

.choice-card p {
  font-size: 14px;
  color: var(--ink-faint);
  margin: 0;
  line-height: 1.5;
}

.choice-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  background: var(--accent-soft);
}

/* Conversation */
.conversation-shell {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 40px 48px 40px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--line-soft);
}

.conversation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.progress-label {
  font-size: 13px;
  color: var(--ink-faint);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--line-soft);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 36px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--peach), var(--lavender), var(--sky));
  border-radius: 999px;
  width: 0%;
  transition: width 400ms ease;
}

.question-area {
  animation: fadeIn 360ms ease;
}

/* Review */
.review-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.review-item {
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  padding: 20px 24px;
}

.review-item .review-question {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 10px;
}

.review-item .review-answer-display {
  font-size: 16px;
  color: var(--ink);
  line-height: 1.55;
  margin: 0;
  white-space: pre-wrap;
}

.review-item textarea {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 16px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 8px;
  min-height: 100px;
  resize: vertical;
}

.review-item textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.review-item .review-edit-toggle {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  margin-top: 8px;
}

.review-item .review-edit-toggle:hover {
  text-decoration: underline;
}

/* Brief preview */
.brief-actions-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.brief-actions-top h1 {
  margin: 0;
  flex: 1 1 auto;
}

.brief-actions-top .button-row {
  margin-top: 0;
}

.brief-content {
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--ink);
}

.brief-section {
  margin-bottom: 8px;
}

.brief-section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin: 32px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}

.brief-section:first-child .brief-section-header {
  margin-top: 0;
}

.brief-section-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
  padding: 0;
  border: none;
  flex: 1 1 auto;
}

.btn-refine {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 4px 12px;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 180ms ease;
  flex: 0 0 auto;
  opacity: 0.45;
}

.brief-section:hover .btn-refine,
.btn-refine:focus-visible {
  opacity: 1;
}

.btn-refine:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  opacity: 1;
}

.refine-icon {
  color: var(--accent);
  margin-right: 2px;
}

.brief-section-content p {
  margin: 0 0 14px;
  color: var(--ink-soft);
}

.brief-section-content ul {
  padding-left: 22px;
  margin: 0 0 16px;
  color: var(--ink-soft);
}

.brief-section-content li {
  margin-bottom: 6px;
}

.brief-section-content .subhead {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 8px;
}

.brief-section-content .subhead:not(:first-child) {
  margin-top: 6px;
}

.brief-section-content .verbatim-answer {
  background: var(--peach-soft);
  border-left: 3px solid var(--peach);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 18px 2px;
  margin: 0 0 22px;
}

.brief-section-content .verbatim-answer p {
  color: var(--ink);
  margin-bottom: 12px;
}

.brief-section-content .thoughts-block {
  padding: 0 0 6px;
}

.brief-section-content .thoughts-block p {
  color: var(--ink-soft);
}

.refine-helper {
  font-size: 13px;
  color: var(--ink-faint);
  margin: 0 0 10px;
  font-style: italic;
}

.brief-section-refine {
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin: 8px 0 20px;
  border: 1px solid var(--line-soft);
  animation: fadeIn 240ms ease;
}

.refine-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.chip {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 6px 12px;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
  transition: all 160ms ease;
}

.chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.refine-textarea {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  resize: vertical;
  min-height: 60px;
  margin-bottom: 12px;
  line-height: 1.5;
  color: var(--ink);
}

.refine-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.refine-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.refine-actions .btn-primary,
.refine-actions .btn-secondary {
  padding: 8px 18px;
  font-size: 13px;
}

.refine-status {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.brief-section.refining .brief-section-content {
  opacity: 0.4;
  transition: opacity 200ms ease;
}

/* Loading */
.spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  margin: 0 auto 24px;
  animation: spin 900ms linear infinite;
}

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

#generating-line {
  text-align: center;
  font-size: 22px;
  font-weight: 500;
  transition: opacity 300ms ease;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn 220ms ease;
  z-index: 100;
}

.toast.hidden {
  display: none;
}

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* What's next */
.next-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 16px;
}

.next-card {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-sans);
  transition: all 200ms ease;
}

.next-card h2 {
  font-size: 16px;
  margin-bottom: 4px;
  color: var(--ink);
}

.next-card p {
  font-size: 14px;
  color: var(--ink-faint);
  margin: 0;
}

.next-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

/* Footer */
.app-footer {
  width: 100%;
  max-width: 860px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 0 8px;
  margin-top: 32px;
  font-size: 13px;
  color: var(--ink-faint);
}

.app-footer a {
  color: var(--ink-soft);
  border-bottom: 1px solid transparent;
}

.app-footer a:hover {
  border-bottom-color: var(--ink-soft);
}

.hidden {
  display: none !important;
}

/* Mobile */
@media (max-width: 640px) {
  .app-shell {
    padding: 24px 16px 16px;
  }
  .card {
    padding: 32px 24px 28px;
    border-radius: var(--radius-lg);
  }
  .conversation-shell {
    padding: 28px 24px;
    border-radius: var(--radius-lg);
  }
  h1 {
    font-size: 26px;
  }
  .question-text {
    font-size: 22px;
  }
  .lede {
    font-size: 16px;
  }
  .choice-grid {
    grid-template-columns: 1fr;
  }
  .brief-actions-top {
    flex-direction: column;
  }
  .button-row {
    width: 100%;
  }
  .btn-primary,
  .btn-secondary {
    flex: 1;
    min-width: 0;
  }
}
