/* ==========================================================================
   JevStudio — a small, spacey design system.
   ========================================================================== */

:root {
  --bg: #04050c;
  --panel: rgba(255, 255, 255, 0.038);
  --panel-2: rgba(255, 255, 255, 0.06);
  --raised: rgba(9, 12, 26, 0.72);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.17);

  --text: #e9edfb;
  --muted: #939dc0;
  --faint: #626b8e;

  --indigo: #7c8cff;
  --teal: #4ee0d0;
  --violet: #c07cff;
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #fb7185;

  --grad: linear-gradient(120deg, var(--teal), var(--indigo) 52%, var(--violet));
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 24px 60px -32px rgba(0, 0, 0, 0.9);
  --ease: cubic-bezier(0.22, 0.7, 0.28, 1);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto, "Helvetica Neue",
    Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  letter-spacing: 0.006em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(1100px 780px at 8% -12%, rgba(124, 140, 255, 0.22), transparent 62%),
    radial-gradient(900px 640px at 96% -4%, rgba(78, 224, 208, 0.14), transparent 58%),
    radial-gradient(1000px 900px at 62% 112%, rgba(192, 124, 255, 0.17), transparent 60%),
    var(--bg);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 0%, transparent 55%, rgba(0, 0, 0, 0.55));
}

#stars {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.85;
}

/* --- Base details -------------------------------------------------------- */

::selection {
  background: rgba(124, 140, 255, 0.35);
  color: #fff;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.13);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.24);
  background-clip: content-box;
}

/* Keep taps snappy and stop the iOS rubber-band from fighting the drawer. */
button,
.example,
.chip-btn,
.tab,
.fab {
  touch-action: manipulation;
}

html {
  overscroll-behavior-y: none;
}

/* --- Typography ---------------------------------------------------------- */

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.grad {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* --- Top bar ------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) clamp(16px, 4vw, 40px) 14px;
  backdrop-filter: blur(14px) saturate(140%);
  background: linear-gradient(180deg, rgba(4, 5, 12, 0.86), rgba(4, 5, 12, 0.32) 70%, transparent);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  font-weight: 600;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
}

.brand-orb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--grad);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25) inset, 0 0 18px rgba(124, 140, 255, 0.8);
  animation: breathe 5.5s var(--ease) infinite;
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.12);
    filter: brightness(1.25);
  }
}

.brand-name em {
  font-style: normal;
  color: var(--muted);
  font-weight: 500;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  font-size: 0.76rem;
  color: var(--muted);
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 0 rgba(78, 224, 208, 0.5);
  transition: background 0.3s;
}

.status.is-live .status-dot {
  background: var(--teal);
  animation: pulse 2.4s infinite;
}
.status.is-demo .status-dot {
  background: var(--warn);
}
.status.is-down .status-dot {
  background: var(--bad);
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(78, 224, 208, 0.55);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(78, 224, 208, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(78, 224, 208, 0);
  }
}

/* --- Buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 550;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--panel-2);
  cursor: pointer;
  transition: transform 0.18s var(--ease), background 0.2s, border-color 0.2s, box-shadow 0.2s,
    opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0) scale(0.985);
}
.btn:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn.primary {
  color: #07080f;
  background: var(--grad);
  background-size: 160% 160%;
  box-shadow: 0 10px 30px -12px rgba(124, 140, 255, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.14) inset;
  font-weight: 650;
}

.btn.primary:hover {
  animation: sheen 3s var(--ease) infinite;
  box-shadow: 0 14px 38px -12px rgba(124, 140, 255, 1), 0 0 0 1px rgba(255, 255, 255, 0.2) inset;
}

@keyframes sheen {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}
.btn.ghost:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--panel);
}

.btn.sm {
  padding: 7px 13px;
  font-size: 0.8rem;
}
.btn.icon-only {
  padding: 9px;
  width: 38px;
  height: 38px;
}
.btn svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.kbd {
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(0, 0, 0, 0.18);
  opacity: 0.75;
}

.chip-btn {
  font: inherit;
  font-size: 0.76rem;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.18s var(--ease);
}
.chip-btn:hover {
  color: var(--text);
  border-style: solid;
  border-color: var(--indigo);
  background: rgba(124, 140, 255, 0.12);
}

/* --- Page + hero --------------------------------------------------------- */

