@import url('core/_animations.css');

:root {
  --primary: oklch(70% 0.22 145);
  --primary-light: oklch(75% 0.2 145);
  --secondary: oklch(67% 0.2 220);
  --bg-dark: #20242b;
  --bg-card: rgba(28, 35, 48, 0.78);
  --bg-input: rgba(12, 18, 28, 0.86);
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.2);
  --border-strong: rgba(148, 163, 184, 0.38);
  --shadow-soft: 0 8px 24px rgba(2, 6, 23, 0.28);
  --shadow-hard: 0 18px 40px rgba(2, 6, 23, 0.4);
  --status-info: oklch(79% 0.14 228);
  --status-success: oklch(78% 0.18 146);
  --status-warning: oklch(84% 0.15 90);
  --status-error: oklch(71% 0.21 16);
  --header-h: 64px;
}

html[data-theme="light"] {
  --bg-dark: #e9eef4;
  --bg-card: rgba(255, 255, 255, 0.86);
  --bg-input: rgba(255, 255, 255, 0.98);
  --text-primary: #142033;
  --text-secondary: #314359;
  --text-muted: #4a607a;
  --border: rgba(20, 32, 51, 0.14);
  --border-strong: rgba(20, 32, 51, 0.24);
  --shadow-soft: 0 9px 22px rgba(15, 23, 42, 0.14);
  --shadow-hard: 0 18px 38px rgba(15, 23, 42, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.55;
  min-height: 100svh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 16% 14%, rgba(16, 185, 129, 0.15), transparent 58%),
    radial-gradient(ellipse at 82% 18%, rgba(56, 189, 248, 0.14), transparent 58%),
    radial-gradient(ellipse at 50% 72%, rgba(12, 74, 110, 0.2), transparent 66%),
    linear-gradient(180deg, rgba(16, 24, 38, 0.95), rgba(19, 24, 34, 0.97));
}

html[data-theme="light"] body::before {
  background:
    radial-gradient(ellipse at 12% 11%, rgba(16, 185, 129, 0.18), transparent 58%),
    radial-gradient(ellipse at 84% 16%, rgba(56, 189, 248, 0.17), transparent 58%),
    radial-gradient(ellipse at 50% 78%, rgba(148, 197, 255, 0.24), transparent 66%),
    linear-gradient(180deg, rgba(245, 250, 255, 0.95), rgba(237, 244, 252, 0.97));
}

.container {
  width: min(1280px, 94vw);
  margin: 0 auto;
}

header {
  padding: 1rem 1.5rem;
  min-height: var(--header-h);
  background:
    radial-gradient(circle at 12% 20%, rgba(56, 189, 248, 0.14), transparent 55%),
    radial-gradient(circle at 88% 18%, rgba(16, 185, 129, 0.16), transparent 60%),
    radial-gradient(circle at 72% 85%, rgba(236, 72, 153, 0.14), transparent 55%),
    linear-gradient(120deg, rgba(15, 23, 42, 0.88), rgba(10, 15, 26, 0.82));
  backdrop-filter: blur(18px) saturate(170%);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
}

html[data-theme="light"] header {
  background:
    radial-gradient(circle at 10% 18%, rgba(56, 189, 248, 0.16), transparent 56%),
    radial-gradient(circle at 88% 20%, rgba(16, 185, 129, 0.14), transparent 60%),
    linear-gradient(120deg, rgba(248, 251, 255, 0.92), rgba(236, 244, 252, 0.9));
  border-bottom-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 5px 22px rgba(15, 23, 42, 0.08);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
  min-width: 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  background-image: linear-gradient(90deg, var(--primary), var(--secondary));
  background-size: 0% 100%;
  background-repeat: no-repeat;
  background-position: 0 100%;
  -webkit-background-clip: text;
  background-clip: text;
  transition: color 0.3s ease, text-shadow 0.3s ease, background-size 0.6s ease;
}

.back-link svg {
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
  transition: color 0.3s ease, filter 0.3s ease;
}

html[data-theme="light"] .back-link {
  color: #314359;
}

html[data-theme="light"] .back-link svg {
  color: #314359;
}

