/* ============================================================
   Счётчик символов
   ============================================================ */

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

:root {
  --bg:         #0c0d10;
  --surface:    #14161b;
  --surface-2:  #1a1c23;
  --border:     #23262e;
  --border-hi:  #303440;

  --text:       #e8eaf0;
  --text-mid:   #a4a9b6;
  --text-dim:   #6e7380;

  --accent:     #ec9a4d;
  --accent-soft:rgba(236, 154, 77, 0.12);

  --latin:      #58c8b8;
  --cyrillic:   #ec9a4d;
  --other:      #9c8ec9;

  --radius:     0px;
}

html { font-size: 16px; }

body {
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  font-feature-settings: "ss01", "ss02";
  min-height: 100vh;
  color: var(--text);
  line-height: 1.55;
  background:
    radial-gradient(900px 500px at 12% -8%,  rgba(236, 154, 77, 0.055), transparent 65%),
    radial-gradient(800px 480px at 92% 6%,   rgba(88, 200, 184, 0.04),  transparent 65%),
    var(--bg);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Тонкая акцентная линия сверху */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(236, 154, 77, 0.55) 45%,
    rgba(236, 154, 77, 0.55) 55%,
    transparent 100%);
  z-index: 10;
}

/* ============================================================
   Страница
   ============================================================ */

.page {
  flex: 1;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 4.5rem 2rem 3rem;
}

/* ============================================================
   Заголовок
   ============================================================ */

.hero {
  margin-bottom: 3rem;
}

.hero-title {
  font-size: clamp(2.1rem, 4.5vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.05;
  margin-bottom: 0.9rem;
  background: linear-gradient(180deg, #f4f5f9 0%, #b8bcc7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.hero-title::after {
  content: '';
  display: inline-block;
  width: 0.42em;
  height: 0.42em;
  margin-left: 0.14em;
  background: var(--accent);
  vertical-align: baseline;
  transform: translateY(0.03em);
}

.hero-lede {
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--text-mid);
  max-width: 46ch;
  line-height: 1.6;
}

/* ============================================================
   Статистика
   ============================================================ */

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-bottom: 2.5rem;
}

.stat {
  background: var(--surface);
  padding: 1.15rem 1.35rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  position: relative;
  overflow: hidden;
}

.stat::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg,
    rgba(236, 154, 77, 0.35),
    transparent 60%);
  opacity: 0.7;
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.stat-value {
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--text);
}

/* ============================================================
   Редактор
   ============================================================ */

.editor {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.editor-frame {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.editor-frame:focus-within {
  border-color: var(--border-hi);
  box-shadow:
    0 0 0 1px rgba(236, 154, 77, 0.22),
    0 24px 60px -34px rgba(236, 154, 77, 0.35);
}

.highlight-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.highlight-content,
#text-input {
  font-family: inherit;
  font-size: 1.02rem;
  font-weight: 400;
  line-height: 1.7;
  padding: 1.25rem 1.4rem;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  letter-spacing: 0.005em;
  tab-size: 4;
}

.highlight-content {
  color: transparent;
}

#text-input {
  position: relative;
  display: block;
  width: 100%;
  min-height: 260px;
  resize: vertical;
  background: transparent;
  color: transparent;
  caret-color: var(--accent);
  border: none;
  outline: none;
}

#text-input::placeholder {
  color: var(--text-dim);
  opacity: 0.75;
}

/* Цвета символов */
.char-latin    { color: var(--latin); }
.char-cyrillic { color: var(--cyrillic); }
.char-other    { color: var(--other); }

/* ============================================================
   Подвал редактора: легенда + составные символы
   ============================================================ */

.editor-foot {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.35rem;
  font-size: 0.82rem;
  color: var(--text-mid);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: currentColor;
}

.dot-latin    { color: var(--latin); }
.dot-cyrillic { color: var(--cyrillic); }
.dot-other    { color: var(--other); }

/* Разбор составных символов */
.multi-char-info {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-height: 0;
}

.multi-char-info:empty {
  display: none;
}

.multi-char-item {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.32rem 0.7rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-mid);
  font-variant-numeric: tabular-nums;
}

.multi-char-item .seq {
  font-size: 1.1rem;
  line-height: 1;
  color: var(--text);
}

.multi-char-item .len {
  color: var(--accent);
  font-weight: 600;
}

.multi-char-item .count {
  color: var(--text-dim);
}

/* ============================================================
   Дисклеймер и подвал
   ============================================================ */

.disclaimer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-dim);
  max-width: 60ch;
  line-height: 1.6;
}

.footer {
  padding: 1.5rem 2rem 2rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-dim);
  letter-spacing: 0.03em;
}

/* ============================================================
   Мобильная адаптация (по остаточному принципу)
   ============================================================ */

@media (max-width: 680px) {
  .page {
    padding: 2.75rem 1rem 2rem;
  }
  .stats {
    grid-template-columns: 1fr;
  }
  .stat-value {
    font-size: 1.6rem;
  }
  .hero {
    margin-bottom: 2rem;
  }
}