.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 8px clamp(16px, 4vw, 40px) 120px;
}

.hero {
  padding: clamp(18px, 5vw, 52px) 0 clamp(20px, 4vw, 36px);
  max-width: 780px;
  animation: rise 0.7s var(--ease) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

.eyebrow {
  margin: 0 0 14px;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--faint);
}

.hero h1 {
  font-size: clamp(2rem, 6.4vw, 3.5rem);
  margin-bottom: 16px;
}

.lede {
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.95rem, 2.2vw, 1.08rem);
  max-width: 62ch;
}

.lede strong {
  color: var(--text);
  font-weight: 600;
}

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 26px;
}

.example {
  font: inherit;
  font-size: 0.82rem;
  padding: 9px 15px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s var(--ease);
  backdrop-filter: blur(10px);
}

.example:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--panel-2);
  transform: translateY(-2px);
  box-shadow: 0 12px 26px -18px rgba(124, 140, 255, 0.9);
}

/* --- Tabs (mobile) ------------------------------------------------------- */

.tabs {
  display: none;
  gap: 6px;
  padding: 5px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
}

.tab {
  flex: 1;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 550;
  padding: 9px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  position: relative;
  transition: all 0.2s var(--ease);
}

.tab.is-active {
  color: #07080f;
  background: var(--grad);
}

.tab-dot {
  position: absolute;
  top: 7px;
  right: 14px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
}

/* --- Workspace + panels -------------------------------------------------- */

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: clamp(14px, 2vw, 22px);
  align-items: start;
}

.panel {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018));
  backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow);
  padding: clamp(16px, 2.4vw, 24px);
  animation: rise 0.7s var(--ease) both;
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  opacity: 0.6;
}

#resultsPanel {
  animation-delay: 0.08s;
  position: sticky;
  top: 78px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-head h2 {
  font-size: 1rem;
  letter-spacing: 0.01em;
}

.panel-head-actions {
  display: flex;
  gap: 8px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.7rem;
  color: var(--faint);
}

.meta span {
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.2);
  font-family: var(--mono);
}

/* --- Fields -------------------------------------------------------------- */

.field {
  margin-bottom: 22px;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.field-head label,
.field-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.hint {
  font-size: 0.72rem;
  color: var(--faint);
  font-family: var(--mono);
}

.hint.is-json {
  color: var(--teal);
}

.questions-head {
  margin-bottom: 12px;
}

.add-menu {
  display: flex;
  align-items: center;
  gap: 6px;
}

.input {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(2, 3, 10, 0.55);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  padding: 11px 13px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  resize: vertical;
}

.input.mono {
  font-family: var(--mono);
  font-size: 0.83rem;
  line-height: 1.6;
}

.input::placeholder {
  color: var(--faint);
}

.input:focus {
  outline: none;
  border-color: rgba(124, 140, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(124, 140, 255, 0.16);
  background: rgba(2, 3, 10, 0.75);
}

/* --- Question cards ------------------------------------------------------ */

.questions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.q-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(6, 8, 20, 0.5);
  padding: 14px;
  animation: rise 0.4s var(--ease) both;
  transition: border-color 0.2s;
}

.q-card:hover {
  border-color: var(--border-strong);
}

.q-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 11px;
}

.q-type {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.q-type[data-type="noul"] {
  color: var(--teal);
  background: rgba(78, 224, 208, 0.12);
  border-color: rgba(78, 224, 208, 0.28);
}
.q-type[data-type="choice"] {
  color: var(--indigo);
  background: rgba(124, 140, 255, 0.13);
  border-color: rgba(124, 140, 255, 0.3);
}
.q-type[data-type="score"] {
  color: var(--violet);
  background: rgba(192, 124, 255, 0.13);
  border-color: rgba(192, 124, 255, 0.3);
}

.q-id {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 6px 8px;
  border-radius: 8px;
  transition: background 0.2s;
}

.q-id:hover,
.q-id:focus {
  background: rgba(255, 255, 255, 0.05);
  outline: none;
}

.q-id::placeholder {
  color: var(--faint);
}

.q-remove {
  border: 0;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  line-height: 1;
  transition: all 0.18s;
}

.q-remove:hover {
  color: var(--bad);
  background: rgba(251, 113, 133, 0.12);
}

.q-label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 10px 0 6px;
}