.back-link:hover {
  color: transparent;
  -webkit-text-fill-color: transparent;
  background-size: 100% 100%;
  text-shadow:
    0 0 12px color-mix(in oklch, var(--primary) 50%, transparent),
    0 0 22px color-mix(in oklch, var(--secondary) 40%, transparent);
}

.back-link:hover svg {
  color: var(--primary);
  filter: drop-shadow(0 0 8px color-mix(in oklch, var(--primary) 60%, transparent));
}

.header-title {
  font-size: clamp(1.3rem, 3.6vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: left;
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  white-space: nowrap;
  padding-bottom: 0.1rem;
  text-shadow:
    0 1px 0 rgba(238, 252, 247, 0.24),
    0 -1px 0 rgba(4, 16, 30, 0.5),
    0 3px 8px rgba(2, 8, 23, 0.46),
    0 0 16px rgba(14, 165, 233, 0.26);
  pointer-events: none;
}

html[data-theme="light"] .header-title {
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.96),
    0 -1px 0 rgba(15, 23, 42, 0.08),
    0 2px 5px rgba(15, 23, 42, 0.18),
    0 0 8px rgba(14, 165, 233, 0.18);
}

.header-title:hover .title-strong,
.header-title:focus-within .title-strong,
.header-title.is-active .title-strong {
  animation: headerShimmer 2.6s ease-in-out infinite;
}

.header-title:hover .title-script,
.header-title:focus-within .title-script,
.header-title.is-active .title-script {
  animation: neonFlicker 1.6s ease-in-out both;
}

/* @keyframes headerShimmer, neonFlicker — removed; imported from core/_animations.css */

.title-lock {
  position: relative;
  display: inline-block;
  width: max-content;
  padding-right: clamp(1.4rem, 4vw, 2.2rem);
}

.title-strong {
  font-size: clamp(1.78rem, 4.9vw, 2.72rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
  color: color-mix(in oklch, var(--primary) 70%, white 14%);
  transform: rotate(-0.55deg);
  display: inline-block;
  -webkit-text-stroke: 0.22px rgba(2, 42, 33, 0.58);
  text-shadow:
    0 1px 0 rgba(240, 255, 250, 0.56),
    0 -1px 0 rgba(2, 16, 25, 0.48),
    0 0 1px rgba(6, 78, 59, 0.34),
    0 4px 10px rgba(2, 8, 23, 0.52),
    0 0 13px rgba(16, 185, 129, 0.34);
}

html[data-theme="light"] .title-strong {
  color: #1a8b6f;
  -webkit-text-stroke: 0.18px rgba(8, 70, 54, 0.42);
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.98),
    0 -1px 0 rgba(15, 23, 42, 0.08),
    0 0 0.8px rgba(8, 70, 54, 0.42),
    0 2px 4px rgba(15, 23, 42, 0.18),
    0 0 9px rgba(16, 185, 129, 0.2);
}

.title-script {
  font-weight: 700;
  font-style: italic;
  position: absolute;
  left: 50%;
  top: 71%;
  width: max-content;
  transform: translate(-13%, -47%) rotate(-9deg);
  font-family: 'Caveat', 'Segoe Script', cursive;
  font-size: clamp(1.08rem, 3.35vw, 1.82rem);
  letter-spacing: 0.012em;
  line-height: 1;
  color: #7befff;
  -webkit-text-stroke: 0.22px rgba(4, 70, 92, 0.5);
  text-shadow:
    0 1px 0 rgba(236, 250, 255, 0.62),
    0 -1px 0 rgba(4, 20, 34, 0.48),
    0 3px 7px rgba(2, 8, 23, 0.55),
    0 0 14px rgba(34, 211, 238, 0.48);
  pointer-events: none;
  white-space: nowrap;
}

html[data-theme="light"] .title-script {
  color: #1a9cc1;
  -webkit-text-stroke: 0.18px rgba(13, 84, 111, 0.48);
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.98),
    0 -1px 0 rgba(15, 23, 42, 0.08),
    0 0 0.8px rgba(13, 84, 111, 0.48),
    0 2px 4px rgba(15, 23, 42, 0.2),
    0 0 9px rgba(14, 165, 233, 0.24);
}

