:root {
  --bg: #ffffff;
  --bg-elevated: #f8fafc;
  --tint-1: #f1f5f9;
  --tint-2: #e2e8f0;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-hover: rgba(255, 255, 255, 0.92);
  --border: rgba(15, 23, 42, 0.12);
  --border-bright: rgba(15, 23, 42, 0.18);
  --text: #0f172a;
  --muted: #334155;
  --dim: #475569;

  --cyan: #22d3ee;
  --violet: #a78bfa;
  --indigo: #818cf8;
  --positive: #4ade80;
  --positive-dim: rgba(74, 222, 128, 0.15);
  --negative: #fb7185;
  --negative-dim: rgba(251, 113, 133, 0.15);
  --neutral: #94a3b8;
  --neutral-dim: rgba(148, 163, 184, 0.12);

  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font: "Outfit", system-ui, sans-serif;
  --font-display: "Syne", var(--font);
  --shadow-panel: 0 2px 8px rgba(15, 23, 42, 0.06), 0 18px 48px rgba(15, 23, 42, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 30px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ── Background ── */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-mesh {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(34, 211, 238, 0.14), transparent 55%),
    radial-gradient(ellipse 60% 45% at 90% 10%, rgba(167, 139, 250, 0.16), transparent 50%),
    radial-gradient(ellipse 50% 40% at 50% 100%, rgba(129, 140, 248, 0.1), transparent 55%),
    var(--bg);
}

.bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.22) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.22) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, black, transparent);
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  animation: float 18s ease-in-out infinite;
}

.orb-1 {
  width: 480px;
  height: 480px;
  background: rgba(34, 211, 238, 0.35);
  top: -15%;
  left: -10%;
}

.orb-2 {
  width: 400px;
  height: 400px;
  background: rgba(167, 139, 250, 0.3);
  top: 40%;
  right: -12%;
  animation-delay: -6s;
}

.orb-3 {
  width: 320px;
  height: 320px;
  background: rgba(129, 140, 248, 0.25);
  bottom: -8%;
  left: 35%;
  animation-delay: -12s;
}

@keyframes float {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  33% {
    transform: translate(24px, -20px) scale(1.05);
  }
  66% {
    transform: translate(-16px, 12px) scale(0.97);
  }
}

/* ── Layout ── */
.page {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 3vw, 2rem) 2.5rem;
}

/* ── Header ── */
.header {
  text-align: center;
  margin-bottom: clamp(2rem, 5vw, 3rem);
}

.brand {
  margin-bottom: 1.25rem;
}

.brand-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.eyebrow {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cyan);
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 5vw, 2.75rem);
  /* Добавлено letter-spacing для читаемости */
  letter-spacing: -0.02em;
  font-weight: 800;
  line-height: 1.2;
}

.title-accent {
  background: linear-gradient(120deg, var(--cyan), var(--indigo) 50%, var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin: 0 auto;
  max-width: 32rem;
  color: var(--muted);
  font-size: 1.6rem;
  line-height: 1.4;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.chip {
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--muted);
  background: var(--tint-1);
  border: 1px solid var(--border);
}

.chip-warn {
  color: #fcd34d;
  background: rgba(252, 211, 77, 0.08);
  border-color: rgba(252, 211, 77, 0.2);
}

/* ── Workspace ── */
.workspace {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 900px) {
  .workspace {
    grid-template-columns: 1.05fr 0.95fr;
    align-items: stretch;
  }
}

.panel {
  position: relative;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(24px) saturate(1.2);
  transition: border-color 0.3s, box-shadow 0.3s;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    145deg,
    rgba(15, 23, 42, 0.08) 0%,
    transparent 40%,
    transparent 60%,
    rgba(15, 23, 42, 0.03) 100%
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.panel-input:focus-within {
  border-color: rgba(34, 211, 238, 0.25);
  box-shadow: var(--shadow-panel), 0 0 48px rgba(34, 211, 238, 0.08);
}

.panel-result.has-result {
  border-color: rgba(167, 139, 250, 0.2);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 600;
}

.panel-head p {
  margin: 0.2rem 0 0;
  font-size: 1.2rem;
  color: var(--dim);
}

.panel-icon {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--tint-1);
  border: 1px solid var(--border);
}

.panel-icon-write {
  background:
    linear-gradient(135deg, rgba(34, 211, 238, 0.2), rgba(129, 140, 248, 0.15)),
    rgba(241, 245, 249, 0.92);
  box-shadow: inset 0 0 20px rgba(34, 211, 238, 0.08);
}

.panel-icon-write::after {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  background: center / 20px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2322d3ee' stroke-width='2'%3E%3Cpath d='M12 20h9M16.5 3.5a2.12 2.12 0 013 3L7 19l-4 1 1-4 12.5-12.5z'/%3E%3C/svg%3E");
}

.panel-icon-chart {
  background:
    linear-gradient(135deg, rgba(167, 139, 250, 0.2), rgba(129, 140, 248, 0.12)),
    rgba(241, 245, 249, 0.92);
}

.panel-icon-chart::after {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  background: center / 20px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23a78bfa' stroke-width='2'%3E%3Cpath d='M4 19V5M10 19V9M16 19v-6M22 19V3'/%3E%3C/svg%3E");
}

/* ── Textarea ── */
.textarea-wrap {
  position: relative;
}

.textarea-glow {
  position: absolute;
  inset: -1px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.4), rgba(167, 139, 250, 0.3));
  opacity: 0;
  filter: blur(12px);
  transition: opacity 0.35s;
  z-index: 0;
}

