* { box-sizing: border-box; }

:root {
  --bg-top: #eef4ff;
  --bg-bottom: #fff6ea;
  --text: #2b2450;
  --text-muted: #6b6690;
  --card-bg: #ffffff;
  --border: #e6e2f7;
  --primary: #6c5ce7;
  --primary-dark: #5a4bd6;
  --secondary: #22b3a3;
  --secondary-dark: #1b9a8c;
  --accent-yellow: #ffe58a;
  --accent-pink: #ff6f91;
  --accent-amber: #f5a623;
  --accent-green: #34c38f;
  --success: #2fb380;
  --success-bg: #e6f7ef;
  --error: #e0576b;
  --error-bg: #fdeaed;
  --radius-lg: 22px;
  --radius-md: 14px;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  
  overflow-anchor: none;
}

body {
  margin: 0;
  padding: 32px 16px;
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(160deg, var(--bg-top), var(--bg-bottom));
  color: var(--text);
  font-family: 'Nunito', -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 16px;
}

.page {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 28px 28px 32px;
  box-shadow: 0 14px 34px rgba(70, 60, 140, 0.10);
  border-top: 6px solid var(--primary);
}

.card-search {
  border-top-color: var(--secondary);
}

.card-picture {
  border-top-color: var(--accent-amber);
}

.card-svgdraw {
  border-top-color: var(--accent-pink);
}

.card-shorts {
  border-top-color: var(--accent-green);
}

.card-gptimage {
  border-top-color: var(--accent-yellow);
}

.card-gptsvg {
  border-top-color: var(--accent-pink);
}


.shorts-frame {
  display: block;
  width: min(100%, 315px);
  aspect-ratio: 9 / 16;
  margin: 12px auto 0;
  border: 0;
  border-radius: var(--radius-md);
  background: #000;
}


.check-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 14px 0 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
}

.check-row input {
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  flex-shrink: 0;
  accent-color: var(--primary);
}


.picture-result .picture-prompt {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  word-break: break-word;
}


.field-note {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}


.picture-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 16px;
}

.picture-option .field-label {
  margin-bottom: 6px;
}

.picture-size .field-label {
  margin-bottom: 6px;
}

.picture-size[hidden] {
  display: none;
}

.picture-size-fields {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text-muted);
}

.picture-size-fields input[type="number"] {
  max-width: 140px;
}

.card-picture select:disabled,
.card-picture input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}


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

.picture-result .picture-grid .inline-answer-figure {
  margin: 0;
}

.picture-result .picture-grid .inline-answer-image {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.picture-result .picture-caption {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}


.picture-result {
  margin-top: 16px;
  padding: 16px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  background: #fbfaff;
  text-align: center;
}

.picture-result[hidden] {
  display: none;
}

.picture-result .inline-answer-figure {
  margin: 0 auto;
}

.picture-result .inline-answer-image {
  max-width: min(100%, 640px);
  height: auto;
}

.picture-result figcaption {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.card-access {
  border-top-color: var(--accent-amber);
}

.card-access[hidden] {
  display: none;
}

.card-limit {
  border-top-color: var(--error);
}

.card-limit[hidden] {
  display: none;
}

.card-limit .card-subtitle {
  margin-bottom: 0;
  color: var(--text);
}

.card-pay {
  border-top-color: var(--accent, #2563eb);
}

.card-pay[hidden] {
  display: none;
}

.card-pay .card-subtitle {
  color: var(--text);
}

.pay-body {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.pay-qr {
  width: 200px;
  height: 200px;
  border: 1px solid var(--border, #d0d5dd);
  border-radius: 8px;
  background: #fff;
}

.pay-note {
  flex: 1 1 200px;
  margin: 0;
}

.who-bar.is-exhausted #whoUsed {
  color: var(--error);
}


.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 6px;
}

.card-head h1 {
  margin: 0;
}

.who-bar {
  margin: 0 0 0 auto;
  font-size: 13px;
  color: var(--text-muted);
}

.who-bar strong {
  color: var(--text);
}

button.who-logout {
  padding: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  font-size: 13px;
  color: var(--secondary-dark);
  border-bottom: 2px dashed var(--secondary);
}

.who-logout:hover:not(:disabled) {
  transform: none;
  box-shadow: none;
  color: var(--primary-dark);
  border-bottom-color: var(--primary);
}

.file-warning {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  background: var(--error-bg);
  color: var(--error);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.5;
}

.file-warning a {
  color: inherit;
}

h1 {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 26px;
  margin: 0 0 6px;
  color: var(--text);
}

.card-subtitle {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 15px;
}

.field-label {
  display: block;
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  margin: 14px 0 6px;
}

select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  background: #fbfaff;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
}

select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.15);
}

.providers-panel {
  margin-top: 16px;
}

.providers-panel .field-label {
  margin-top: 0;
}

.providers-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 14px;
  align-items: center;
}

.providers-grid label {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}

.providers-grid select {
  padding: 8px 12px;
  font-size: 15px;
}


.providers-grid .provider-fixed {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
}

@media (max-width: 520px) {
  .providers-grid {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .providers-grid select {
    margin-bottom: 8px;
  }
}

input[type="text"], input[type="number"], input[type="password"], textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  background: #fbfaff;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
}

input[type="number"] {
  max-width: 160px;
}

textarea {
  resize: vertical;
}

input:focus, textarea:not([readonly]):focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.15);
}

textarea[readonly] {
  color: var(--text-muted);
  background: #f6f5fb;
  cursor: default;
  font-size: 13px;
  font-family: 'Consolas', 'SF Mono', monospace;
}

.prompt-details {
  margin-top: 16px;
}

