:root {
  --bg: #0b0b0f;
  --surface: #141418;
  --surface2: #1c1c22;
  --border: #2a2a32;
  --text: #c8c8d0;
  --text-dim: #6a6a78;
  --accent: #e8a849;
  --digraph: #7eb8da;
  --trigraph: #c89dea;
  --novg-special: #e8a849;
  --radius: 6px;
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Fira Code", monospace;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 24px 32px;
  width: 100%;
  flex: 1;
}

header {
  margin-bottom: 32px;
}

header h1 {
  font-size: 20px;
  font-weight: 600;
  color: #eee;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.flag-icon {
  vertical-align: middle;
  border-radius: 2px;
  flex-shrink: 0;
}

header p {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 4px;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
  align-items: start;
}

.io {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-weight: 500;
}

textarea,
.output-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--text);
  resize: vertical;
  min-height: 120px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  line-height: 1.7;
}

textarea:focus {
  border-color: var(--accent);
}

textarea::placeholder {
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 14px;
}

.output-box {
  min-height: 120px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  cursor: text;
  user-select: text;
}

.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}

.bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bar-left span {
  font-size: 12px;
  color: var(--text-dim);
}

button {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

button:hover {
  background: var(--border);
  border-color: var(--text-dim);
}

#copy-btn {
  min-width: 100px;
}

.graph.digraph {
  color: var(--digraph);
}

.graph.trigraph {
  color: var(--trigraph);
}

.graph.single {
  color: var(--text);
}

.graph {
  cursor: help;
  border-bottom: 1px dotted transparent;
}

.graph.digraph {
  border-bottom-color: rgba(126, 184, 218, 0.3);
}

.graph.trigraph {
  border-bottom-color: rgba(200, 157, 234, 0.3);
}

.sep {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 2px 0;
}

.sidebar {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.table-section {
  margin-bottom: 16px;
}

.table-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 500;
}

table {
  border-collapse: collapse;
  width: 100%;
}

td {
  padding: 3px 8px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 14px;
}

td.cyr {
  color: var(--text-dim);
  width: 50%;
  font-size: 13px;
}

td.cyr.clickable {
  cursor: pointer;
}

td.cyr.clickable:hover {
  color: var(--accent);
}

td.novg {
  color: var(--text);
  width: 50%;
}

td.novg.digraph {
  color: var(--digraph);
}

td.novg.trigraph {
  color: var(--trigraph);
}

td.novg.special {
  color: var(--novg-special);
}

.alphabet-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 16px;
}

.alphabet-grid .letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 15px;
  cursor: default;
  transition: border-color 0.15s, background 0.15s;
}

.alphabet-grid .letter.clickable {
  cursor: pointer;
}

.alphabet-grid .letter.clickable:hover {
  border-color: var(--accent);
  background: var(--surface2);
}

.alphabet-grid .letter:hover {
  border-color: var(--text-dim);
  background: var(--surface2);
}

.alphabet-grid .letter.special {
  color: var(--novg-special);
  border-color: rgba(232, 168, 73, 0.25);
}

.alphabet-grid .letter.special:hover {
  border-color: var(--novg-special);
}

footer {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 24px 32px;
  width: 100%;
  border-top: 1px solid var(--border);
}

footer p {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}

footer a {
  color: var(--text-dim);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  transition: color 0.15s;
}

footer a:hover {
  color: var(--accent);
}

.legend {
  display: flex;
  gap: 16px;
  justify-content: flex-start;
  margin-top: 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-dim);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-dot.single {
  background: var(--text);
}

.legend-dot.digraph {
  background: var(--digraph);
}

.legend-dot.special {
  background: var(--novg-special);
}

.mobile-letters {
  display: none;
}

.hidden {
  display: none;
}

@media (max-width: 720px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .mobile-letters {
    display: block;
    margin-bottom: 16px;
  }

  .sidebar .letters-section {
    display: none;
  }

  .sidebar {
    position: static;
    max-height: none;
  }

  main {
    padding: 32px 16px 24px;
  }

  textarea,
  .output-box {
    font-size: 14px;
    padding: 12px;
  }
}