.q-criteria {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.crit-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.crit-row .input {
  padding: 8px 10px;
  font-size: 0.83rem;
}

.crit-row .opt {
  flex: 0 0 34%;
  font-family: var(--mono);
}

.crit-row .level-n {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
}

.crit-row .rm {
  border: 0;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  transition: all 0.18s;
}

.crit-row .rm:hover {
  color: var(--bad);
  background: rgba(251, 113, 133, 0.12);
}

.add-mini {
  align-self: flex-start;
  font: inherit;
  font-size: 0.76rem;
  padding: 6px 12px;
  margin-top: 3px;
  border-radius: 999px;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.18s;
}

.add-mini:hover {
  color: var(--text);
  border-color: var(--indigo);
  border-style: solid;
}

.noul-criteria {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* --- Run bar ------------------------------------------------------------- */

.run-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.run-meta {
  margin: 0;
  font-size: 0.76rem;
  color: var(--faint);
}

.run-meta.is-error {
  color: var(--bad);
}

.btn.primary.is-loading .btn-label::after {
  content: "…";
}

.spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.25);
  border-top-color: rgba(0, 0, 0, 0.8);
  animation: spin 0.7s linear infinite;
}

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

/* --- Results ------------------------------------------------------------- */

.results {
  display: flex;
  flex-direction: column;
  gap: 13px;
  min-height: 120px;
}

.empty {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 22px;
  padding: 44px 20px;
  color: var(--faint);
  font-size: 0.88rem;
}

.empty p {
  margin: 0;
  max-width: 34ch;
}

.empty-orb {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #ffffff, #8fa2ff 46%, #c07cff);
  box-shadow: 0 0 44px -8px rgba(124, 140, 255, 0.95);
  animation: breathe 6s var(--ease) infinite;
}

.empty-orb::after {
  content: "";
  position: absolute;
  inset: -16px -22px;
  border-radius: 50%;
  border: 1px solid rgba(124, 140, 255, 0.45);
  transform: rotate(-24deg);
}

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

.answer {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(6, 8, 20, 0.5);
  padding: 15px;
  animation: rise 0.5s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 55ms);
}

.answer-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.answer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.answer-id {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.confidence {
  font-size: 0.7rem;
  font-family: var(--mono);
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
  flex: 0 0 auto;
}

.answer .q-type {
  font-size: 0.58rem;
  padding: 3px 7px;
  flex: 0 0 auto;
}

.confidence[data-band="high"] {
  color: var(--good);
  border-color: rgba(74, 222, 128, 0.32);
  background: rgba(74, 222, 128, 0.1);
}
.confidence[data-band="mid"] {
  color: var(--warn);
  border-color: rgba(251, 191, 36, 0.32);
  background: rgba(251, 191, 36, 0.1);
}
.confidence[data-band="low"] {
  color: var(--bad);
  border-color: rgba(251, 113, 133, 0.32);
  background: rgba(251, 113, 133, 0.1);
}

.answer-value {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 2px 0 12px;
}

.big {
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

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

.dist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dist-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 3.4rem;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 5px 10px;
}

.dist-label {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.dist-label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dist-label.is-winner {
  color: var(--text);
  font-weight: 600;
}

.dist-label.is-winner::before {
  content: "▸";
  color: var(--teal);
}

.track {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
  grid-column: 1;
  grid-row: 2;
}

.track i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--indigo), var(--violet));
  transition: width 0.7s var(--ease);
}

.dist-row.is-winner .track i {
  background: linear-gradient(90deg, var(--teal), var(--indigo));
}

.dist-pct {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  text-align: right;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.big.opt {
  font-size: clamp(1.15rem, 3.4vw, 1.5rem);
  overflow-wrap: anywhere;
}

.noul-scale {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
  margin-top: 4px;
}

.noul-scale i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--violet), var(--indigo) 55%, var(--teal));
  transition: width 0.8s var(--ease);
}

.noul-scale .mid {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.3);
}

.big.opt {
  font-size: clamp(1.15rem, 3.4vw, 1.5rem);
  overflow-wrap: anywhere;
}