.prompt-details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 4px 0;
}

@media (hover: hover) {
  .prompt-details summary:hover {
    color: var(--primary);
  }
}

.prompt-details textarea {
  margin-top: 8px;
}

.search-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.search-bar input[type="text"] {
  flex: 1;
  min-width: 200px;
}


.search-one {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 10px;
}

.search-one select {
  flex: 1;
  width: auto;
  min-width: 200px;
}

.help-link {
  display: inline-block;
  margin: 8px 0 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--secondary-dark);
  text-decoration: none;
  border-bottom: 2px dashed var(--secondary);
  cursor: pointer;
}

@media (hover: hover) {
  .help-link:hover {
    color: var(--primary-dark);
    border-bottom-color: var(--primary);
  }
}

.help-link[hidden] {
  display: none;
}

.subject-context {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 4px;
  padding: 6px 8px 6px 14px;
  border-radius: 999px;
  background: #e9f8f5;
  color: var(--secondary-dark);
  font-size: 13px;
  font-weight: 700;
}

.subject-context[hidden] {
  display: none;
}

.clear-subject-btn {
  position: relative;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: rgba(34, 179, 163, 0.18);
  color: var(--secondary-dark);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
}

@media (hover: hover) {
  .subject-context .clear-subject-btn:hover {
    background: var(--secondary);
    color: #fff;
    transform: none;
    box-shadow: none;
  }
}

#subjectPicker {
  margin-top: 6px;
}

.subject-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.subject-bar input[type="text"],
.subject-bar input[type="password"] {
  flex: 1;
  min-width: 180px;
}

.topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 4px;
}

.topic-chip {
  padding: 8px 16px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: #fbfaff;
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s ease;
  box-shadow: none;
}

@media (hover: hover) {
  .topic-chips .topic-chip:hover {
    border-color: var(--primary);
    color: var(--primary-dark);
    background: #f2f0fb;
    transform: translateY(-1px);
    box-shadow: none;
  }
}

.topic-chip.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}


.topic-chips .topic-chip-more {
  border-color: transparent;
  background: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
  color: #fff;
  box-shadow: 0 4px 10px rgba(27, 154, 140, 0.25);
}

@media (hover: hover) {
  .topic-chips .topic-chip-more:hover:not(:disabled) {
    border-color: transparent;
    background: linear-gradient(135deg, var(--secondary-dark), #17867a);
    color: #fff;
    box-shadow: 0 6px 14px rgba(27, 154, 140, 0.32);
  }
}

.topic-chips .topic-chip-more:disabled {
  background: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
  color: #fff;
  opacity: 0.7;
  cursor: progress;
}


.topic-chip.is-new {
  animation: topicChipNew 1.8s ease-out;
}

@keyframes topicChipNew {
  from { background: #d4f4ef; border-color: var(--secondary); }
}

@media (prefers-reduced-motion: reduce) {
  .topic-chip.is-new { animation: none; }
}


#topicInput {
  text-overflow: ellipsis;
}


.explain-start {
  margin: 10px 0 0;
}


.examples {
  margin: 26px 0 4px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.examples-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.examples-title {
  margin-right: 2px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
}

.examples-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: #f1eefc;
}

button.examples-tab {
  padding: 5px 14px;
  border-radius: 999px;
  border: none;
  background: transparent;
  box-shadow: none;
  font-size: 13px;
  font-weight: 800;
  color: var(--text-muted);
}

button.examples-tab[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 3px 8px rgba(108, 92, 231, 0.28);
}

button.examples-more {
  position: relative;
  margin-left: auto;
  padding: 0;
  border-radius: 0;
  border: none;
  border-bottom: 2px dashed var(--secondary);
  background: none;
  box-shadow: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--secondary-dark);
}


button.examples-more::after {
  content: "";
  position: absolute;
  inset: -12px -8px;
}

@media (hover: hover) {
  button.examples-tab:hover:not(:disabled) {
    transform: none;
  }

  button.examples-tab:not([aria-pressed="true"]):hover:not(:disabled) {
    box-shadow: none;
    background: rgba(108, 92, 231, 0.10);
    color: var(--primary-dark);
  }

  button.examples-tab[aria-pressed="true"]:hover {
    box-shadow: 0 3px 8px rgba(108, 92, 231, 0.28);
  }

  button.examples-more:hover:not(:disabled) {
    transform: none;
    box-shadow: none;
    color: var(--primary-dark);
    border-bottom-color: var(--primary);
  }
}

.examples-chips {
  margin-top: 12px;
}


.card-explain > .help-link {
  margin-top: 18px;
}


.card-explain > #explainStatus:empty {
  display: none;
}

.examples-chips .topic-chip {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}

.explain-bar {
  margin: 18px 0 4px;
}


.quiz-retry-bar {
  margin-top: 8px;
}

button, .btn, summary, .help-link {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(108, 92, 231, 0.15);
}

button, .btn {
  padding: 12px 22px;
  border-radius: 999px;
  border: none;
  font-size: 15px;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
  box-shadow: 0 6px 16px rgba(70, 60, 140, 0.18);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
}

.btn-secondary {
  background: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
  color: #fff;
}

@media (hover: hover) {
  button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(70, 60, 140, 0.24);
  }
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:disabled {
  background: #dcdaee;
  color: #9490b3;
  cursor: default;
  box-shadow: none;
}

.status-text {
  min-height: 20px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  margin: 14px 0 4px;
}

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


body:not(.dev-mode) .status-text:has(> .tech-line) {
  display: none;
}


.ai-notice {
  margin: 12px 0 0;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: #fff8de;
  border: 1px solid #f6e3a1;
  color: #7a5b00;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
}