.model-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.72rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.38);
  background: rgba(8, 15, 26, 0.72);
  color: #ecfeff;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  transition: border-color 200ms ease, background-color 200ms ease, color 200ms ease;
}

.model-status-badge .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.52;
}

.model-status-badge.active {
  color: #bbf7d0;
  border-color: rgba(16, 185, 129, 0.48);
}

.model-status-badge.disconnected {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.45);
}

html[data-theme="light"] .model-status-badge {
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(15, 23, 42, 0.16);
  color: #1e293b;
}

html[data-theme="light"] .model-status-badge.active {
  color: #116149;
  border-color: color-mix(in oklch, var(--primary) 42%, rgba(15, 23, 42, 0.16));
}

html[data-theme="light"] .model-status-badge.connecting {
  color: #0f5989;
  border-color: color-mix(in oklch, var(--secondary) 42%, rgba(15, 23, 42, 0.16));
}

html[data-theme="light"] .model-status-badge:hover {
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(15, 23, 42, 0.24);
  color: #0f172a;
}

.model-status-badge:hover {
  background: rgba(148, 163, 184, 0.15);
  border-color: rgba(148, 163, 184, 0.4);
  color: var(--text-secondary);
}

.model-status-badge.connecting .status-dot,
.model-status-badge.active .status-dot {
  opacity: 1;
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.8;
  }

  50% {
    transform: scale(1.18);
    opacity: 1;
  }
}

.problem-solver-app {
  flex: 1;
  width: min(1380px, 96vw);
  margin: 0 auto;
  padding: clamp(1rem, 2vw, 1.5rem) 0.5rem 2rem;
}

.problem-solver-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(290px, 390px);
  gap: 1rem;
  align-items: start;
}

@media (min-width: 1920px) {
  .container {
    width: min(94vw, 1420px);
  }

  .problem-solver-app {
    width: min(95vw, 1560px);
  }

  .problem-solver-layout {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 440px);
    gap: 1.2rem;
  }
}

@media (min-width: 2560px) {
  .container {
    width: min(92vw, 1600px);
  }

  .problem-solver-app {
    width: min(93vw, 1740px);
  }

  .problem-solver-layout {
    grid-template-columns: minmax(0, 1fr) minmax(350px, 490px);
    gap: 1.35rem;
  }
}

.problem-solver-context {
  margin-top: clamp(1.2rem, 3vw, 2rem);
  padding: clamp(1rem, 2.6vw, 1.6rem);
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: color-mix(in oklch, var(--bg-card) 92%, transparent 8%);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px) saturate(125%);
}

.context-header {
  margin-bottom: 1rem;
}

.context-eyebrow {
  margin: 0;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.context-header h2 {
  margin: 0.35rem 0 0;
  font-size: clamp(1.12rem, 2.6vw, 1.5rem);
  letter-spacing: -0.02em;
}

.context-header p {
  margin: 0.45rem 0 0;
  color: var(--text-secondary);
}

.context-pills {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.52rem;
}

.context-pills li {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in oklch, var(--bg-input) 62%, transparent 38%);
  color: var(--text-secondary);
  padding: 0.34rem 0.68rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.context-details {
  margin-top: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 0.84rem;
  background: color-mix(in oklch, var(--bg-input) 55%, transparent 45%);
  overflow: clip;
}

.context-details > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.68rem 0.82rem;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid transparent;
}

.context-details > summary::-webkit-details-marker {
  display: none;
}

.context-details[open] > summary {
  border-bottom-color: var(--border);
}

.context-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.7rem;
  padding: 0.76rem;
}

.context-card {
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  background: color-mix(in oklch, var(--bg-input) 72%, transparent 28%);
  padding: 0.72rem;
}

.context-card h3 {
  margin: 0;
  font-size: 0.98rem;
}

.context-card p {
  margin: 0.36rem 0 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.45;
}

.context-note {
  margin-top: 0.72rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

@media (min-width: 640px) {
  .header-title {
    margin-left: clamp(0.4rem, 1.6vw, 1.2rem);
  }
}

@media (min-width: 740px) {
  .header-title {
    margin-left: auto;
    margin-right: auto;
    justify-content: center;
  }
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: var(--shadow-soft);
  overflow: clip;
  backdrop-filter: blur(14px) saturate(140%);
  position: relative;
}

.panel::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.06), transparent 42%),
    radial-gradient(circle at 92% -2%, rgba(56, 189, 248, 0.12), transparent 42%);
  opacity: 0.8;
}