.apply-preview {
  margin: 11px 0 0;
  max-height: 220px;
  overflow: auto;
  padding: 11px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: rgba(2, 3, 10, 0.7);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* --- Architect call to action -------------------------------------------- */

.architect-cta {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 13px;
  text-align: left;
  padding: 12px 14px;
  margin-bottom: 22px;
  border: 1px solid transparent;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(124, 140, 255, 0.11), rgba(192, 124, 255, 0.06)) padding-box,
    linear-gradient(120deg, rgba(78, 224, 208, 0.6), rgba(124, 140, 255, 0.5), rgba(192, 124, 255, 0.6))
      border-box;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: transform 0.22s var(--ease), box-shadow 0.25s;
  -webkit-tap-highlight-color: transparent;
}

.architect-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 44px -26px rgba(124, 140, 255, 1);
}

.architect-cta:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 3px;
}

.cta-spark {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--grad);
  color: #07080f;
  box-shadow: 0 0 24px -4px rgba(124, 140, 255, 0.9);
}

.cta-spark svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.cta-text {
  flex: 1;
  min-width: 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--muted);
}

.cta-text strong {
  display: block;
  margin-bottom: 1px;
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--text);
}

.cta-arrow {
  flex: 0 0 auto;
  font-size: 1.05rem;
  color: var(--muted);
  transition: transform 0.22s var(--ease), color 0.22s;
}

.architect-cta:hover .cta-arrow {
  transform: translateX(4px);
  color: var(--text);
}

/* --- Drawer / assistant -------------------------------------------------- */

.fab {
  position: fixed;
  right: clamp(16px, 4vw, 30px);
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  /* Icon-only by default: on desktop the page has side margins, so a compact
     round button never covers the answers panel. The pill returns on mobile. */
  padding: 15px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(135deg, rgba(15, 18, 40, 0.96), rgba(28, 22, 56, 0.96));
  backdrop-filter: blur(16px);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 20px 48px -18px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(124, 140, 255, 0.28),
    0 0 32px -8px rgba(124, 140, 255, 0.6);
  transition: transform 0.22s var(--ease), box-shadow 0.22s, opacity 0.22s;
  -webkit-tap-highlight-color: transparent;
}

.fab span {
  display: none;
}

.fab.is-hidden {
  opacity: 0;
  transform: translateY(14px) scale(0.9);
  pointer-events: none;
}

/* A slow halo so the eye finds it without being obnoxious. */
.fab::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  border: 1px solid rgba(124, 140, 255, 0.55);
  animation: halo 3.2s var(--ease) infinite;
  pointer-events: none;
}

@keyframes halo {
  0% {
    transform: scale(1);
    opacity: 0.65;
  }
  70%,
  100% {
    transform: scale(1.16);
    opacity: 0;
  }
}

.fab svg {
  width: 19px;
  height: 19px;
  fill: var(--teal);
}

.fab:hover {
  transform: translateY(-3px);
  box-shadow: 0 26px 58px -18px rgba(124, 140, 255, 0.75), 0 0 0 1px rgba(124, 140, 255, 0.5),
    0 0 40px -6px rgba(124, 140, 255, 0.8);
}

.fab:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 3px;
}

.drawer {
  position: fixed;
  z-index: 60;
  top: 0;
  right: 0;
  height: 100dvh;
  width: min(440px, 100vw);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(8, 10, 24, 0.96), rgba(5, 6, 14, 0.98));
  backdrop-filter: blur(24px) saturate(150%);
  box-shadow: -30px 0 80px -40px rgba(0, 0, 0, 1);
  transform: translateX(102%);
  transition: transform 0.42s var(--ease);
  will-change: transform;
}

.drawer.is-open {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: calc(18px + env(safe-area-inset-top)) 18px 14px;
  border-bottom: 1px solid var(--border);
}

.drawer-title {
  min-width: 0;
}

.drawer-head h2 {
  font-size: 1rem;
}

.drawer-sub {
  margin: 4px 0 0;
  font-size: 0.74rem;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.model-bar label {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}

.model-select {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 0.78rem;
  font-family: var(--mono);
  color: var(--text);
  padding: 7px 9px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(2, 3, 10, 0.7);
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}

.model-select:focus {
  outline: none;
  border-color: rgba(124, 140, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(124, 140, 255, 0.16);
}

.model-select optgroup {
  color: var(--faint);
  background: #0a0c18;
}

.model-select option {
  color: var(--text);
  background: #0a0c18;
  font-family: var(--mono);
}

.model-price {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--faint);
  white-space: nowrap;
}

.msg-meta {
  align-self: flex-start;
  margin: -6px 0 2px 4px;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--faint);
  animation: rise 0.35s var(--ease) both;
}

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
}