.ai-notice[hidden] {
  display: none;
}


.page > .ai-notice {
  margin-top: -14px;
}

.progress {
  margin: 20px 0 4px;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
}

.progress-track {
  height: 14px;
  border-radius: 999px;
  background: #eeebfa;
  box-shadow: inset 0 1px 3px rgba(70, 60, 140, 0.12);
  overflow: hidden;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.35) 50%, rgba(255, 255, 255, 0) 100%),
    linear-gradient(90deg, var(--primary), var(--secondary));
  background-size: 120px 100%, 100% 100%;
  background-repeat: no-repeat;
  animation: progress-shimmer 1.6s linear infinite;
  transition: width 0.5s ease;
}

@keyframes progress-shimmer {
  from { background-position: -120px 0, 0 0; }
  to { background-position: calc(100% + 120px) 0, 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  .progress-fill { animation: none; }
}


.progress-track {
  position: relative;
  z-index: 1;
}

.runner-lane {
  position: relative;
  height: 60px;
  margin-top: -4px;
}

.runner {
  position: absolute;
  bottom: 0;
  left: clamp(110px, calc(var(--pct, 0) * 1%), calc(100% - 110px));
  width: 0;
  height: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transition: left 0.5s ease, opacity 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.runner-jump,
.runner-patrol,
.runner-flip,
.runner-confetti {
  position: absolute;
  left: 0;
  bottom: 0;
}

.runner svg {
  position: absolute;
  bottom: 0;
  display: block;
  overflow: visible;
}

.runner:focus-visible svg {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 8px;
}


.runner-patrol { animation: runner-patrol 5s ease-in-out infinite; }
.runner-flip { animation: runner-flip 5s steps(1) infinite; }
.runner-pace-slow,
.runner-pace-slow .runner-flip { animation-duration: 8s; }
.runner-pace-fast,
.runner-pace-fast .runner-flip { animation-duration: 3.4s; }
.runner-pace-stay,
.runner-pace-stay .runner-flip { animation: none; }

@keyframes runner-patrol {
  0%, 4% { transform: translateX(-46px); }
  46%, 54% { transform: translateX(40px); }
  96%, 100% { transform: translateX(-46px); }
}

@keyframes runner-flip {
  0% { transform: scaleX(1); }
  50% { transform: scaleX(-1); }
}


.runner-boing { animation: runner-boing 0.45s ease-out; }
.runner-hooray { animation: runner-hooray 0.6s ease-in-out 2; }

@keyframes runner-boing {
  0%, 100% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-22px) scale(1.08); }
  75% { transform: translateY(0) scale(1.1, 0.9); }
}

@keyframes runner-hooray {
  0%, 100% { transform: translateY(0) rotate(0); }
  45% { transform: translateY(-26px) rotate(-8deg); }
  60% { transform: translateY(-24px) rotate(8deg); }
}

.runner-confetti span {
  position: absolute;
  left: -3px;
  bottom: 20px;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  opacity: 0;
  animation: runner-confetti 1.3s ease-out forwards;
}

@keyframes runner-confetti {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  60% { transform: translate(calc(var(--dx) * 0.85), var(--dy)) rotate(calc(var(--rot) * 0.7)); opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--dy) + 36px)) rotate(var(--rot)); opacity: 0; }
}


.rn-lg { transform-box: fill-box; transform-origin: 50% 0; animation: rn-swing 0.32s ease-in-out infinite alternate; }
.rn-lg.rn-b { animation-delay: -0.32s; }
.rn-bob { animation: rn-bob 0.32s ease-in-out infinite alternate; }
.rn-flap { transform-box: fill-box; transform-origin: 50% 50%; animation: rn-flap 0.18s linear infinite alternate; }
.rn-fly { animation: rn-fly 1.6s ease-in-out infinite; }
.rn-slowfly { animation-duration: 2.6s; }
.rn-spin { transform-box: fill-box; transform-origin: 50% 50%; animation: rn-spin 0.5s linear infinite; }
.rn-kick { animation: rn-kick 1.25s ease-out infinite; }
.rn-puff { transform-box: fill-box; transform-origin: 50% 50%; animation: rn-puff 1s ease-out infinite; }
.rn-puff.rn-b { animation-delay: -0.5s; }
.rn-puff.rn-up { animation-name: rn-puff-up; }
.rn-cloud { animation-duration: 1.8s; }
.rn-cloud.rn-b { animation-delay: -0.9s; }
.rn-hop { animation: rn-hop 0.62s ease-in-out infinite; }
.rn-hop.rn-quick { animation-duration: 0.42s; }
.rn-hop.rn-big { animation-name: rn-hop-big; animation-duration: 0.7s; }
.rn-seg { animation: rn-seg 0.7s ease-in-out infinite alternate; }
.rn-tail { transform-box: fill-box; transform-origin: 100% 100%; animation: rn-tail 0.4s ease-in-out infinite alternate; }
.rn-wig { transform-box: fill-box; transform-origin: 50% 100%; animation: rn-wig 0.16s linear infinite alternate; }
.rn-prop { transform-box: fill-box; transform-origin: 50% 50%; animation: rn-prop 0.12s linear infinite alternate; }
.rn-flame { transform-box: fill-box; transform-origin: 100% 50%; animation: rn-flame 0.15s linear infinite alternate; }
.rn-squash { transform-box: fill-box; transform-origin: 0 100%; animation: rn-squash 1.2s ease-in-out infinite alternate; }
.rn-orbit { transform-box: fill-box; transform-origin: 50% 50%; animation: rn-orbit 4s ease-in-out infinite; }
.rn-glow { animation: rn-glow 0.8s steps(1) infinite; }
.rn-blink { transform-box: fill-box; transform-origin: 50% 50%; animation: rn-blink 3.2s infinite; }
.rn-page { transform-box: fill-box; transform-origin: 0 50%; animation: rn-page 1.8s ease-in-out infinite; }
.rn-waddle { transform-box: fill-box; transform-origin: 50% 100%; animation: rn-waddle 0.5s ease-in-out infinite alternate; }
.rn-leap { transform-box: fill-box; transform-origin: 50% 50%; animation: rn-leap 1.1s ease-in-out infinite; }
.rn-splash { transform-box: fill-box; transform-origin: 50% 100%; animation: rn-splash 1.1s ease-out infinite; }