html[data-theme="light"] .panel::before {
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.6), transparent 45%),
    radial-gradient(circle at 92% -2%, rgba(56, 189, 248, 0.08), transparent 44%);
  opacity: 0.64;
}

.panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  color: var(--text-primary);
}

.panel summary::-webkit-details-marker {
  display: none;
}

.summary-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.panel-content {
  padding: 1rem;
}

.panel-header {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1rem 1rem 0.4rem;
}

.panel-header h1 {
  margin: 0;
  font-size: clamp(1.25rem, 2.8vw, 1.8rem);
  letter-spacing: -0.02em;
}

.panel-header p {
  margin: 0;
  color: var(--text-secondary);
  max-width: 74ch;
}

.panel-header-inline {
  padding: 0;
  margin-bottom: 0.75rem;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.panel-header-inline h2,
.panel-subheader h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--text-primary);
}

.panel-subheader {
  margin-top: 1rem;
  margin-bottom: 0.55rem;
}

.panel-workflow {
  padding-bottom: 1rem;
}

.workflow-step {
  margin: 0.5rem 1rem 0;
  padding: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  background: color-mix(in oklch, var(--bg-card) 78%, transparent 22%);
}

.workflow-step.is-active {
  border-color: color-mix(in oklch, var(--primary) 32%, var(--border-strong));
  box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--primary) 30%, transparent);
}

.step-header {
  display: grid;
  grid-template-columns: minmax(170px, auto) 1fr;
  align-items: center;
  gap: 0.85rem;
  margin: -0.95rem -0.95rem 0.85rem;
  padding: 0.72rem 0.95rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklch, var(--bg-input) 52%, transparent 48%);
}