.msg {
  max-width: 88%;
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 0.87rem;
  line-height: 1.55;
  animation: rise 0.35s var(--ease) both;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(124, 140, 255, 0.9), rgba(192, 124, 255, 0.85));
  color: #07080f;
  border-bottom-right-radius: 6px;
  font-weight: 500;
}

.msg.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--border);
  border-bottom-left-radius: 6px;
}

.msg.err {
  border-color: rgba(251, 113, 133, 0.4);
  color: #ffd7dd;
  background: rgba(251, 113, 133, 0.1);
}

.msg.typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.msg.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: blink 1.3s infinite;
}
.msg.typing i:nth-child(2) {
  animation-delay: 0.18s;
}
.msg.typing i:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes blink {
  0%,
  60%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.apply-card {
  align-self: flex-start;
  width: 100%;
  border: 1px solid rgba(78, 224, 208, 0.3);
  background: linear-gradient(180deg, rgba(78, 224, 208, 0.09), rgba(124, 140, 255, 0.06));
  border-radius: 16px;
  padding: 13px;
  animation: rise 0.4s var(--ease) both;
}

.apply-card h3 {
  font-size: 0.86rem;
  margin-bottom: 6px;
}

.apply-desc {
  font-size: 0.76rem;
  color: var(--muted);
  margin: 0 0 11px;
}

.apply-actions {
  display: flex;
  gap: 8px;
}

.suggest {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  padding: 0 18px 12px;
}

.suggest button {
  font: inherit;
  font-size: 0.74rem;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.18s;
}

.suggest button:hover {
  color: var(--text);
  border-color: var(--indigo);
}

.composer {
  display: flex;
  gap: 9px;
  align-items: flex-end;
  padding: 12px 18px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}

.composer .input {
  resize: none;
  max-height: 160px;
  min-height: 42px;
  border-radius: 14px;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(2, 3, 8, 0.6);
  backdrop-filter: blur(3px);
  animation: fade 0.3s var(--ease) both;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

/* --- Toast --------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  z-index: 80;
  padding: 11px 20px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(10, 12, 26, 0.95);
  backdrop-filter: blur(14px);
  font-size: 0.84rem;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s var(--ease);
  pointer-events: none;
  max-width: min(90vw, 460px);
  text-align: center;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* --- Responsive ---------------------------------------------------------- */

@media (max-width: 900px) {
  .tabs {
    display: flex;
    position: sticky;
    top: 66px;
    z-index: 30;
    backdrop-filter: blur(14px);
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .workspace[data-tab="builder"] #resultsPanel {
    display: none;
  }
  .workspace[data-tab="results"] #builderPanel {
    display: none;
  }

  #resultsPanel {
    position: static;
  }
}

@media (max-width: 900px) {
  /* On mobile the topbar label is hidden and the CTA lives in the other tab,
     so the floating button keeps its label. */
  .fab {
    gap: 9px;
    padding: 13px 20px;
    border-radius: 999px;
  }
  .fab span {
    display: inline;
  }
}

@media (max-width: 620px) {
  .assistant-btn-label {
    display: none;
  }
  .assistant-btn {
    padding: 9px;
    width: 38px;
    height: 38px;
  }
}

@media (max-width: 560px) {
  .status-text {
    display: none;
  }
  .status {
    padding: 7px;
  }
  .noul-criteria {
    grid-template-columns: 1fr;
  }
  .crit-row .opt {
    flex: 0 0 40%;
  }
  .panel {
    border-radius: 18px;
  }
  .cta-text {
    font-size: 0.78rem;
  }
  .drawer {
    top: auto;
    bottom: 0;
    height: min(88dvh, 720px);
    width: 100%;
    border-left: 0;
    border-top: 1px solid var(--border-strong);
    border-radius: 24px 24px 0 0;
    transform: translateY(103%);
  }
  .drawer.is-open {
    transform: translateY(0);
  }
}

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