@keyframes rn-swing { from { transform: rotate(-24deg); } to { transform: rotate(24deg); } }
@keyframes rn-bob { from { transform: translateY(0); } to { transform: translateY(-2px); } }
@keyframes rn-flap { from { transform: scaleX(1); } to { transform: scaleX(0.2); } }
@keyframes rn-fly {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(4px, -8px); }
  50% { transform: translate(-2px, -3px); }
  75% { transform: translate(3px, -10px); }
}
@keyframes rn-spin { to { transform: rotate(360deg); } }
@keyframes rn-kick {
  0% { transform: translate(0, 0); }
  30% { transform: translate(14px, -9px); }
  55% { transform: translate(22px, 0); }
  100% { transform: translate(0, 0); }
}
@keyframes rn-puff {
  from { transform: translate(0, 0) scale(0.4); opacity: 0.9; }
  to { transform: translate(-14px, -6px) scale(1.4); opacity: 0; }
}
@keyframes rn-puff-up {
  from { transform: translate(0, 0) scale(0.4); opacity: 0.9; }
  to { transform: translate(-10px, -12px) scale(1.5); opacity: 0; }
}
@keyframes rn-hop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-16px); } }
@keyframes rn-hop-big {
  0%, 100% { transform: translateY(0) rotate(0); }
  45% { transform: translateY(-14px) rotate(-6deg); }
}
@keyframes rn-seg { from { transform: translateY(0); } to { transform: translateY(-4px); } }
@keyframes rn-tail { from { transform: rotate(-15deg); } to { transform: rotate(20deg); } }
@keyframes rn-wig { from { transform: rotate(-8deg) translateY(0); } to { transform: rotate(6deg) translateY(-3px); } }
@keyframes rn-prop { from { transform: scaleY(1); } to { transform: scaleY(0.15); } }
@keyframes rn-flame { from { transform: scaleX(1); } to { transform: scaleX(0.55); } }
@keyframes rn-squash { from { transform: scaleX(1); } to { transform: scaleX(1.12); } }
@keyframes rn-orbit {
  0% { transform: translate(-36px, 2px) scaleX(1); }
  25% { transform: translate(0, -6px) scaleX(1); }
  49% { transform: translate(36px, 2px) scaleX(1); }
  50% { transform: translate(36px, 2px) scaleX(-1); }
  75% { transform: translate(0, 10px) scaleX(-1); }
  99% { transform: translate(-36px, 2px) scaleX(-1); }
  100% { transform: translate(-36px, 2px) scaleX(1); }
}
@keyframes rn-glow { 0% { opacity: 1; } 50% { opacity: 0.25; } }
@keyframes rn-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.1); } }
@keyframes rn-page { 0%, 15% { transform: scaleX(1); } 55%, 100% { transform: scaleX(-1); } }
@keyframes rn-waddle { from { transform: rotate(-6deg); } to { transform: rotate(6deg); } }
@keyframes rn-leap {
  0% { transform: translateY(16px) rotate(-40deg); }
  50% { transform: translateY(-16px) rotate(0); }
  100% { transform: translateY(16px) rotate(40deg); }
}
@keyframes rn-splash {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  25% { transform: translateY(-6px) scale(0.6); opacity: 0; }
  100% { opacity: 0; }
}


.pull-scene {
  position: absolute;
  bottom: -7px;
  left: clamp(0px, calc(var(--pct, 0) * 1%), calc(100% - var(--scene-w, 150px) - 6px));
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: left 0.5s ease;
}

.pull-scene svg {
  display: block;
  overflow: visible;
}

.pull-scene.pull-in {
  opacity: 1;
  animation: pull-in 0.8s ease-out;
}

.pull-scene.pull-out {
  opacity: 0;
  animation: pull-out 0.9s ease-in;
}