.step-header h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.step-header p {
  margin: 0.35rem 0 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.field-label {
  margin-top: 0.9rem;
  margin-bottom: 0.45rem;
  display: inline-flex;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
}

.field-help {
  margin-top: 0.35rem;
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.scenario-input {
  width: 100%;
  min-height: 10rem;
  resize: vertical;
  padding: 0.9rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-primary);
  font: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.scenario-input:focus {
  outline: none;
  border-color: color-mix(in oklch, var(--primary) 54%, var(--border-strong));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 0 0 2px color-mix(in oklch, var(--primary) 36%, transparent 64%);
}

.slider-row {
  margin-top: 0.8rem;
}

.slider-row input[type="range"] {
  width: 100%;
  margin-top: 0.35rem;
  accent-color: color-mix(in oklch, var(--primary) 56%, var(--secondary) 44%);
}

.step-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.95rem;
}

.primary-button,
.ghost-button {
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.52rem 1rem;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.primary-button {
  background: linear-gradient(120deg, color-mix(in oklch, var(--primary) 70%, #052e2b 30%), color-mix(in oklch, var(--secondary) 62%, #044052 38%));
  color: #f8fafc;
  box-shadow: 0 8px 18px rgba(2, 8, 23, 0.3);
}

.primary-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 20px rgba(2, 8, 23, 0.36);
}

.ghost-button {
  background: color-mix(in oklch, var(--bg-card) 72%, transparent 28%);
  color: var(--text-secondary);
  border-color: var(--border);
}

.ghost-button:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.primary-button:disabled,
.ghost-button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

html[data-theme="light"] .primary-button:disabled,
html[data-theme="light"] .ghost-button:disabled {
  opacity: 1;
  color: #4f657e;
  border-color: rgba(88, 111, 136, 0.28);
}

html[data-theme="light"] .primary-button:disabled {
  background: linear-gradient(120deg, rgba(180, 202, 224, 0.9), rgba(167, 190, 215, 0.92));
}

html[data-theme="light"] .ghost-button:disabled {
  background: rgba(227, 234, 243, 0.9);
}

.option-grid {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.option-card {
  border: 1px solid var(--border);
  background: color-mix(in oklch, var(--bg-input) 64%, transparent 36%);
  border-radius: 0.8rem;
  padding: 0.8rem;
  text-align: left;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.option-card h3 {
  margin: 0;
  font-size: 0.96rem;
  line-height: 1.35;
}

.option-card p {
  margin: 0.45rem 0 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.option-card:hover {
  transform: translateY(-1px);
  border-color: color-mix(in oklch, var(--primary) 36%, var(--border-strong));
}

.option-card.selected {
  border-color: color-mix(in oklch, var(--primary) 55%, var(--secondary) 45%);
  box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--primary) 44%, transparent);
}

.option-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.55rem;
}

.meta-chip {
  font-size: 0.76rem;
  color: var(--text-secondary);
  border-radius: 999px;
  border: 1px solid color-mix(in oklch, var(--border-strong) 70%, transparent);
  padding: 0.2rem 0.52rem;
  background: color-mix(in oklch, var(--bg-input) 45%, transparent 55%);
}

.markdown-output {
  margin-top: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  padding: 0.9rem;
  min-height: 7.5rem;
  background: color-mix(in oklch, var(--bg-input) 66%, transparent 34%);
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.markdown-output h1,
.markdown-output h2,
.markdown-output h3 {
  margin: 0.95rem 0 0.5rem;
  line-height: 1.24;
}

.markdown-output h1:first-child,
.markdown-output h2:first-child,
.markdown-output h3:first-child,
.markdown-output p:first-child {
  margin-top: 0;
}

.markdown-output p,
.markdown-output ul,
.markdown-output ol,
.markdown-output pre,
.markdown-output table,
.markdown-output blockquote {
  margin: 0.65rem 0;
}

.markdown-output ul,
.markdown-output ol {
  padding-left: 1.2rem;
}

.markdown-output code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  background: color-mix(in oklch, var(--bg-input) 72%, transparent 28%);
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  padding: 0.1rem 0.32rem;
}

.markdown-output pre {
  overflow-x: auto;
  border-radius: 0.65rem;
  border: 1px solid var(--border);
  background: color-mix(in oklch, var(--bg-input) 72%, transparent 28%);
  padding: 0.8rem;
}

.markdown-output pre code {
  border: 0;
  background: transparent;
  padding: 0;
}

.markdown-output table {
  width: 100%;
  border-collapse: collapse;
}

.markdown-output th,
.markdown-output td {
  border: 1px solid var(--border);
  padding: 0.38rem 0.42rem;
  text-align: left;
}

.markdown-output a {
  color: color-mix(in oklch, var(--secondary) 60%, var(--primary) 40%);
}

.placeholder-text {
  margin: 0;
  color: var(--text-muted);
}

.workflow-status-row {
  margin: 0.75rem 1rem 0;
  min-height: 2rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.processing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.processing-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: color-mix(in oklch, var(--primary) 56%, var(--secondary) 44%);
  animation: pulse 1.2s ease-in-out infinite;
}

.processing-dot:nth-child(2) {
  animation-delay: 120ms;
}

.processing-dot:nth-child(3) {
  animation-delay: 240ms;
}

.status-banner {
  min-height: 1.3rem;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.status-banner.is-info {
  color: var(--status-info);
}

.status-banner.is-success {
  color: var(--status-success);
}

.status-banner.is-warning {
  color: var(--status-warning);
}

.status-banner.is-error {
  color: var(--status-error);
}

.session-list,
.step-list {
  display: grid;
  gap: 0.55rem;
}

.session-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
}

.session-select {
  border: 1px solid var(--border);
  border-radius: 0.74rem;
  background: color-mix(in oklch, var(--bg-input) 60%, transparent 40%);
  color: var(--text-primary);
  text-align: left;
  padding: 0.6rem;
  cursor: pointer;
  transition: border-color 160ms ease, transform 160ms ease;
}

.session-select:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.session-item.active .session-select {
  border-color: color-mix(in oklch, var(--primary) 42%, var(--border-strong));
  box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--primary) 30%, transparent);
}

.session-title {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.25;
}

.session-time {
  display: block;
  margin-top: 0.2rem;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.session-delete {
  border: 1px solid var(--border);
  border-radius: 0.68rem;
  padding: 0.3rem 0.58rem;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.session-delete:hover {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.45);
}

.step-item {
  border: 1px solid var(--border);
  border-radius: 0.72rem;
  background: color-mix(in oklch, var(--bg-input) 58%, transparent 42%);
  color: var(--text-secondary);
  text-align: left;
  cursor: pointer;
  padding: 0.52rem 0.64rem;
  font: inherit;
  font-size: 0.86rem;
  transition: border-color 160ms ease, color 160ms ease;
}

.step-item .step-label {
  display: block;
}

.step-item.complete {
  color: var(--text-primary);
  border-color: color-mix(in oklch, var(--primary) 36%, var(--border));
}

.step-item.current {
  color: #ecfeff;
  border-color: color-mix(in oklch, var(--primary) 52%, var(--secondary) 48%);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.18), rgba(56, 189, 248, 0.18));
}

