:root {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #151b23;
  --surface-2: #1c2430;
  --surface-3: #232d3b;
  --text: #f4f7fb;
  --muted: #9eabbc;
  --line: #2d3949;
  --accent: #66e3b4;
  --accent-strong: #2fc48f;
  --warning: #f5c45b;
  --danger: #ef7d86;
  --covered: #2fba88;
  --duplicate: #d39a42;
  --uncovered: #526176;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(60, 139, 255, 0.11), transparent 33rem),
    radial-gradient(circle at 85% 15%, rgba(47, 196, 143, 0.10), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0 40px;
}

.hero {
  max-width: 780px;
  margin-bottom: 30px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 9px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 700px;
  margin-bottom: 16px;
  font-size: clamp(2.35rem, 7vw, 4.65rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.intro {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.15rem);
  line-height: 1.7;
}

.entry-card,
.panel {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  background: rgba(21, 27, 35, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.entry-card {
  padding: clamp(22px, 5vw, 38px);
  margin-bottom: 22px;
}

.panel {
  padding: clamp(20px, 4vw, 32px);
  margin-top: 22px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.section-heading.compact {
  margin-bottom: 20px;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
  letter-spacing: -0.025em;
}

.ghost-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: 160ms ease;
}

.ghost-button:hover,
.ghost-button:focus-visible {
  border-color: var(--accent);
  color: var(--text);
  outline: none;
}

.word-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 20px;
  align-items: center;
  margin-bottom: 28px;
}

.word-field {
  display: grid;
  gap: 9px;
}

.word-field > span {
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--muted);
}

.word-field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface-2);
  color: var(--text);
  padding: 18px 20px;
  font-size: clamp(1.55rem, 5vw, 2.45rem);
  font-weight: 850;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  transition: 160ms ease;
}

.word-field input::placeholder {
  color: #586678;
}

.word-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(102, 227, 180, 0.11);
  outline: none;
}

.word-field small {
  color: var(--muted);
  font-size: 0.78rem;
}

.word-field input.invalid-word {
  border-color: #ef6b73;
  box-shadow: 0 0 0 4px rgba(239, 107, 115, 0.1);
}

.word-field input.invalid-word:focus {
  border-color: #ef6b73;
  box-shadow: 0 0 0 4px rgba(239, 107, 115, 0.16);
}

.word-field small.validation-error {
  color: #ff8a91;
  font-weight: 750;
}

.plus {
  color: var(--accent);
  font-size: 2rem;
  font-weight: 300;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 14px;
}

.summary-card {
  min-height: 142px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface-2);
}

.summary-card.primary {
  border-color: rgba(102, 227, 180, 0.35);
  background: linear-gradient(145deg, rgba(47, 196, 143, 0.14), var(--surface-2) 70%);
}

.summary-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.summary-card strong {
  font-size: clamp(1.8rem, 4vw, 2.55rem);
  letter-spacing: -0.045em;
}

.summary-card > span:last-child {
  color: var(--muted);
  font-size: 0.79rem;
  line-height: 1.4;
}

.priority-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.priority-letter {
  min-width: 58px;
  display: grid;
  gap: 3px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  text-align: center;
}

.priority-letter strong {
  font-size: 1.45rem;
}

.priority-letter span {
  color: var(--muted);
  font-size: 0.7rem;
}

.frequency-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

.frequency-row {
  display: grid;
  grid-template-columns: 34px 40px 1fr 58px;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 13px;
  background: var(--surface-2);
  border: 1px solid transparent;
  transition: 160ms ease;
}

.frequency-row.covered {
  border-color: rgba(47, 186, 136, 0.32);
  background: rgba(47, 186, 136, 0.10);
}

.frequency-row.duplicate {
  border-color: rgba(211, 154, 66, 0.4);
  background: rgba(211, 154, 66, 0.10);
}

.rank {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.76rem;
}

.letter-badge {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--surface-3);
  font-size: 1.05rem;
  font-weight: 900;
}

.frequency-row.covered .letter-badge {
  background: var(--covered);
  color: #07130e;
}

.frequency-row.duplicate .letter-badge {
  background: var(--duplicate);
  color: #1c1203;
}

.bar-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #293443;
}

.bar-fill {
  display: block;
  height: 100%;
  min-width: 1px;
  border-radius: inherit;
  background: linear-gradient(90deg, #69788e, #9dacc0);
}

.frequency-row.covered .bar-fill {
  background: linear-gradient(90deg, var(--covered), var(--accent));
}

.frequency-row.duplicate .bar-fill {
  background: linear-gradient(90deg, var(--duplicate), var(--warning));
}

.percent {
  color: var(--muted);
  font-size: 0.74rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.legend-group,
.legend {
  display: flex;
  align-items: center;
}

.legend-group {
  gap: 14px;
  flex-wrap: wrap;
}

.legend {
  gap: 7px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--uncovered);
}

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

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

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

.detail-columns {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.detail-columns article {
  padding: 18px;
  border-radius: 16px;
  background: var(--surface-2);
}

.detail-columns h3 {
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.letter-sentence {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

footer {
  max-width: 850px;
  padding: 24px 4px 0;
  color: #778496;
  font-size: 0.78rem;
  line-height: 1.55;
}

@media (max-width: 820px) {
  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .frequency-list {
    grid-template-columns: 1fr;
  }

  .detail-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    padding-top: 34px;
  }

  .section-heading {
    align-items: flex-start;
  }

  .word-grid {
    grid-template-columns: 1fr;
  }

  .plus {
    display: none;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .section-heading.compact {
    display: grid;
  }

  .frequency-row {
    grid-template-columns: 28px 36px 1fr 50px;
    padding-inline: 9px;
  }
}

.panel-intro {
  max-width: 790px;
  margin: -4px 0 20px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}


.improvement-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.improvement-card,
.improvement-empty {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-2);
}

.improvement-card {
  padding: 18px;
}

.improvement-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.improvement-card-header h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.improvement-card-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.weak-letter {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: rgba(207, 112, 79, 0.13);
  color: var(--duplicate);
  font-size: 1.15rem;
  font-weight: 800;
}

.replacement-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.replacement-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid rgba(56, 151, 126, 0.24);
  border-radius: 999px;
  background: rgba(56, 151, 126, 0.09);
}

.replacement-chip strong {
  color: var(--covered);
  font-size: 0.95rem;
}

.replacement-chip span {
  color: var(--muted);
  font-size: 0.7rem;
}


.improvement-empty {
  grid-column: 1 / -1;
  padding: 20px;
  color: var(--muted);
  line-height: 1.55;
}

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

.opener-config {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface-2);
}

.opener-config label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.opener-config input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
}

.opener-count-value {
  min-width: 2.4rem;
  color: var(--accent);
  font-size: 1.35rem;
  font-weight: 850;
  text-align: center;
}

.word-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  align-items: start;
}

@media (max-width: 560px) {
  .opener-config { gap: 10px; }
  .word-grid { grid-template-columns: 1fr; }
}