@keyframes pull-in {
  from { transform: translateX(70px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes pull-out {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(90px); opacity: 0; }
}

.progress-pulling .runner {
  opacity: 0;
  pointer-events: none;
}


.progress-pulling .progress-fill {
  transform-origin: left center;
  animation: progress-shimmer 1.6s linear infinite, progress-tug 0.9s ease-in-out infinite;
}

@keyframes progress-tug {
  0%, 100% { transform: scaleX(1); }
  50% { transform: scaleX(1.03); }
}

.rn-fastspin { animation-duration: 0.35s; }
.rn-heave { transform-box: view-box; animation: rn-heave 0.7s ease-in-out infinite alternate; }
.rn-strain { animation: rn-strain 0.12s linear infinite alternate; }
.rn-wheelie { transform-box: view-box; transform-origin: 45px 69px; animation: rn-wheelie 2.6s ease-in-out infinite; }
.rn-smoke { transform-box: fill-box; transform-origin: 50% 50%; animation: rn-smoke 1.5s ease-out infinite; }
.rn-smoke.rn-b { animation-delay: -0.5s; }
.rn-smoke.rn-c { animation-delay: -1s; }
.rn-dust { animation-duration: 0.8s; }

@keyframes rn-heave { from { transform: rotate(5deg); } to { transform: rotate(13deg); } }
@keyframes rn-strain { from { transform: translate(0, 0); } to { transform: translate(0.8px, -0.8px); } }
@keyframes rn-wheelie {
  0%, 62%, 100% { transform: rotate(0); }
  74% { transform: rotate(-5deg); }
  84% { transform: rotate(-1deg); }
  90% { transform: rotate(-3deg); }
}
@keyframes rn-smoke {
  from { transform: translate(0, 0) scale(0.5); opacity: 0.9; }
  to { transform: translate(-22px, -20px) scale(2); opacity: 0; }
}


@media (prefers-reduced-motion: reduce) {
  .runner,
  .runner *,
  .pull-scene,
  .pull-scene * { animation: none !important; transition: none !important; }
  .progress-pulling .progress-fill { animation: none; }
}

.answer-box {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border-top: 6px solid var(--accent-green);
  box-shadow: 0 14px 34px rgba(70, 60, 140, 0.10);
  padding: 28px 28px 32px;
  min-height: 24px;
  line-height: 1.8;
  font-size: 17px;
}

.answer-box:empty {
  display: none;
}

.answer-box h2, .answer-box h3, .answer-box h4, .answer-box h5, .answer-box h6 {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  color: #3d2b7a;
  line-height: 1.3;
  margin: 22px 0 10px;
}

.answer-box > *:first-child {
  margin-top: 0;
}

.answer-box h2 { font-size: 23px; }
.answer-box h3 { font-size: 20px; }
.answer-box h4, .answer-box h5, .answer-box h6 { font-size: 18px; }

.answer-box ul, .answer-box ol {
  margin: 10px 0 14px;
  padding-left: 28px;
}

.answer-box li {
  margin: 6px 0;
  padding-left: 4px;
}

.answer-box li::marker {
  color: var(--primary);
  font-weight: 800;
}

.answer-box li > ul, .answer-box li > ol {
  margin: 6px 0 4px;
}

.answer-box strong {
  font-weight: 800;
  color: #3d2b7a;
  background: linear-gradient(180deg, transparent 55%, var(--accent-yellow) 55%);
  border-radius: 3px;
}

.math-display {
  margin: 14px 0;
  padding: 4px 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.math-display .katex-display {
  margin: 0;
}

.answer-box .katex {
  font-size: 1.15em;
}

.field-label .katex {
  font-size: 1.05em;
  font-weight: 400;
}

.math-fallback {
  font-family: 'Consolas', 'SF Mono', monospace;
  font-size: 0.9em;
  background: #f2f0fb;
  border-radius: 6px;
  padding: 2px 6px;
}

.inline-answer-figure {
  margin: 16px 0;
  text-align: center;
}


.inline-answer-image.zoomable { cursor: zoom-in; transition: transform 0.25s ease; }
.inline-answer-image.zoomable.zoomed { transform: scale(2); position: relative; z-index: 5; cursor: zoom-out; }

.image-keyword {
  margin-top: 10px;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--accent-yellow);
  color: #7a5b00;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.4;
}

body.dev-mode .image-keyword.dev-only {
  display: inline-block;
}

.image-keyword.problem {
  background: #ffe1e1;
  color: #a12b2b;
}

.inline-svg-image {
  height: auto;
  background: #fff;
}

.inline-answer-image {
  display: block;
  max-width: 100%;
  border-radius: var(--radius-md);
  margin: 0 auto;
  box-shadow: 0 10px 24px rgba(70, 60, 140, 0.16);
  border: 4px solid #fff;
}


.image-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: min(100%, 440px);
  aspect-ratio: 16 / 10;
  margin: 16px auto;
  padding: 10px;
  overflow: hidden;
  border: 2px dashed #d9d3f5;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #f7f5ff, #eef9f7);
  white-space: normal;
  transition: height 0.35s ease, margin 0.35s ease, opacity 0.3s ease, border-width 0.35s ease;
}

.image-slot .slot-art {
  width: min(62%, 190px);
  height: auto;
  overflow: visible;
}

.slot-hill, .slot-sun {
  fill: none;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1 2;
  stroke-dashoffset: 0;
  opacity: 0.55;
}

.slot-hill { stroke: var(--secondary); }
.slot-sun { stroke: var(--accent-amber); }
.slot-pencil { display: none; }

.image-slot-text {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-muted);
  text-align: center;
}