.step-item.locked {
  opacity: 0.7;
  cursor: not-allowed;
}

html[data-theme="light"] .step-item {
  color: #36495f;
  border-color: rgba(20, 32, 51, 0.2);
  background: rgba(255, 255, 255, 0.88);
}

html[data-theme="light"] .step-item.current {
  color: #0f172a;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.24), rgba(56, 189, 248, 0.22));
  border-color: rgba(14, 116, 144, 0.45);
}

html[data-theme="light"] .step-item.locked {
  opacity: 1;
  color: #50647c;
  border-color: rgba(20, 32, 51, 0.16);
  background: rgba(245, 248, 252, 0.9);
}

html[data-theme="light"] .step-header p,
html[data-theme="light"] .field-help,
html[data-theme="light"] .placeholder-text,
html[data-theme="light"] .status-banner,
html[data-theme="light"] .session-time {
  color: #42566f;
}

html[data-theme="light"] .scenario-input::placeholder {
  color: #687d96;
  opacity: 1;
}

html[data-theme="light"] .session-delete {
  color: #546b86;
  border-color: rgba(20, 32, 51, 0.18);
  background: rgba(255, 255, 255, 0.86);
}

.action-panel-content {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.site-footer {
  padding: 0.75rem 0 0.85rem;
  border-top: 1px solid var(--border);
  background: rgba(34, 37, 43, 0.6);
}

html[data-theme="light"] .site-footer {
  background: rgba(248, 250, 252, 0.9);
}

.footer-content {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.9rem 1rem;
  margin-bottom: 0.45rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 220px;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 1;
}

.footer-links a:hover {
  color: var(--text-secondary);
}

.theme-toggle {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  position: relative;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.35);
  color: var(--text-secondary);
  cursor: pointer;
  margin-left: auto;
}

html[data-theme="light"] .theme-toggle {
  background: rgba(255, 255, 255, 0.8);
}

.theme-toggle-icon {
  display: inline-flex;
  position: relative;
  width: 18px;
  height: 18px;
}