.textarea-wrap:focus-within .textarea-glow {
  opacity: 0.35;
}

textarea {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  min-height: 200px;
  padding: 1.1rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  font: inherit;
  line-height: 1.7;
  font-size: 1rem;
  resize: vertical;
  transition: border-color 0.25s, background 0.25s;
}

textarea:focus {
  outline: none;
  border-color: rgba(34, 211, 238, 0.4);
  background: rgba(255, 255, 255, 0.98);
}

textarea::placeholder {
  color: #64748b;
}

.input-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.65rem;
  font-size: 1rem;
  color: var(--dim);
}

.char-count-warn {
  color: #fcd34d;
}

.kbd-hint kbd {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--tint-1);
  border: 1px solid var(--border);
  color: var(--muted);
}

/* ── Buttons ── */
.actions {
  display: flex;
  gap: 0.65rem;
  margin-top: 1.25rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.9rem 1.35rem;
  border: none;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  /* Увеличено: базовый размер уже увеличен на body */
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.25s, filter 0.2s;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  flex: 1;
  color: #0f172a;
  background: linear-gradient(135deg, var(--cyan) 0%, var(--indigo) 55%, var(--violet) 100%);
  background-size: 200% 200%;
  box-shadow: 0 4px 20px rgba(34, 211, 238, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.btn-primary:hover:not(:disabled) {
  background-position: 100% 0;
  box-shadow: 0 8px 32px rgba(129, 140, 248, 0.4);
}

.btn-secondary {
  color: var(--muted);
  background: var(--tint-1);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  color: var(--text);
  background: var(--tint-2);
  border-color: var(--border-bright);
}

.btn-icon {
  display: flex;
  opacity: 0.85;
}

.btn-spinner {
  width: 1.15rem;
  height: 1.15rem;
  border: 2px solid rgba(15, 23, 42, 0.25);
  border-top-color: #0f172a;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.error-msg {
  margin: 1rem 0 0;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: #9f1239;
  background: rgba(251, 113, 133, 0.08);
  border: 1px solid rgba(251, 113, 133, 0.25);
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

/* ── Empty state ── */
.result-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  padding: 2rem 1rem;
  text-align: center;
}

.empty-illustration {
  position: relative;
  width: 120px;
  height: 120px;
  margin-bottom: 1.5rem;
}

.empty-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px dashed rgba(15, 23, 42, 0.14);
  animation: spin 24s linear infinite;
}

.empty-dot {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.empty-dot-a {
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--neutral);
  box-shadow: 0 0 16px var(--neutral);
}

.empty-dot-b {
  bottom: 20px;
  left: 16px;
  background: var(--positive);
  box-shadow: 0 0 16px var(--positive);
}

.empty-dot-c {
  bottom: 20px;
  right: 16px;
  background: var(--negative);
  box-shadow: 0 0 16px var(--negative);
}

.empty-title {
  margin: 0 0 0.35rem;
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--muted);
}

.empty-desc {
  margin: 0;
  font-size: 1rem;
  color: var(--dim);
  max-width: 16rem;
}

/* ── Result body ── */
.result-body {
  animation: reveal 0.5s var(--ease-out);
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.score-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  border-radius: var(--radius-md);
  background: var(--tint-1);
  border: 1px solid var(--border);
}