.image-slot.is-active .slot-hill,
.image-slot.is-active .slot-sun { opacity: 1; stroke-dashoffset: 1; }
.image-slot.is-active .slot-hill { animation: slotHill 4.8s linear infinite; }
.image-slot.is-active .slot-sun { animation: slotSun 4.8s linear infinite; }
.image-slot.is-active .slot-pencil { display: inline; animation: slotPencil 4.8s linear infinite; }
.image-slot.is-active { border-color: #c9c0f2; }
.image-slot.is-active .image-slot-text { color: var(--primary-dark); }

.image-slot.is-collapsing {
  height: 0 !important;
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-width: 0;
  opacity: 0;
}

@keyframes slotHill {
  0% { stroke-dashoffset: 1; opacity: 1; }
  50% { stroke-dashoffset: 0; opacity: 1; }
  88% { stroke-dashoffset: 0; opacity: 1; }
  96% { stroke-dashoffset: 0; opacity: 0; }
  100% { stroke-dashoffset: 1; opacity: 0; }
}

@keyframes slotSun {
  0%, 56% { stroke-dashoffset: 1; opacity: 1; }
  72%, 88% { stroke-dashoffset: 0; opacity: 1; }
  96% { stroke-dashoffset: 0; opacity: 0; }
  100% { stroke-dashoffset: 1; opacity: 0; }
}


@keyframes slotPencil {
  0% { transform: translate(12px, 74px); opacity: 1; }
  6.25% { transform: translate(29.4px, 61.5px); }
  12.5% { transform: translate(46px, 56.8px); }
  18.75% { transform: translate(62.6px, 59.1px); }
  25% { transform: translate(80px, 68px); }
  31.25% { transform: translate(97.4px, 76.8px); }
  37.5% { transform: translate(114px, 78.8px); }
  43.75% { transform: translate(130.6px, 72.8px); }
  50% { transform: translate(148px, 58px); }
  56% { transform: translate(111px, 26px); }
  58% { transform: translate(114.2px, 33.8px); }
  60% { transform: translate(122px, 37px); }
  62% { transform: translate(129.8px, 33.8px); }
  64% { transform: translate(133px, 26px); }
  66% { transform: translate(129.8px, 18.2px); }
  68% { transform: translate(122px, 15px); }
  70% { transform: translate(114.2px, 18.2px); }
  72%, 88% { transform: translate(111px, 26px); opacity: 1; }
  96% { transform: translate(111px, 26px); opacity: 0; }
  100% { transform: translate(12px, 74px); opacity: 0; }
}


.inline-answer-figure.is-arriving {
  animation: figureArrive 0.5s ease both;
}

@keyframes figureArrive {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .image-slot, .inline-answer-figure.is-arriving { animation: none; transition: none; }
  .image-slot.is-active .slot-hill,
  .image-slot.is-active .slot-sun { animation: none; stroke-dashoffset: 0; opacity: 1; }
  .image-slot.is-active .slot-pencil { display: none; animation: none; }
}


.image-pill {
  position: fixed;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 40;
  transform: translateX(-50%);
  max-width: calc(100vw - 24px);
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(43, 36, 80, 0.92);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 8px 22px rgba(43, 36, 80, 0.28);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.image-pill[hidden] { display: none; }

.image-pill.is-leaving {
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
}

.inline-image-placeholder {
  display: inline-block;
  color: var(--text-muted);
  font-style: italic;
  background: #f2f0fb;
  border-radius: 8px;
  padding: 2px 8px;
  font-size: 14px;
}

.results {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.result-row {
  display: flex;
  gap: 14px;
  align-items: center;
  background: #fbfaff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

@media (hover: hover) {
  .result-row:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(70, 60, 140, 0.12);
  }
}

.result-row img {
  width: 140px;
  height: 100px;
  object-fit: cover;
  border-radius: 10px;
  flex-shrink: 0;
  background: var(--border);
}

.preview-fallback {
  width: 140px;
  height: 100px;
  border-radius: 10px;
  flex-shrink: 0;
  background: var(--border);
  color: var(--text-muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
}

.result-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-info a {
  color: var(--secondary-dark);
  text-decoration: none;
  word-break: break-all;
  font-size: 13px;
}

.result-info a:hover { text-decoration: underline; }

.result-row.top-pick {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary), 0 10px 22px rgba(108, 92, 231, 0.2);
}

.top-pick-badge {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 800;
  color: #7a5b00;
  background: var(--accent-yellow);
  border-radius: 999px;
  padding: 3px 10px;
}

.score-badge {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 800;
  color: var(--success);
  background: var(--success-bg);
  border-radius: 999px;
  padding: 3px 10px;
}

.score-badge.pending {
  color: var(--text-muted);
  background: #f2f0fb;
}

.source-badge {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  color: var(--secondary-dark);
  background: #eef6fb;
  border-radius: 999px;
  padding: 3px 10px;
}

.quiz-section {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border-top: 6px solid var(--accent-amber);
  box-shadow: 0 14px 34px rgba(70, 60, 140, 0.10);
  padding: 28px 28px 32px;
}

.quiz-section h2 {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 22px;
  margin: 0 0 6px;
  color: var(--text);
}


.more-section {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border-top: 6px solid var(--secondary);
  box-shadow: 0 14px 34px rgba(70, 60, 140, 0.10);
  padding: 28px 28px 32px;
}

.more-section h2 {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 22px;
  margin: 0 0 6px;
  color: var(--text);
}

.more-questions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

button.more-question {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 2px solid #d5f0ec;
  background: #f3fbfa;
  box-shadow: none;
  color: var(--text);
  font-size: 16px;
  text-align: left;
  line-height: 1.4;
}

button.more-question::after {
  content: "→";
  flex-shrink: 0;
  color: var(--secondary-dark);
  font-size: 18px;
}

@media (hover: hover) {
  button.more-question:hover:not(:disabled) {
    border-color: var(--secondary);
    background: #e9f8f5;
    transform: translateY(-1px);
    box-shadow: none;
  }
}

.more-section .status-text:empty {
  display: none;
}

.quiz-section .answer-box {
  border-top-color: var(--accent-amber);
  border-top-width: 5px;
  background: #fffdf5;
  box-shadow: 0 8px 22px rgba(70, 60, 140, 0.08);
  padding: 22px 24px;
  margin-top: 16px;
}

.quiz-questions {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin: 6px 0 4px;
}

.quiz-question .field-label {
  margin-top: 0;
  
  font-size: 17px;
  line-height: 1.5;
}


.quiz-hint {
  margin: -2px 0 8px;
  font-size: 13px;
  color: var(--text-muted);
}


.quiz-check-bar {
  margin-top: 4px;
}


.quiz-question .status-text {
  margin: 10px 0 0;
}

.quiz-question .status-text:empty {
  display: none;
}

.quiz-section .quiz-question .answer-box {
  margin-top: 12px;
}


.char-counter {
  margin: 4px 4px 0;
  text-align: right;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.char-counter.warn { color: #b7791f; }
.char-counter.full { color: var(--error); }


.sample-question {
  margin: 18px 0 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-muted);
}

.sample-question::before {
  content: "Вопрос: ";
  font-weight: 800;
}

.sample-question + ol {
  margin-top: 4px;
  margin-bottom: 0;
}

.dev-only {
  display: none;
}

body.dev-mode .dev-only {
  display: block;
}


.dev-inline {
  display: none;
}

body.dev-mode .dev-inline {
  display: inline;
}

.dev-toggle {
  position: fixed;
  right: 8px;
  bottom: 8px;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: rgba(43, 36, 80, 0.10);
  font-size: 15px;
  line-height: 26px;
  text-align: center;
  box-shadow: none;
  cursor: pointer;
  z-index: 50;
}

@media (hover: hover) {
  .dev-toggle:hover {
    color: rgba(43, 36, 80, 0.5);
    background: rgba(255, 255, 255, 0.7);
  }
}



.help-link {
  position: relative;
}


.help-link::after,
.clear-subject-btn::after {
  content: "";
  position: absolute;
  inset: -12px -8px;
}

.subject-context {
  max-width: 100%;
}

@media (pointer: coarse) {
  .dev-toggle {
    width: 44px;
    height: 44px;
    right: 2px;
    bottom: 2px;
    font-size: 18px;
    line-height: 44px;
  }
}

@media (max-width: 600px) {
  body {
    padding: 14px 12px 28px;
  }

  .page {
    gap: 18px;
  }

  .card, .quiz-section, .more-section {
    padding: 20px 16px 24px;
  }

  .card, .quiz-section, .more-section, .answer-box {
    border-top-width: 5px;
  }

  h1 { font-size: 22px; }
  .quiz-section h2, .more-section h2 { font-size: 20px; }

  
  .examples-chips .topic-chip:nth-child(n+3) {
    display: none;
  }

  .examples-chips .topic-chip {
    min-height: 40px;
    padding: 8px 14px;
  }

  
  .examples-tabs {
    order: 3;
    flex: 1 1 100%;
  }

  button.examples-tab {
    flex: 1 1 0;
    min-height: 36px;
    padding: 5px 8px;
  }

  
  .card-head .who-bar {
    order: -1;
    flex-basis: 100%;
    text-align: right;
  }

  .card-subtitle {
    font-size: 14px;
    margin-bottom: 16px;
  }

  .file-warning {
    padding: 14px 16px;
    font-size: 14px;
  }

  
  .answer-box,
  .quiz-section .answer-box {
    padding: 20px 16px 24px;
    font-size: 16px;
    line-height: 1.7;
  }

  .quiz-section .answer-box {
    padding: 16px 14px 20px;
  }

  .answer-box h2 { font-size: 20px; }
  .answer-box h3 { font-size: 18px; }
  .answer-box h4, .answer-box h5, .answer-box h6 { font-size: 17px; }

  .answer-box ul, .answer-box ol {
    padding-left: 22px;
  }

  
  input[type="text"], input[type="number"], input[type="password"], textarea, textarea[readonly],
  select, .providers-grid select {
    font-size: 16px;
  }

  .providers-grid select {
    min-height: 46px;
  }

  
  .explain-bar .btn {
    width: 100%;
    min-height: 48px;
    border-radius: 26px;
    line-height: 1.3;
  }

  .quiz-check-btn {
    min-height: 44px;
  }

  .search-bar input[type="text"],
  .search-one select,
  .subject-bar input[type="text"],
  .subject-bar input[type="password"] {
    flex: 1 1 100%;
    min-width: 0;
  }

  .search-bar .btn,
  .search-one .btn,
  .subject-bar .btn {
    flex: 1 1 0;
    min-height: 48px;
  }

  .topic-chip {
    min-height: 44px;
    padding: 10px 16px;
  }

  .prompt-details summary {
    padding: 10px 0;
  }

  .result-row {
    flex-direction: column;
    align-items: stretch;
  }

  .result-row img,
  .preview-fallback {
    width: 100%;
    height: 190px;
  }

  .result-info a {
    padding: 6px 0;
  }

  .page > .ai-notice {
    margin-top: -8px;
  }
}

@media (max-width: 360px) {
  body {
    padding: 10px 8px 24px;
  }

  .card, .quiz-section, .more-section {
    padding: 18px 14px 22px;
  }

  h1 { font-size: 20px; }

  .answer-box,
  .quiz-section .answer-box {
    padding-left: 12px;
    padding-right: 12px;
  }
}


.image-credit {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.4;
  color: #667085;
}

.image-credit a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(102, 112, 133, 0.45);
}




.section-ask {
  margin: 14px 0 28px;
  white-space: normal;
  line-height: 1.2;
}


.section-ask:last-child {
  margin-bottom: 0;
}

.section-ask-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 2px solid #d9d3fb;
  border-radius: 999px;
  background: #f4f1ff;
  color: var(--primary-dark);
  font-size: 14px;
  font-weight: 800;
  box-shadow: none;
}

@media (hover: hover) {
  .section-ask-btn:hover:not(:disabled) {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 6px 14px rgba(108, 92, 231, 0.28);
  }
}

.section-ask-btn:focus-visible,
.section-chip:focus-visible,
.section-dialog-close:focus-visible {
  outline: 3px solid rgba(108, 92, 231, 0.45);
  outline-offset: 2px;
}


body:has(.section-dialog[open]) {
  overflow: hidden;
}

.section-dialog {
  width: min(680px, calc(100vw - 24px));
  max-width: none;
  max-height: none;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text);
  overflow: visible;
}


.section-dialog::backdrop {
  background: rgba(43, 36, 80, 0.42);
  -webkit-backdrop-filter: blur(9px) saturate(1.1);
  backdrop-filter: blur(9px) saturate(1.1);
}

.section-dialog-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: min(86vh, 780px);
  max-height: min(86dvh, 780px);
  
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border-top: 6px solid var(--primary);
  box-shadow: 0 28px 70px rgba(43, 36, 80, 0.38);
}