.theme-toggle-icon svg {
  position: absolute;
  inset: 0;
  width: 18px;
  height: 18px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.theme-toggle .icon-sun {
  opacity: 0;
  transform: rotate(-90deg);
}

html[data-theme="light"] .theme-toggle .icon-sun {
  opacity: 1;
  transform: rotate(0deg);
}

html[data-theme="light"] .theme-toggle .icon-moon {
  opacity: 0;
  transform: rotate(90deg);
}

.theme-toggle-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.footer-privacy {
  display: block;
  margin-top: 0.35rem;
}

.privacy-inline {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  width: auto;
  max-width: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-left: auto;
  margin-right: auto;
  scroll-margin-top: calc(var(--header-h) + 0.75rem);
}

html[data-theme="light"] .privacy-inline {
  background: transparent;
}

.privacy-inline-summary {
  width: auto;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 1.05rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: none;
  text-shadow: none;
}

html[data-theme="light"] .privacy-inline-summary {
  background: rgba(15, 23, 42, 0.03);
  border-color: rgba(15, 23, 42, 0.1);
  box-shadow: none;
}

.privacy-inline-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.privacy-inline-heading {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.privacy-inline-toggle {
  position: relative;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-secondary);
  flex-shrink: 0;
}

html[data-theme="light"] .privacy-inline-toggle {
  background: rgba(255, 255, 255, 0.75);
}

.privacy-inline-toggle svg {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  transform: translate(-50%, -50%);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.privacy-inline-toggle .icon-collapse {
  opacity: 0;
  transform: translate(-50%, -50%) rotate(-90deg);
}

.privacy-inline-summary[aria-expanded="true"] .icon-expand {
  opacity: 0;
  transform: translate(-50%, -50%) rotate(90deg);
}

.privacy-inline-summary[aria-expanded="true"] .icon-collapse {
  opacity: 1;
  transform: translate(-50%, -50%) rotate(0deg);
}

.privacy-inline-summary[aria-expanded="true"] {
  border-radius: 999px;
}

.privacy-inline-inner {
  width: 100%;
  margin: 0.6rem 0 0;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0.6rem 0.85rem 0.35rem 0.5rem;
  box-shadow: none;
  max-height: none;
  overflow: visible;
}

html[data-theme="light"] .privacy-inline-inner {
  background: transparent;
  box-shadow: none;
}

.privacy-inline-body {
  color: var(--text-primary);
  font-size: 0.9rem;
  line-height: 1.55;
}

.privacy-inline-lede {
  margin: 0 0 1rem 0;
  color: var(--text-primary);
  font-size: 0.85rem;
}

.privacy-inline-body strong {
  color: var(--text-primary);
}

.privacy-inline-body ul {
  margin: 0 0 0.75rem 1.25rem;
  padding: 0;
}

.privacy-inline-body p {
  margin: 0 0 0.75rem 0;
}

.privacy-inline-body code {
  background: rgba(6, 78, 59, 0.66);
  color: #e6fffa;
  border: 1px solid rgba(16, 185, 129, 0.38);
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 0.9em;
}

html[data-theme="light"] .privacy-inline-body code {
  background: rgba(16, 185, 129, 0.2);
  color: #0b3b2e;
  border-color: rgba(16, 185, 129, 0.45);
}

@media (color-gamut: p3) {
  .panel::before {
    opacity: 0.94;
  }

  .model-status-badge.active {
    box-shadow:
      0 0 0 1px rgba(16, 185, 129, 0.24),
      0 8px 20px rgba(16, 185, 129, 0.18);
  }
}

@media (dynamic-range: high) {
  .panel::before {
    opacity: 0.97;
  }

  .model-status-badge.active {
    box-shadow:
      0 0 0 1px rgba(16, 185, 129, 0.32),
      0 10px 24px rgba(16, 185, 129, 0.24);
  }
}

@media (min-width: 700px) {
  .footer-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 1rem;
    row-gap: 0.6rem;
  }

  .privacy-inline-summary {
    grid-column: 2;
    justify-self: center;
  }

  .theme-toggle {
    margin-left: 0;
    grid-column: 3;
    justify-self: end;
  }
}

@media (max-width: 1120px) {
  .problem-solver-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .panel-sidebar,
  .panel-actions {
    order: 2;
  }

  .panel-workflow {
    order: 1;
  }
}

@media (max-width: 740px) {
  header {
    padding: 0.72rem 0.8rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
  }

  .header-left {
    width: 100%;
    gap: 0.7rem;
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .header-title {
    margin: 0;
    align-items: flex-start;
    line-height: 1.08;
    padding-bottom: 0;
  }

  .title-lock {
    padding-right: 0.9rem;
  }

  .title-script {
    top: 76%;
    font-size: clamp(0.88rem, 2.8vw, 1.02rem);
    transform: translate(-12%, -50%) rotate(-8deg);
  }

  .model-status-badge {
    width: 100%;
    justify-content: space-between;
    font-size: 0.78rem;
  }

  .workflow-step {
    margin: 0.5rem 0.72rem 0;
    padding: 0.8rem;
  }

  .panel-header {
    padding: 0.82rem 0.72rem 0.36rem;
  }

  .workflow-status-row {
    margin: 0.65rem 0.72rem 0;
  }

  .step-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .step-header {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }

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

  .action-panel-content {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  .title-script {
    display: none;
  }

  .title-lock {
    padding-right: 0.2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
