:root {
  --ink: #24304a;
  --muted: #66708c;
  --purple: #6557d8;
  --purple-dark: #4d40bd;
  --lavender: #eeeafe;
  --paper: #ffffff;
  --surface: #f8f7ff;
  --yellow: #ffe58a;
  --green: #90e0ba;
  --blue: #92d8ff;
  --pink: #ffb8cf;
  --orange: #ffc58f;
  --red: #d74767;
  --shadow: 0 18px 55px rgba(75, 64, 164, 0.14);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 15px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 6%, rgba(255, 229, 138, 0.48), transparent 21rem),
    radial-gradient(circle at 90% 20%, rgba(146, 216, 255, 0.38), transparent 25rem),
    linear-gradient(180deg, #f7f5ff 0%, #fdfcff 45%, #f2fbff 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.site-header {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: relative;
  z-index: 2;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mascot {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  font-size: 31px;
  background: var(--yellow);
  box-shadow: 0 9px 22px rgba(157, 126, 20, 0.14);
  transform: rotate(-4deg);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 22px;
  line-height: 1;
}

.brand small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

main {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.hero {
  padding: 60px 0 42px;
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  align-items: center;
  gap: clamp(30px, 6vw, 80px);
}

.eyebrow,
.section-kicker {
  display: inline-block;
  color: var(--purple-dark);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 13px;
}

.hero h1 {
  margin: 14px 0 16px;
  font-size: clamp(42px, 6.5vw, 72px);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.hero-copy p {
  max-width: 540px;
  margin: 0;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.6;
}

.search-card {
  padding: clamp(24px, 4vw, 38px);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  border: 1px solid rgba(101, 87, 216, 0.1);
  backdrop-filter: blur(10px);
}

.search-card label {
  display: block;
  margin-bottom: 13px;
  font-size: 20px;
  font-weight: 800;
}

.input-row {
  display: flex;
  gap: 12px;
}

input {
  width: 100%;
  min-width: 0;
  padding: 18px 20px;
  border: 2px solid #d9d4f6;
  border-radius: 16px;
  outline: none;
  background: #fff;
  color: var(--ink);
  font-size: 20px;
  transition: 0.2s ease;
}

input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 5px rgba(101, 87, 216, 0.12);
}

.primary-button,
.ghost-button {
  border: 0;
  border-radius: 16px;
  font-weight: 800;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.primary-button {
  padding: 0 25px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: #fff;
  background: linear-gradient(135deg, var(--purple), #8177e8);
  box-shadow: 0 10px 24px rgba(78, 64, 189, 0.26);
}

.primary-button:hover,
.ghost-button:hover,
.examples button:hover {
  transform: translateY(-2px);
}

.primary-button:active,
.ghost-button:active,
.examples button:active {
  transform: translateY(0);
}

.primary-button:disabled {
  cursor: progress;
  opacity: 0.72;
}

.ghost-button {
  padding: 12px 16px;
  color: var(--purple-dark);
  background: #fff;
  border: 1px solid #dedaf6;
}

.input-hint,
.form-message {
  margin: 9px 2px 0;
  font-size: 13px;
}

.input-hint {
  color: var(--muted);
}

.form-message {
  min-height: 18px;
  color: var(--red);
  font-weight: 700;
}

.examples {
  margin-top: 18px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.examples button {
  padding: 8px 12px;
  border: 0;
  border-radius: 999px;
  color: var(--purple-dark);
  background: var(--lavender);
  font-weight: 700;
  transition: 0.15s ease;
}

.loading-card,
.welcome-card {
  margin: 10px auto 50px;
  padding: 24px;
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.loading-card {
  max-width: 600px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.loading-card[hidden],
.result[hidden],
.welcome-card[hidden],
.print-button[hidden] {
  display: none;
}

.loading-card strong {
  font-size: 18px;
}

.loading-card p {
  margin: 5px 0 0;
  color: var(--muted);
}

.book-loader {
  font-size: 42px;
  animation: bookBounce 0.85s ease-in-out infinite alternate;
}

@keyframes bookBounce {
  to { transform: translateY(-7px) rotate(3deg); }
}

.welcome-card {
  max-width: 760px;
  display: flex;
  align-items: center;
  gap: 18px;
  border: 2px dashed #cfc9f8;
  box-shadow: none;
  background: rgba(255, 255, 255, 0.68);
}

.welcome-card > span {
  font-size: 40px;
}

.welcome-card h2 {
  margin: 0 0 5px;
  font-size: 21px;
}

.welcome-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.result {
  padding: 24px 0 50px;
}

.result-heading {
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
}

.result-heading h2 {
  margin: 8px 0 8px;
  font-size: clamp(31px, 5vw, 48px);
  letter-spacing: -0.035em;
}

.result-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
}

.confidence-badge {
  flex: 0 0 auto;
  padding: 9px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  background: #e7f8ef;
  color: #18714a;
}

.confidence-badge.medium {
  background: #fff4ce;
  color: #82610d;
}

.confidence-badge.low {
  background: #ffe2e8;
  color: #a52e4a;
}

.lesson-card {
  position: relative;
  margin-bottom: 24px;
  padding: clamp(24px, 5vw, 48px);
  border-radius: var(--radius-xl);
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.lesson-number {
  position: absolute;
  top: -20px;
  right: 22px;
  color: rgba(101, 87, 216, 0.08);
  font-size: 130px;
  line-height: 1;
  font-weight: 900;
  pointer-events: none;
}

.lesson-content {
  position: relative;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 30px;
}

.section-title h3 {
  margin: 6px 0 0;
  font-size: clamp(25px, 4vw, 35px);
}

.section-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 19px;
  background: var(--lavender);
  font-size: 31px;
}

.morpheme-word {
  display: flex;
  justify-content: center;
  align-items: end;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 105px;
  padding: 25px 10px 8px;
}

.morpheme {
  position: relative;
  min-width: 44px;
  padding: 12px 13px 15px;
  text-align: center;
  border-radius: 12px;
  font-size: clamp(30px, 6vw, 48px);
  font-weight: 900;
  line-height: 1;
}

.morpheme small {
  position: absolute;
  left: 50%;
  bottom: -24px;
  transform: translateX(-50%);
  color: var(--muted);
  white-space: nowrap;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.morpheme.prefix { background: rgba(146, 216, 255, 0.58); }
.morpheme.root { background: rgba(255, 229, 138, 0.65); }
.morpheme.suffix { background: rgba(144, 224, 186, 0.59); }
.morpheme.ending { background: rgba(255, 184, 207, 0.58); border: 3px solid #ea82a6; }
.morpheme.postfix { background: rgba(255, 197, 143, 0.62); }
.morpheme.interfix { background: rgba(207, 201, 248, 0.7); }

.morpheme.prefix::before {
  content: "";
  position: absolute;
  inset: 5px 6px auto;
  height: 8px;
  border-top: 3px solid #3e94bf;
  border-left: 3px solid #3e94bf;
  border-radius: 4px 0 0;
}

.morpheme.root::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 6px;
  height: 9px;
  border-bottom: 3px solid #c69516;
  border-radius: 50%;
}

.morpheme.suffix::before {
  content: "⌃";
  position: absolute;
  top: -13px;
  left: 50%;
  transform: translateX(-50%);
  color: #28885d;
  font-size: 26px;
}

.morpheme.zero {
  font-size: 33px;
}

.morpheme-legend {
  margin: 34px 0 26px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 4px;
}

.legend-dot.prefix { background: var(--blue); }
.legend-dot.root { background: var(--yellow); }
.legend-dot.suffix { background: var(--green); }
.legend-dot.ending { background: var(--pink); }
.legend-dot.postfix { background: var(--orange); }
.legend-dot.interfix { background: #cfc9f8; }

.scheme-box {
  padding: 20px;
  border-radius: 18px;
  background: var(--surface);
  text-align: center;
}

.scheme-label {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.scheme-line {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 800;
}

.scheme-part {
  padding: 7px 11px;
  border-radius: 10px;
  background: #fff;
}

.scheme-plus {
  color: var(--purple);
}

.facts-grid {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 0.75fr 1.25fr;
  gap: 14px;
}

.fact {
  padding: 18px;
  border: 1px solid #e6e3f7;
  border-radius: 16px;
}

.fact span,
.sound-intro span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.fact strong {
  font-size: 17px;
  line-height: 1.45;
}

.sound-intro {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.sound-intro > div {
  padding: 18px;
  border-radius: 16px;
  background: var(--surface);
}

.sound-intro strong {
  font-size: 21px;
}

.summary-box {
  margin: 22px 0;
  padding: 22px;
  border-radius: 20px;
  background: linear-gradient(135deg, #ede9ff, #f7f5ff);
  border: 2px solid #d7d1fa;
}

.summary-box h4 {
  margin: 0 0 14px;
  font-size: 22px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.summary-item {
  padding: 12px;
  border-radius: 13px;
  background: #fff;
}

.summary-item strong,
.summary-item span {
  display: block;
}

.summary-item strong {
  font-size: 24px;
  color: var(--purple-dark);
}

.summary-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid #e5e2f5;
  border-radius: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

th,
td {
  padding: 15px 17px;
  border-bottom: 1px solid #ece9f8;
  text-align: left;
}

th {
  color: var(--purple-dark);
  background: #f5f2ff;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:nth-child(even) {
  background: #fcfbff;
}

.letter-cell,
.sound-cell {
  font-size: 22px;
  font-weight: 900;
}

.sound-cell {
  color: var(--purple-dark);
}

.kind-label {
  display: block;
  margin-bottom: 4px;
  font-weight: 800;
}

.characteristics {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.notes {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 15px;
  background: #fff8da;
  color: #675112;
}

.notes p {
  margin: 5px 0;
  line-height: 1.5;
}

.teacher-note {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 20px 22px;
  border-radius: 18px;
  background: #eaf9f2;
  color: #285e49;
}

.teacher-note > span {
  font-size: 24px;
}

.teacher-note p {
  margin: 0;
  line-height: 1.55;
}

footer {
  padding: 22px 16px 34px;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.sky-shape {
  position: fixed;
  border-radius: 50%;
  filter: blur(1px);
  pointer-events: none;
}

.sky-shape-one {
  width: 180px;
  height: 180px;
  top: 37%;
  left: -120px;
  background: rgba(144, 224, 186, 0.3);
}

.sky-shape-two {
  width: 240px;
  height: 240px;
  right: -170px;
  bottom: 12%;
  background: rgba(255, 184, 207, 0.25);
}

@media (max-width: 820px) {
  .hero {
    grid-template-columns: 1fr;
    padding-top: 38px;
  }

  .hero-copy {
    text-align: center;
  }

  .hero-copy p {
    margin-inline: auto;
  }

  .facts-grid,
  .sound-intro {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 590px) {
  .site-header {
    padding-top: 15px;
  }

  .brand-mascot {
    width: 46px;
    height: 46px;
    font-size: 27px;
  }

  .brand strong {
    font-size: 19px;
  }

  .input-row {
    flex-direction: column;
  }

  .primary-button {
    min-height: 56px;
  }

  .search-card,
  .lesson-card {
    border-radius: 22px;
  }

  .result-heading {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .print-button {
    font-size: 0;
    width: 46px;
    height: 46px;
  }

  .print-button::first-letter {
    font-size: 20px;
  }

  .morpheme {
    font-size: 30px;
    padding-inline: 9px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .site-header,
  .hero,
  .welcome-card,
  .teacher-note,
  footer,
  .confidence-badge {
    display: none !important;
  }

  main {
    width: 100%;
  }

  .result {
    display: block !important;
    padding: 0;
  }

  .lesson-card {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }
}


/* Мобильная таблица: каждая буква показывается отдельной понятной карточкой. */
@media (max-width: 700px) {
  .table-wrap {
    overflow: visible;
    border: 0;
    border-radius: 0;
  }

  .table-wrap table {
    display: block;
    min-width: 0;
    width: 100%;
  }

  .table-wrap thead {
    display: none;
  }

  .table-wrap tbody {
    display: grid;
    gap: 12px;
  }

  .table-wrap .letter-row {
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    border: 1px solid #e5e2f5;
    border-radius: 17px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 8px 22px rgba(75, 64, 164, 0.07);
  }

  .table-wrap .letter-row:nth-child(even) {
    background: #fcfbff;
  }

  .table-wrap .letter-row td {
    display: grid;
    gap: 5px;
    min-width: 0;
    padding: 13px 15px;
    border: 0;
    overflow-wrap: anywhere;
  }

  .table-wrap .letter-row td::before {
    content: attr(data-label);
    color: var(--purple-dark);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }

  .table-wrap .letter-cell {
    border-right: 1px solid #ece9f8 !important;
  }

  .table-wrap .description-cell {
    grid-column: 1 / -1;
    border-top: 1px solid #ece9f8 !important;
  }

  .table-wrap .letter-cell,
  .table-wrap .sound-cell {
    font-size: 25px;
  }

  .table-wrap .kind-label {
    margin-bottom: 2px;
    font-size: 18px;
  }

  .table-wrap .characteristics {
    font-size: 15px;
    line-height: 1.45;
  }
}