.section-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 8px;
}

.section-dialog-kicker {
  font-size: 13px;
  font-weight: 800;
  color: var(--primary);
}

.section-dialog-title {
  margin: 2px 0 0;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-size: 21px;
  line-height: 1.3;
  color: #3d2b7a;
  overflow-wrap: anywhere;
}

.section-dialog-close {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  background: #f1eefb;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 38px;
  box-shadow: none;
}

@media (hover: hover) {
  .section-dialog-close:hover:not(:disabled) {
    background: #e3defa;
    color: var(--text);
    box-shadow: none;
    transform: none;
  }
}


.section-dialog-source {
  margin: 0 20px;
}

.section-dialog-source summary {
  cursor: pointer;
  padding: 6px 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
}

.section-dialog-source .answer-box {
  max-height: 34vh;
  overflow-y: auto;
  margin: 4px 0 6px;
  padding: 12px 14px;
  border-top-width: 0;
  border-radius: 12px;
  background: #faf9ff;
  box-shadow: none;
  font-size: 15px;
  line-height: 1.65;
}

.section-dialog-log {
  flex: 1 1 auto;
  min-height: 96px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 8px 20px 10px;
  overscroll-behavior: contain;
}

.section-msg {
  max-width: 90%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.section-msg.is-ai {
  align-self: flex-start;
  background: #f3f1ff;
  border-bottom-left-radius: 5px;
}

.section-msg.is-me {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.section-msg strong {
  font-weight: 800;
  color: #3d2b7a;
  background: linear-gradient(180deg, transparent 55%, var(--accent-yellow) 55%);
  border-radius: 3px;
}

.section-msg ul, .section-msg ol {
  margin: 6px 0;
  padding-left: 22px;
  white-space: normal;
}


.section-msg.is-typing {
  display: flex;
  gap: 5px;
  padding: 14px 16px;
}

.section-msg.is-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a79ae8;
  animation: sectionTyping 1.2s infinite ease-in-out;
}

.section-msg.is-typing span:nth-child(2) { animation-delay: 0.15s; }
.section-msg.is-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes sectionTyping {
  0%, 70%, 100% { transform: translateY(0); opacity: 0.55; }
  35% { transform: translateY(-5px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .section-msg.is-typing span { animation: none; opacity: 0.8; }
}


.section-dialog-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 20px 18px;
}

.section-chip {
  padding: 9px 16px;
  border: 2px solid #d9d3fb;
  border-radius: 999px;
  background: #fff;
  color: var(--primary-dark);
  font-size: 15px;
  font-weight: 700;
  box-shadow: none;
}

@media (hover: hover) {
  .section-chip:hover:not(:disabled) {
    background: #f4f1ff;
    box-shadow: none;
    transform: none;
  }
}

.section-chip:disabled {
  border-color: #e6e3f4;
}

.section-dialog-status {
  min-height: 0;
  margin: 8px 20px 0;
}

.section-dialog-status:empty {
  display: none;
}


@media (max-width: 600px) {
  .section-dialog {
    width: 100vw;
    margin: auto 0 0;
  }

  .section-dialog-card {
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-top-width: 5px;
  }

  .section-dialog-head { padding: 16px 16px 6px; }
  .section-dialog-title { font-size: 19px; }
  .section-dialog-source { margin: 0 16px; }
  .section-dialog-log { padding: 8px 16px 10px; }
  .section-msg { max-width: 94%; font-size: 16px; }
  .section-dialog-chips { padding: 6px 16px 16px; }
  .section-chip { min-height: 44px; }
  .section-dialog-status { margin: 8px 16px 0; }
  .section-ask-btn { min-height: 44px; padding: 10px 18px; }
  .section-dialog-close { width: 44px; height: 44px; line-height: 44px; }
}


@media (max-height: 560px) {
  .section-dialog-kicker {
    display: none;
  }

  .section-dialog-head { padding-top: 12px; padding-bottom: 2px; }
  .section-dialog-title { font-size: 18px; }
  .section-dialog-log { min-height: 72px; }
  .section-dialog-source .answer-box { max-height: 26vh; }
}


.providers-grid label.provider-off,
.providers-grid select.provider-off { color: #9a9ab0; opacity: 0.6; cursor: not-allowed; }


.card-fold > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; }
.card-fold > summary::-webkit-details-marker { display: none; }
.card-fold > summary h1 { margin: 0; flex: 1; }
.card-fold > summary::after { content: '▸ развернуть'; font-size: 13px; font-weight: 700; color: var(--primary); }
.card-fold[open] > summary::after { content: '▾ свернуть'; }
.card-fold[open] > summary { margin-bottom: 8px; }


.providers-grid .sub { font-size: 14px; }
.providers-grid .sub[hidden] { display: none; }
.providers-grid label.sub { padding-left: 14px; font-weight: 600; }
.prompt-details[hidden] { display: none; }
