  * { box-sizing: border-box; margin: 0; padding: 0; }
  body { font-family: 'Segoe UI', Arial, sans-serif; background: #f0f4f8; color: #333; min-height: 100vh; padding: 20px;
      position: relative;
      isolation: isolate;
}
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: #f0f4f8 url("images/background.jpg") center / cover no-repeat;
  }
  h1 {
    font-family: 'Reggae One', 'Segoe UI', Arial, sans-serif;
    font-weight: 400;
    text-align: center;
    color: #2c3e50;
    margin-bottom: 8px;
  }
  .subtitle { text-align: center; color: #2c3e50; margin-bottom: 20px; font-size: 14px; }
  .stats { display: flex; justify-content: center; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
  .stat-box { background: #fff; padding: 10px 20px; border-radius: 10px; box-shadow: 0 2px 6px rgba(0,0,0,0.08); text-align: center; min-width: 100px; }
  .stat-box .label { font-size: 12px; color: #95a5a6; text-transform: uppercase; }
  .stat-box .value { font-size: 22px; font-weight: bold; color: #2c3e50; }
  #quiz,
  #quiz2 {
  max-width: 700px;
  margin: 0 auto;
}
  .card { background: #fff; border-radius: 14px; padding: 18px 22px; margin-bottom: 14px; box-shadow: 0 2px 8px rgba(0,0,0,0.07); display: flex; flex-direction: column; gap: 14px; transition: border-color 0.3s; border: 2px solid transparent; }
  .card-top { display: flex; align-items: center; gap: 18px; }
  .card.correct { border-color: #27ae60; }
  .card.wrong { border-color: #e74c3c; }
  .char { font-size: 38px; min-width: 80px; text-align: center; color: #2c3e50; }
  .card-body { flex: 1; min-width: 50% }
  .card-body input { width: 100%; padding: 10px 14px; font-size: 16px; border: 1px solid #d0d5db; border-radius: 8px; outline: none; transition: border-color 0.2s; }
  .card-body input:focus { border-color: #3498db; }
  .hint { font-size: 16px; color: #95a5a6; margin-top: 6px; display: none; }
  .hint.show { display: block; }
  .hint-link { font-size: 12px; color: #3498db; cursor: pointer; margin-top: 4px; display: inline-block; }
  .actions { display: flex; justify-content: center; gap: 12px; margin: 24px 0; flex-wrap: wrap; }
  button { padding: 12px 28px; font-size: 16px; border: none; border-radius: 10px; cursor: pointer; transition: all 0.2s; }
  #check-btn, .check-btn { background: #3498db; color: #fff; }
  #check-btn:hover, .check-btn:hover { background: #2980b9; }
  #new-btn, .new-btn { background: #2ecc71; color: #fff; }
  #new-btn:hover, .new-btn:hover { background: #27ae60; }
  #result-banner, #result-banner2 { text-align: center; font-size: 20px; font-weight: bold; margin: 16px 0; min-height: 28px; }
  #tab-words #result-banner:empty,
  #tab-words #result-banner2:empty {
  margin-block: calc(16px / 3);
  min-height: calc(28px / 3);
}
  
  .score-green { color: #27ae60; }
  .score-orange { color: #e67e22; }
  .score-red { color: #e74c3c; }
  
  /* Локальный шрифт для названий разделов */
@font-face {
  font-family: 'Reggae One';
  src: url('fonts/ReggaeOne-Regular.woff2') format('woff2');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

  /* Tabs */
.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-width: 540px;
  margin: 0 auto 24px;
}
.tab {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  aspect-ratio: 1.5;
  padding: 12px;
  font-size: clamp(18px, 2.5vw, 20px);
  font-family: 'Reggae One', 'Segoe UI', Arial, sans-serif;
  font-weight: 400;
  text-align: center;
  white-space: nowrap;
  overflow-wrap: normal;
  border: 1px solid rgba(44, 62, 80, 0.30);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.50);
  color: #2c3e50;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.tab-label {
  display: block;
  flex: 0 0 auto;
  white-space: nowrap;
  line-height: 1.4;
}
.tab:focus-visible {
  outline: 3px solid #3498db;
  outline-offset: 3px;
}
  .tab.active {
    background: rgba(255, 255, 255, 0.60);
    color: #2c3e50;
    border-color: #385c47;
  }
  .tab:hover:not(.active) {
    background: rgba(255, 255, 255, 0.40);
    border-color: #385c47;
  }
  .tab-content { display: none; }
  .tab-content.active { display: block; }
  
  /* Sentence cards */
  .sent-card { background: #fff; border-radius: 14px; padding: 18px 22px; margin-bottom: 14px; box-shadow: 0 2px 8px rgba(0,0,0,0.07); border: 2px solid transparent; transition: border-color 0.3s; }
  .sent-card.correct { border-color: #27ae60; }
  .sent-card.wrong { border-color: #e74c3c; }
  .sent-chinese { font-size: 24px; color: #2c3e50; margin-bottom: 10px; line-height: 1.6; }
  .sent-russian { font-size: 18px; color: #2c3e50; margin-bottom: 10px; line-height: 1.6; }
  .sent-card input { width: 100%; padding: 10px 14px; font-size: 16px; border: 1px solid #d0d5db; border-radius: 8px; outline: none; transition: border-color 0.2s; }
  .sent-card input:focus { border-color: #3498db; }
  .sent-answer { font-size: 15px; color: #27ae60; margin-top: 8px; display: none; }
  .sent-answer.show { display: block; }
  .sent-actions { display: flex; gap: 10px; margin-top: 8px; }
  .btn-sm { padding: 6px 16px; font-size: 14px; border: none; border-radius: 8px; cursor: pointer; }
  .btn-yes { background: #27ae60; color: #fff; }
  .btn-no { background: #e74c3c; color: #fff; }
  .sent-label { font-size: 13px; color: #95a5a6; margin-bottom: 4px; }
  .loading { text-align: center; font-size: 18px; color: #95a5a6; padding: 40px; }
  
  /* Dictionary search */
  .dict-search-wrap {
    max-width: 700px;
    width: 100%;
    margin: 0 auto 24px;
    padding: 22px 26px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  }
  .dict-search-input { width: 100%; padding: 14px 18px; font-size: 18px; border: 2px solid #d0d5db; border-radius: 12px; outline: none; transition: border-color 0.2s; }
  .dict-search-input:focus { border-color: #3498db; }
  .dict-results { max-width: 700px; margin: 0 auto; }
  .dict-item { background: #fff; border-radius: 12px; padding: 16px 22px; margin-bottom: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.07); display: flex; align-items: center; gap: 18px; }
  .dict-char { font-size: 34px; min-width: 70px; text-align: center; color: #2c3e50; }
  .dict-info { flex: 1; }
  .dict-pinyin { font-size: 16px; color: #3498db; font-weight: 600; margin-bottom: 2px; }
  .dict-translation { font-size: 16px; color: #333; }
  .dict-empty { text-align: center; color: #95a5a6; font-size: 16px; padding: 30px; }
  .dict-edit-btn {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    background: #eef4fa;
    color: #25547a;
    font-size: 22px;
  }
  .dict-edit-btn:hover:not(:disabled) { background: #deebf7; }
  .dict-edit-btn:disabled { opacity: 0.45; cursor: default; }
  .dict-edit-form { flex: 1; min-width: 0; display: grid; gap: 10px; }
  .dict-edit-field { display: grid; gap: 4px; font-size: 14px; font-weight: 600; }
  .dict-edit-field :is(input, textarea) {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid #d0d5db;
    border-radius: 8px;
    font: inherit;
    font-size: 16px;
    font-weight: 400;
  }
  .dict-edit-field textarea { resize: vertical; }
  .dict-edit-status:not(:empty) { margin: 0 auto 10px; }
  .add-status.dict-edit-status:empty, .add-status.dict-edit-feedback:empty {
    min-height: 0;
    margin: 0;
  }

  .speak-btn { background: transparent; color: #fff; border: none; border-radius: 50%; width: 36px; height: 36px; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background 0.2s; }
  .speak-btn:hover { background: transparent; }
  .speak-btn:active { transform: scale(1.2); }
  .speak-btn-sm { background: transparent; color: #fff; border: none; border-radius: 50%; width: 30px; height: 30px; font-size: 15px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background 0.2s; }
  .speak-btn-sm:hover { background: transparent; }
  .speak-btn-sm:active { transform: scale(1.2); }


  /* Test section */
  .test-start-screen { text-align: center; padding: 60px 20px; }
  .test-start-screen h2 { font-size: 24px; color: #2c3e50; margin-bottom: 16px; }
  .test-start-screen p { font-size: 16px; color: #2c3e50; margin-bottom: 28px; }
  .test-btn { background: #3498db; color: #fff; font-size: 18px; padding: 14px 40px; border: none; border-radius: 12px; cursor: pointer; transition: background 0.2s; }
  .test-btn:hover { background: #2980b9; }
  .test-progress-wrap { max-width: 600px; margin: 0 auto 20px; }
  .test-progress-bar { height: 8px; background: #e0e6ed; border-radius: 4px; overflow: hidden; }
  .test-progress-fill { height: 100%; background: #3498db; transition: width 0.3s; }
  .test-progress-text { text-align: center; font-size: 14px; color: #2c3e50; margin-top: 6px; }
  .test-card-wrap { max-width: 600px; margin: 0 auto; }
  .test-card { background: #fff; border-radius: 16px; padding: 36px 30px; box-shadow: 0 4px 12px rgba(0,0,0,0.08); text-align: center; }
  .test-char { font-size: 64px; color: #2c3e50; margin-bottom: 28px; }
  .test-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .test-option { padding: 16px 20px; font-size: 17px; border: 2px solid #d0d5db; border-radius: 12px; background: #fff; cursor: pointer; transition: all 0.2s; text-align: center; }
  @media (hover: hover) and (pointer: fine) {
  .test-option:hover {
    border-color: #3498db;
    background: #f8fbff;
  }
}
  .test-option.correct { border-color: #27ae60; background: #eafaf1; color: #27ae60; font-weight: 600; }
  .test-option.wrong { border-color: #e74c3c; background: #fdedec; color: #e74c3c; font-weight: 600; }
  .test-option.disabled { pointer-events: none; opacity: 0.6; }
  .test-result { text-align: center; padding: 50px 20px; }
  .test-result-score { font-size: 48px; font-weight: bold; margin-bottom: 12px; }
  .test-result-msg { font-size: 22px; color: #2c3e50; font-weight: bold ; margin-bottom: 30px; }
  .test-restart-btn { background: #2ecc71; color: #fff; font-size: 18px; padding: 14px 40px; border: none; border-radius: 12px; cursor: pointer; transition: background 0.2s; }
  .test-restart-btn:hover { background: #27ae60; }


  /* One-card quiz */
  .quiz-card-wrap { max-width: 700px; margin: 0 auto; }
  .quiz-progress-text { text-align: center; font-size: 14px; color: #2c3e50; margin-bottom: 10px; }
  .next-btn { background: #3498db; color: #fff; }
  .next-btn:hover { background: #3498db; }

  /* Results list */
  .results-list { max-width: 700px; margin: 20px auto; }
  .results-list h3 { text-align: center; margin-bottom: 16px; }
  .result-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-radius: 10px; margin-bottom: 8px; box-shadow: 0 2px 6px rgba(0,0,0,0.05); }
  .result-row.ok { background: #eafaf1; border-left: 4px solid #27ae60; }
  .result-row.err { background: #fdedec; border-left: 4px solid #e74c3c; }
  .result-mark { font-size: 20px; font-weight: bold; }
  .result-char { font-size: 28px; min-width: 60px; text-align: center; }
  .result-pinyin { font-size: 15px; color: #3498db; font-weight: 600; }
  .result-char-pinyin { display: flex; flex-direction: column; align-items: center; min-width: 80px; }
  .result-translation { font-size: 16px; color: #333; flex: 1; }
  .result-user-answer { font-size: 14px; color: #e74c3c; }

  /* Test word count selector */
  .test-count-select { padding: 12px 20px; font-size: 18px; border: 2px solid #d0d5db; border-radius: 12px; outline: none; margin-bottom: 20px; cursor: pointer; }
  .test-count-select:focus { border-color: #3498db; }
  .test-settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-width: 520px; margin: 0 auto 20px; text-align: left; }
  .test-settings label { display: block; margin-bottom: 8px; font-size: 16px; color: #2c3e50; }
  .test-settings .test-count-select { width: 100%; min-width: 0; margin-bottom: 0; padding-inline: 10px; font-size: 16px; }
  .test-start-status { color: #e74c3c; }
  .test-start-status:empty { display: none; }
  .test-restart-during { background: #e74c3c; color: #fff; font-size: 16px; padding: 10px 28px; border: none; border-radius: 10px; cursor: pointer; transition: background 0.2s; }
  .test-restart-during:hover { background: #c0392b; }
  .test-pinyin { font-size: 22px; color: #3498db; margin-top: -18px; margin-bottom: 18px; font-weight: 600; }
  .test-char-clickable { cursor: pointer; transition: color 0.2s; }
  .test-char-clickable:hover { color: #3498db; }
  .test-sound-toggle { background: #fff; border: 2px solid #d0d5db; border-radius: 50%; width: 44px; height: 44px; font-size: 20px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: all 0.2s; vertical-align: middle; margin-right: 10px; padding: 0; }
  .test-sound-toggle:hover { border-color: #3498db; }
  .test-sound-toggle.muted { opacity: 0.5; }
  .test-prev-btn { background: #fff; color: #2c3e50; font-size: 16px; padding: 10px 24px; border: 2px solid #d0d5db; border-radius: 10px; cursor: pointer; transition: all 0.2s; margin-right: 10px; }
  .test-prev-btn:hover:not(:disabled) { border-color: #3498db; color: #3498db; }
  .test-prev-btn:disabled { opacity: 0.4; cursor: not-allowed; }

  /* Add word section */
  .add-word-section { max-width: 700px; width: 100%; margin: 0 auto 28px; background: #fff; border-radius: 14px; padding: 22px 26px; box-shadow: 0 2px 8px rgba(0,0,0,0.07); box-sizing: border-box; }
  .add-word-form { display: flex; flex-direction: column; gap: 14px; }
  .dictionary-photo > summary { 
    cursor: pointer;
    font-weight: 400;
  }
  .dictionary-photo:not([open]) > summary { margin-bottom: 0; }
  .dictionary-photo .add-status:empty { display: none; }
  #dictionary-photo-preview {
    display: block;
    max-width: 100%;
    max-height: 320px;
    margin: 0 auto 12px;
    object-fit: contain;
  }
  .dictionary-photo-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2fr) auto;
    align-items: end;
    gap: 10px;
    min-width: 0;
    margin: 0 0 12px;
    padding: 12px;
    border: 1px solid #d0d5db;
    border-radius: 10px;
  }
  .dictionary-photo-row .add-word-field { flex-direction: column; align-items: stretch; }
  .dictionary-photo-row .add-word-field label { min-width: 0; }
  .dictionary-photo-row .add-word-field input { min-width: 0; }
  @media (max-width: 600px) {
    .dictionary-photo-row { grid-template-columns: minmax(0, 1fr); }
    .dictionary-photo-row > button { justify-self: start; }
  }
  .add-word-row { display: flex; flex-direction: column; gap: 10px; }
  .add-word-row input { flex: 1; padding: 12px 16px; font-size: 18px; border: 2px solid #d0d5db; border-radius: 10px; outline: none; transition: border-color 0.2s; }
  .add-word-row input:focus { border-color: #3498db; }
  .lookup-btn { padding: 12px 24px; font-size: 16px; background: #9b59b6; color: #fff; border: none; border-radius: 10px; cursor: pointer; transition: background 0.2s; white-space: nowrap; width: 100%; }
  .lookup-btn:hover { background: #8e44ad; }
  .lookup-btn:disabled { opacity: 0.6; cursor: wait; }
  .add-word-preview { display: flex; flex-direction: column; gap: 12px; max-width: 100%; overflow: hidden; }
  .add-word-field { display: flex; align-items: center; gap: 10px; }
  .add-word-field label { font-size: 14px; color: #2c3e50; min-width: 70px; font-weight: 600; }
  .add-word-field input { flex: 1; padding: 10px 14px; font-size: 16px; border: 1px solid #d0d5db; border-radius: 8px; outline: none; transition: border-color 0.2s; }
  .add-word-field input:focus { border-color: #3498db; }
  .add-word-matches,
  .dictionary-photo-duplicate:not(:empty) {
    background: #fff4d6;
    color: #624400;
  }
  .add-word-matches {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    overflow-wrap: anywhere;
  }
  .add-word-matches ul {
    margin: 6px 0 0;
    padding-left: 22px;
  }
  .add-word-actions { display: flex; gap: 10px; justify-content: center; margin-top: 4px; flex-wrap: wrap; }
  .add-confirm-btn { padding: 10px 24px; font-size: 16px; background: #27ae60; color: #fff; border: none; border-radius: 10px; cursor: pointer; transition: background 0.2s; }
  .add-confirm-btn:hover { background: #229954; }
  .add-confirm-btn:disabled { opacity: 0.6; cursor: wait; }
  .add-cancel-btn { padding: 10px 24px; font-size: 16px; background: #e0e6ed; color: #2c3e50; border: none; border-radius: 10px; cursor: pointer; transition: background 0.2s; }
  .add-cancel-btn:hover { background: #d0d5db; }
  .add-status { text-align: center; font-size: 14px; min-height: 20px; margin-top: 4px; }
  .add-status.success { color: #27ae60; }
  .add-status.error { color: #e74c3c; }
  .add-status.loading { color: #95a5a6; }

  /* Russian-to-Chinese options */
  .add-char-options { display: flex; flex-direction: column; gap: 8px; }
  .add-char-option { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 2px solid #d0d5db; border-radius: 10px; cursor: pointer; transition: all 0.2s; background: #fff; }
  .add-char-option:hover { border-color: #3498db; background: #f8fbfe; }
  .add-char-option.selected { border-color: #27ae60; background: #f0faf3; }
  .add-char-option .opt-char { font-size: 28px; color: #2c3e50; min-width: 60px; text-align: center; }
  .add-char-option .opt-pinyin { font-size: 14px; color: #95a5a6; }
  .add-char-option .opt-translation { font-size: 14px; color: #7f8c8d; margin-left: auto; }
  .add-char-options .opt-header { font-size: 13px; color: #2c3e50; font-weight: 600; margin-bottom: 2px; }


/* Адаптация содержимого */
.tab-content {
  max-width: 900px;
  margin-inline: auto;
}
button, input, select { font: inherit; }
button { touch-action: manipulation; }
.card-body, .dict-info, .result-translation, .add-word-field input {
  min-width: 0;
}
.char, .dict-char, .dict-info, .result-char-pinyin,
.result-translation, .test-char, .test-option {
  overflow-wrap: anywhere;
}
.add-word-row input, .add-word-field input { width: 100%; }

@media (max-width: 768px) {
  body { padding: 16px; }
  h1 { font-size: 26px; margin-bottom: 18px; }
  .card, .sent-card, .add-word-section, .dict-search-wrap { padding: 18px; }
  .test-card { padding: 24px 18px; }
  .test-start-screen, .test-result { padding: 28px 8px; }
  button, input, select { min-height: 44px; }
  input, select { font-size: 16px; }
  .speak-btn, .speak-btn-sm {
    width: 44px;
    height: 44px;
    padding: 0;
  }
  .hint-link { padding-block: 12px; font-size: 14px; }
  .dict-item {
    flex-wrap: nowrap;
    gap: 10px;
    padding: 16px;
}

.dict-char {
  flex: 0 0 auto;
  min-width: 0;
  max-width: 45%;
}

.dict-info {
  flex: 1 1 0;
  min-width: 0;
}
  .result-row { flex-wrap: wrap; }
  .result-translation { flex: 1 1 150px; }
  .test-prev-btn, .test-restart-during { margin: 4px; }
}
@media (max-width: 480px) {
  body { padding: 12px; }
  h1 { font-size: 23px; }
  .dict-item-editable { gap: 8px; padding: 12px; }
  .dict-item-editable .dict-char { max-width: 34%; font-size: 26px; }
  .test-settings label { font-size: 14px; }
  .test-settings .test-count-select { font-size: 14px; padding-inline: 8px; }
  .tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    max-width: 360px;
  }
  .card-top { flex-wrap: wrap; gap: 10px; }
  .char { min-width: 0; font-size: 34px; }
  .add-word-field {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .actions > button, .add-word-actions > button {
    flex: 1 1 140px;
    padding-inline: 12px;
  }
  .test-options { grid-template-columns: minmax(0, 1fr); }
  .test-char { font-size: 48px; }
  .test-option { padding: 14px; }
}

/* Меню и форма раздела показываются по очереди. */
.tabs[hidden], .section-navigation[hidden] { display: none; }
.section-navigation {
  max-width: 900px;
  margin: 0 auto 18px;
}
.back-to-sections {
  min-height: 44px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.75);
  color: #2c3e50;
  border: 1px solid rgba(44, 62, 80, 0.30);
}

.page-scroll-controls {
  display: none;
  position: fixed;
  left: calc(8px + env(safe-area-inset-left, 0px));
  top: 50%;
  transform: translateY(-50%);
  z-index: 1000;
  flex-direction: column;
  gap: 10px;
}

body:has(#tab6.active, #tab8.active) .page-scroll-controls {
  display: flex;
}

.page-scroll-controls button {
  width: 22px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
  color: #2c3e50;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(44, 62, 80, 0.30);
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.page-scroll-controls button:focus-visible {
  outline: 3px solid #3498db;
  outline-offset: 3px;
}

.back-to-sections:focus-visible {
  outline: 3px solid #3498db;
  outline-offset: 3px;
}
#quiz-round .actions,
#quiz-round2 .actions {
  flex-wrap: nowrap;
}
#quiz-round .actions > button,
#quiz-round2 .actions > button {
  flex: 0 1 160px;
  width: 160px;
  min-width: 0;
  min-height: 44px;
  padding: 12px;
  white-space: nowrap;
}
/* Закрепляем «К разделам» в Словаре и Именах. */
body:has(#tab6.active, #tab8.active) .section-navigation {
  position: sticky;
  top: calc(8px + env(safe-area-inset-top, 0px));
  z-index: 1000;
}


/* Предложения: общие карточки Baozi и Chinese-quiz. */
.sentences-wrap { max-width: 700px; margin-inline: auto; }
.sentences-start { text-align: center; padding: 16px 8px; }
.sentences-start p { line-height: 1.6; margin-bottom: 16px; }
.sentences-status { text-align: center; line-height: 1.5; color: #2c3e50; margin-block: 16px; }
.sentences-status:empty { display: none; }
.sentences-status.is-error { color: #b33a2e; }
.sentences-card, .sentences-review { background: #fff; border-radius: 16px; padding: 24px; box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.sentences-prompt { font-size: 24px; line-height: 1.5; margin-bottom: 20px; overflow-wrap: anywhere; }
#sentences-form { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
#sentences-answer { display: block; width: 100%; min-width: 0; resize: vertical; padding: 12px; font: inherit; font-size: 22px; line-height: 1.5; border: 2px solid #d0d5db; border-radius: 10px; }
#sentences-answer:focus { outline: 2px solid #3498db; outline-offset: 2px; }
#sentences-answer[readonly] { background: #f4f6f8; }
.sentences-navigation { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.sentences-navigation .test-prev-btn { margin: 0; min-height: 44px; }
.sentences-feedback { margin-top: 20px; padding: 16px; border-radius: 12px; background: #f4f6f8; overflow-wrap: anywhere; }
.sentences-feedback p, .sentences-review p { margin-bottom: 10px; line-height: 1.55; white-space: pre-wrap; }
.sentences-feedback.is-correct { border-left: 4px solid #23824a; background: #eafaf1; }
.sentences-feedback.is-wrong { border-left: 4px solid #b33a2e; background: #fff3ee; }
.sentences-verdict { font-weight: bold; }
.sentences-flags, .sentences-grammar { font-size: 15px; color: #425366; }
.sentences-reference { font-size: 20px; }
.sentences-speak { color: #2c3e50; width: 44px; height: 44px; }
.sentences-review { margin-block: 16px; overflow-wrap: anywhere; }
.sentences-review h3 { margin-bottom: 12px; }
.sentences-reset { display: block; margin: 24px auto; }
.sentences-reset[hidden] { display: none; }
.sentences-wrap button:disabled { opacity: .6; cursor: wait; }
#sentences-score { text-align: center; margin-block: 20px; }
@media (max-width: 480px) {
  .sentences-card, .sentences-review { padding: 18px; }
  .sentences-prompt { font-size: 21px; }
  .sentences-wrap .test-btn { max-width: 100%; padding-inline: 22px; }
}


.dictionary-heading {
  font-size: 1.17em;
  font-weight: 700;
  text-align: center;
  margin-bottom: 14px;
  color: #2c3e50;
}
.test-navigation {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 600px;
  margin: 0 auto 16px;
}
.test-navigation > button {
  margin: 0;
  white-space: nowrap;
}
.test-navigation .test-sound-toggle {
  flex: 0 0 44px;
}
.test-navigation .test-prev-btn {
  flex: 0 1 auto;
  min-width: 0;
  min-height: 44px;
}
.test-restart-wrap {
  text-align: center;
  margin-top: 20px;
}
#sentences-check-btn {
  background: #2ecc71;
}
#sentences-check-btn:hover:not(:disabled) {
  background: #27ae60;
}
@media (max-width: 480px) {
  .test-navigation { gap: 6px; }
  .test-navigation .test-prev-btn {
    padding-inline: 8px;
    font-size: 14px;
  }
}


/* ИИ практика: обе панели сохраняют своё состояние при переключении. */
.ai-practice-switch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 20px; }
.ai-practice-switch .test-btn {
  min-width: 0;
  margin: 0;
  min-height: 88px;
  padding: 12px 6px;

  font-family: 'Reggae One', 'Segoe UI', Arial, sans-serif;
  font-weight: 400;
  font-size: clamp(18px, 2.5vw, 20px);
  white-space: normal;
  line-height: 1.3;

  border: 1px solid rgba(44, 62, 80, 0.30);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.50);
  color: #2c3e50;
  box-shadow: none;

  transition: background 0.2s, border-color 0.2s;
}

/* Выбранный подраздел */
.ai-practice-switch .test-btn[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.60);
  border-color: #385c47;
}

/* Наведение на невыбранный подраздел */
.ai-practice-switch .test-btn:hover:not([aria-pressed="true"]) {
  background: rgba(255, 255, 255, 0.70);
}

/* Фокус при управлении клавиатурой */
.ai-practice-switch .test-btn:focus-visible {
  outline: 3px solid #3498db;
  outline-offset: 3px;
}
#tab-words .word-panel[hidden] { display: none; }
#practice-testing[hidden], #practice-analysis[hidden], #analysis-result[hidden] { display: none; }
#analysis-form { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
#analysis-input { width: 100%; min-width: 0; resize: none; overflow-y: hidden; padding: 12px; font: inherit; font-size: 22px; line-height: 1.5; border: 2px solid #d0d5db; border-radius: 10px; }
#analysis-input:focus { outline: 2px solid #3498db; outline-offset: 2px; }
#analysis-input[readonly] { background: #f4f6f8; }
.analysis-hint { font-size: 13px; color: #425366; line-height: 1.5; }
#analysis-result h3 { margin: 16px 0 8px; font-size: 17px; }
#analysis-result h3:first-child { margin-top: 0; }
#analysis-result p { white-space: pre-wrap; line-height: 1.6; }
.analysis-issue { margin-block: 14px; padding-top: 12px; border-top: 1px solid #c3d0dc; }
#analysis-result.needs-context { border-left: 4px solid #b7791f; background: #fff8e6; }


.analysis-actions { display: flex; gap: 8px; width: 100%; }
.analysis-actions .test-btn { flex: 1 1 0; min-width: 0; min-height: 44px; margin: 0; padding: 12px 8px; font-size: clamp(11px, 3.2vw, 16px); }

/* Проанализировать */
#analysis-submit {
  background: #27ae60;
  color: #fff;
}

#analysis-submit:hover:not(:disabled) {
  background: #219653;
}

/* Очистить содержимое */
#analysis-clear {
  background: #e74c3c;
  color: #fff;
}

#analysis-clear:hover:not(:disabled) {
  background: #c0392b;
}

.ai-practice-label {
  display: block;
  width: 100%;
  min-width: 0;
  white-space: normal;
  word-break: normal;
  overflow-wrap: normal;
  line-height: 1.3;
}
/* Размеры подразделов как у главных разделов */

.ai-practice-switch {
  width: calc((min(100%, 540px) - 24px) / 3 * 2 + 12px);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0 auto 20px;
}
.ai-practice-switch .test-btn {
  width: 100%;
  min-height: 0;
  aspect-ratio: 1.5;
  padding: 12px;
}
#tab-words [data-word-panel] {
  aspect-ratio: 3.0;
  padding-block: 0;
}

/* На телефоне главные разделы тоже расположены в две колонки */
@media (max-width: 480px) {
  .ai-practice-switch {
    width: 100%;
    max-width: 360px;
    gap: 10px;
  }
}

/* Ввод показанного иероглифа. Стили ограничены новым разделом. */
.hanzi-practice { max-width: 700px; margin: 0 auto; }
.hanzi-practice [hidden] { display: none !important; }
.hanzi-practice h2 { margin-bottom: 16px; }
.hanzi-settings { grid-template-columns: minmax(0, 1fr); max-width: 230px; }
.hanzi-char { font-size: 54px; line-height: 1.5; color: #2c3e50; text-align: center; }
.hanzi-practice .card-body label { display: block; margin-bottom: 8px; }
.hanzi-actions { display: flex; justify-content: center; margin-top: 16px; }
.hanzi-actions .test-btn { width: auto; min-width: 160px; max-width: 100%; padding: 12px 22px; font-size: 16px; white-space: nowrap; }
#hanzi-status { color: #c0392b; margin-bottom: 12px; }
#hanzi-feedback { text-align: center; line-height: 1.6; overflow-wrap: anywhere; }
.hanzi-result-row { padding: 12px; margin-bottom: 8px; border-radius: 10px; background: #fff; line-height: 1.6; overflow-wrap: anywhere; }
.hanzi-result-row.ok { border-left: 4px solid #27ae60; }
.hanzi-result-row.err { border-left: 4px solid #e74c3c; }

#hanzi-answer { font-size: 28px; }
#hanzi-answer::placeholder { font-size: 16px; }

.hanzi-prompt { display: flex; align-items: center; justify-content: center; gap: 16px; }
.hanzi-practice button:disabled { cursor: default; opacity: 0.5; }


#hanzi-card.correct #hanzi-feedback { color: #27ae60; }
#hanzi-card.wrong #hanzi-feedback { color: #e74c3c; }
#hanzi-check-btn { background: #2ecc71; }
#hanzi-check-btn:hover:not(:disabled) { background: #27ae60; }
.hanzi-hint-wrap { text-align: center; margin: 4px 0 16px; padding: 0 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.94); }
.hanzi-hint-wrap .hint-link { background: transparent; border: 0; border-radius: 0; padding: 8px 0; }
.hanzi-hint-wrap .hint { padding-bottom: 12px; color: #687780; line-height: 1.6; overflow-wrap: anywhere; }
.hanzi-hint-label { margin-top: 6px; }