.score-ring {
  position: relative;
  flex-shrink: 0;
  width: 100px;
  height: 100px;
}

.score-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: rgba(15, 23, 42, 0.08);
  stroke-width: 8;
}

.ring-fill {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 326.73;
  transition: stroke-dashoffset 0.9s var(--ease-out), stroke 0.3s;
}

.score-card.positive .ring-fill {
  stroke: var(--positive);
  filter: drop-shadow(0 0 8px rgba(74, 222, 128, 0.5));
}

.score-card.negative .ring-fill {
  stroke: var(--negative);
  filter: drop-shadow(0 0 8px rgba(251, 113, 133, 0.5));
}

.score-card.neutral .ring-fill {
  stroke: var(--neutral);
  filter: drop-shadow(0 0 8px rgba(148, 163, 184, 0.4));
}

.score-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.score-info {
  flex: 1;
  min-width: 0;
}

.score-caption {
  margin: 0.5rem 0 0;
  font-size: 1rem;
  color: var(--dim);
}

.sentiment-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem 0.5rem 0.65rem;
  border-radius: 999px;
  font-size: 1.5rem;
  font-weight: 700;
  overflow: hidden;
}

.badge-glow {
  position: absolute;
  inset: 0;
  opacity: 0.5;
  filter: blur(12px);
}

.sentiment-badge.positive {
  color: var(--positive);
  background: var(--positive-dim);
  border: 1px solid rgba(74, 222, 128, 0.25);
}

.sentiment-badge.positive .badge-glow {
  background: var(--positive);
}

.sentiment-badge.negative {
  color: var(--negative);
  background: var(--negative-dim);
  border: 1px solid rgba(251, 113, 133, 0.25);
}

.sentiment-badge.negative .badge-glow {
  background: var(--negative);
}

.sentiment-badge.neutral {
  color: var(--neutral);
  background: var(--neutral-dim);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.sentiment-badge.neutral .badge-glow {
  background: var(--neutral);
}

.badge-icon {
  position: relative;
  z-index: 1;
  font-size: 1.8rem;
  line-height: 1;
}

#sentiment-label {
  position: relative;
  z-index: 1;
}

.result-quote {
  margin: 0 0 1.25rem;
  padding: 1rem 1.1rem 1rem 1.25rem;
  border: none;
  border-left: 3px solid var(--indigo);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: rgba(129, 140, 248, 0.06);
  color: var(--muted);
  /* Увеличено: было 0.92rem -> стало 1.1rem */
  font-size: 1.1rem;
  font-style: italic;
  line-height: 1.6;
}

.probs-head {
  margin-bottom: 0.85rem;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

.probs {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.prob-row {
  display: grid;
  grid-template-columns: 6.5rem 1fr 2.75rem;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  transition: background 0.25s;
}

.prob-row.is-winner {
  background: var(--tint-1);
}

.prob-name {
  font-size: 1rem;
  color: var(--dim);
  transition: color 0.25s;
}

.prob-row.is-winner .prob-name {
  color: var(--text);
  font-weight: 600;
}

.prob-track {
  height: 10px;
  border-radius: 999px;
  background: var(--tint-2);
  overflow: hidden;
}

.prob-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  transition: width 0.85s var(--ease-out);
}

.prob-fill.positive {
  background: linear-gradient(90deg, #16a34a, var(--positive));
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.4);
}

.prob-fill.negative {
  background: linear-gradient(90deg, #e11d48, var(--negative));
  box-shadow: 0 0 12px rgba(251, 113, 133, 0.4);
}

.prob-fill.neutral {
  background: linear-gradient(90deg, #64748b, var(--neutral));
}

.prob-value {
  text-align: right;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  color: var(--dim);
}

.prob-row.is-winner .prob-value {
  color: var(--text);
  font-weight: 700;
}

/* ── Footer ── */
.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 2.5rem;
  font-size: 1rem;
  color: var(--dim);
}

.footer-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--positive);
  box-shadow: 0 0 8px var(--positive);
  animation: pulse 2s ease infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* ── Scrollbar ── */
textarea::-webkit-scrollbar {
  width: 8px;
}

textarea::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.65);
  border-radius: 4px;
}

@media (max-width: 599px) {
  .score-card {
    flex-direction: column;
    text-align: center;
  }

  .prob-row {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .prob-value {
    text-align: left;
  }
}