:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --text: #122033;
  --muted: #5f7087;
  --line: #d8e1ec;
  --line-strong: #c8d4e3;
  --accent: #1858e6;
  --accent-soft: rgba(24, 88, 230, 0.08);
  --shadow: 0 8px 24px rgba(16, 31, 50, 0.05);
  --row-hover: #f8fbff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
  line-height: 1.35;
}

.app {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 12px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 0 12px;
  background: linear-gradient(180deg, rgba(246, 248, 251, 0.98) 0%, rgba(246, 248, 251, 0.94) 80%, rgba(246, 248, 251, 0) 100%);
  backdrop-filter: blur(10px);
}

.searches {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.search {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.search:focus-within {
  border-color: rgba(24, 88, 230, 0.5);
  box-shadow: 0 0 0 4px rgba(24, 88, 230, 0.08);
}

.search svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
  flex: 0 0 auto;
}

#searchInput,
#transcriptionSearchInput,
#hebrewSearchInput {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 16px;
  color: var(--text);
}

#searchInput::placeholder,
#transcriptionSearchInput::placeholder,
#hebrewSearchInput::placeholder {
  color: #8b9ab0;
}

#hebrewSearchInput {
  direction: rtl;
  text-align: right;
  font-family: "Times New Roman", Times, Georgia, serif;
  font-size: 20px;
}

.clear-btn {
  display: none;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: #eef3f9;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 18px;
  line-height: 1;
}

.search.has-value .clear-btn {
  display: inline-grid;
  place-items: center;
}

.filter-wrap {
  position: relative;
  flex: 0 0 auto;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.filter-btn:hover,
.filter-btn[aria-expanded="true"] {
  border-color: rgba(24, 88, 230, 0.35);
  background: #fbfdff;
}

.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(360px, calc(100vw - 24px));
  max-height: min(65vh, 560px);
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 18px 44px rgba(16, 31, 50, 0.12);
  display: none;
}

.dropdown.is-open {
  display: block;
}

.dropdown-tools {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #edf2f7;
}

.tool-btn {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.tool-btn:hover {
  border-color: rgba(24, 88, 230, 0.35);
  background: #fbfdff;
}

.dropdown-section {
  display: grid;
  gap: 8px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid #edf2f7;
}

.dropdown-section-lessons {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: 0;
}

.dropdown-section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.lesson-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 0 8px;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
}

.lesson-option:hover {
  background: var(--accent-soft);
}

.lesson-option input {
  margin: 0;
}

.lesson-list {
  display: grid;
  gap: 6px;
}

.list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.row {
  display: grid;
  grid-template-columns: 84px minmax(150px, 240px) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #edf2f7;
}

.row:last-child {
  border-bottom: 0;
}

.row:hover {
  background: var(--row-hover);
}

.lesson {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.hebrew {
  direction: rtl;
  text-align: right;
  font-family: "Times New Roman", Times, Georgia, serif;
  font-size: 26px;
  color: #17283d;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deutsch {
  min-width: 0;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

mark {
  background: rgba(24, 88, 230, 0.12);
  color: inherit;
  padding: 0.02em 0.16em;
  border-radius: 0.22em;
}

.plain {
  padding: 14px;
  color: var(--muted);
  font-size: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

@media (max-width: 1100px) {
  .searches {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .topbar {
    align-items: stretch;
  }

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

@media (max-width: 760px) {
  .topbar {
    gap: 6px;
  }

  .filter-btn {
    padding-inline: 12px;
  }

  .row {
    grid-template-columns: 70px 110px minmax(0, 1fr);
    gap: 10px;
    padding: 9px 10px;
  }

  .hebrew {
    font-size: 22px;
  }

  .deutsch {
    font-size: 14px;
  }
}

@media (max-width: 560px) {
  .app {
    padding: 8px;
  }

  .topbar {
    flex-wrap: nowrap;
    gap: 6px;
  }

  .search {
    padding-inline: 10px;
    gap: 8px;
  }

  .filter-wrap {
    width: auto;
    flex: 0 0 auto;
  }

  .filter-btn {
    width: auto;
    min-width: 96px;
    padding-inline: 12px;
    justify-content: center;
    font-size: 13px;
  }

  .dropdown {
    left: auto;
    right: 0;
    width: min(320px, calc(100vw - 16px));
  }

  .row {
    grid-template-columns: 64px 88px minmax(0, 1fr);
  }
}

.hebrew-keyboard-panel {
  margin: -6px 0 12px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 18px 44px rgba(16, 31, 50, 0.12);
}

.hebrew-keyboard-panel[hidden] {
  display: none;
}

.hebrew-keyboard {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.hebrew-keyboard-key {
  appearance: none;
  width: 50px;
  height: 50px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  font-family: "SBL Hebrew", "Cardo", "Noto Sans Hebrew", "Times New Roman", "Arial Hebrew", "Segoe UI Symbol", serif;
}

.hebrew-keyboard-key:hover {
  border-color: #b8c4d1;
  filter: brightness(0.995);
}

.hebrew-keyboard-key.blocked {
  background: #f1f4f8;
  color: #9aa6b4;
}

.hebrew-keyboard-key.active {
  border-color: #7ba5ea;
  background: #d7e7ff;
}

.hebrew-keyboard-key.tone-consonant {
  background: #eef4ff;
  border-color: #d9e6ff;
}

.hebrew-keyboard-key.tone-vowel {
  background: #edf9f3;
  border-color: #d5efdf;
}

.hebrew-keyboard-key.tone-sign {
  background: #fff6e9;
  border-color: #fde8c6;
}

.hebrew-keyboard-glyph {
  display: inline-block;
  line-height: 1;
  white-space: nowrap;
  user-select: none;
  pointer-events: none;
}

.hebrew-keyboard-glyph.consonant {
  font-size: 40px;
  transform: translateY(1px);
}

.hebrew-keyboard-glyph.mark {
  font-size: 40px;
  transform: translateY(-1px);
}

@media (max-width: 760px) {
  .hebrew-keyboard-panel {
    margin-top: -2px;
    padding: 4px;
    border-radius: 12px;
  }

  .hebrew-keyboard {
    gap: 2px;
    padding: 2px;
  }

  .hebrew-keyboard-key {
    width: 32px;
    height: 32px;
    border-radius: 6px;
  }

  .hebrew-keyboard-glyph.consonant {
    font-size: 22px;
  }

  .hebrew-keyboard-glyph.mark {
    font-size: 27px;
  }
}

@media (max-width: 390px) {
  .hebrew-keyboard-key {
    width: 30px;
    height: 30px;
  }
}


.topbar-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.info-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.info-btn:hover,
.info-btn[aria-expanded="true"] {
  border-color: rgba(24, 88, 230, 0.35);
  background: #fbfdff;
}

.info-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 32, 51, 0.42);
}

.info-overlay[hidden] {
  display: none;
}

.info-dialog {
  position: relative;
  width: min(920px, 100%);
  min-height: 260px;
  max-height: min(88vh, 920px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(16, 31, 50, 0.22);
}

.info-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: #eef3f9;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 20px;
  line-height: 1;
}

.info-close-btn:hover {
  background: #e2ebf5;
  color: var(--text);
}

.info-content {
  min-height: 260px;
  padding: 56px 24px 24px;
}

.info-title {
  margin: 0 0 16px;
  font-size: 24px;
  line-height: 1.15;
}

.info-copy {
  margin-bottom: 16px;
  color: var(--text);
}

.info-copy p {
  margin: 0;
}

.info-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid #edf2f7;
}

.info-tab-btn {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.info-tab-btn:hover {
  border-color: rgba(24, 88, 230, 0.35);
  color: var(--text);
}

.info-tab-btn.is-active,
.info-tab-btn[aria-selected="true"] {
  border-color: rgba(24, 88, 230, 0.35);
  background: #eef4ff;
  color: var(--accent);
}

.info-tab-panel {
  display: none;
}

.info-tab-panel.is-active {
  display: block;
}

.info-general {
  display: grid;
  gap: 16px;
}

.info-section {
  display: grid;
  gap: 8px;
}

.info-section h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
}

.info-section p {
  margin: 0;
}

.info-section code {
  padding: 0.05em 0.28em;
  border-radius: 0.28em;
  background: #eef3f9;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.95em;
}

.mapping-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(220px, 0.8fr);
  gap: 12px;
  align-items: start;
}

.mapping-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.mapping-card h3 {
  margin: 0 0 12px;
  font-size: 18px;
  line-height: 1.2;
}

.mapping-card-consonants {
  background: #eef4ff;
  border-color: #d9e6ff;
}

.mapping-card-vowels {
  background: #edf9f3;
  border-color: #d5efdf;
}

.mapping-card-signs {
  background: #fff6e9;
  border-color: #fde8c6;
}

.mapping-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.mapping-list li {
  display: grid;
  grid-template-columns: max-content max-content max-content;
  align-items: center;
  justify-content: start;
  gap: 6px;
}

.mapping-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 14px;
}

.mapping-arrow {
  color: var(--muted);
}

.mapping-value {
  font-family: "SBL Hebrew", "Cardo", "Noto Sans Hebrew", "Times New Roman", "Arial Hebrew", "Segoe UI Symbol", serif;
  font-size: 24px;
  line-height: 1;
  direction: rtl;
  text-align: left;
}

@media (max-width: 900px) {
  .topbar {
    align-items: stretch;
  }

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

@media (max-width: 560px) {
  .topbar-actions {
    gap: 6px;
  }

  .info-content {
    padding: 56px 16px 18px;
  }

  .info-title {
    font-size: 22px;
  }

  .info-tabs {
    flex-wrap: wrap;
  }

  .mapping-list li {
    grid-template-columns: max-content max-content max-content;
    gap: 6px;
  }

  .mapping-key {
    font-size: 13px;
  }

  .mapping-value {
    font-size: 22px;
  }
}

/* Refined info overlay layout */
.info-dialog {
  display: grid;
  overflow: hidden;
  padding: 8px;
}

.info-close-btn {
  z-index: 2;
  top: 18px;
  right: 18px;
}

.info-content {
  max-height: min(calc(88vh - 16px), 904px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 14px;
  padding: 48px 20px 20px;
  scrollbar-gutter: stable;
}

.info-content::-webkit-scrollbar {
  width: 10px;
}

.info-content::-webkit-scrollbar-track {
  background: transparent;
}

.info-content::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: #cfd8e3;
  background-clip: content-box;
}

.info-content::-webkit-scrollbar-thumb:hover {
  background: #aebdcb;
  background-clip: content-box;
}

.info-general {
  gap: 12px;
}

.info-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.info-source-card {
  background: #f8fbff;
}

.info-warning-card {
  background: #fffaf2;
  border-color: #fde8c6;
}

.info-card h3,
.info-card h4 {
  margin: 0;
  line-height: 1.25;
}

.info-card h3 {
  font-size: 17px;
}

.info-card h4 {
  margin-top: 2px;
  font-size: 14px;
  color: var(--muted);
}

.info-list,
.info-def-list {
  margin: 0;
  padding: 0;
}

.info-list {
  display: grid;
  gap: 7px;
  padding-left: 1.15rem;
}

.info-compact-list {
  gap: 5px;
}

.info-def-list {
  display: grid;
  gap: 8px;
}

.info-def-list > div {
  display: grid;
  grid-template-columns: minmax(110px, 0.32fr) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 8px 0;
  border-top: 1px solid #edf2f7;
}

.info-def-list > div:first-child {
  border-top: 0;
  padding-top: 0;
}

.info-def-list > div:last-child {
  padding-bottom: 0;
}

.info-def-list dt {
  font-weight: 700;
}

.info-def-list dd {
  margin: 0;
  color: var(--text);
}

/* Keep the keyboard mapping in columns on narrow screens. */
.mapping-grid {
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.88fr) minmax(0, 0.55fr);
  gap: clamp(5px, 1.4vw, 12px);
}

.mapping-card {
  min-width: 0;
  overflow: hidden;
  padding: clamp(8px, 1.5vw, 14px);
}

.mapping-card h3 {
  margin-bottom: clamp(7px, 1.2vw, 12px);
  font-size: clamp(13px, 2vw, 18px);
}

.mapping-list {
  gap: clamp(4px, 1vw, 8px);
}

.mapping-list li {
  min-width: 0;
  gap: clamp(2px, 0.8vw, 6px);
}

.mapping-key {
  min-width: 0;
  font-size: clamp(10px, 1.55vw, 14px);
  white-space: nowrap;
}

.mapping-arrow {
  font-size: clamp(10px, 1.4vw, 14px);
}

.mapping-value {
  font-size: clamp(17px, 3vw, 24px);
}

@media (max-width: 900px) {
  .mapping-grid {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.88fr) minmax(0, 0.55fr);
  }
}

@media (max-width: 560px) {
  .info-overlay {
    padding: 12px;
  }

  .info-dialog {
    max-height: calc(100dvh - 24px);
    padding: 6px;
  }

  .info-close-btn {
    top: 14px;
    right: 14px;
  }

  .info-content {
    max-height: calc(100dvh - 36px);
    padding: 46px 12px 14px;
  }

  .info-card {
    padding: 12px;
  }

  .info-def-list > div {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .mapping-grid {
    grid-template-columns: minmax(0, 1.22fr) minmax(0, 0.85fr) minmax(0, 0.5fr);
    gap: 5px;
  }

  .mapping-card {
    padding: 7px;
    border-radius: 10px;
  }

  .mapping-card h3 {
    font-size: 12px;
  }

  .mapping-key {
    font-size: 9.5px;
  }

  .mapping-arrow {
    font-size: 10px;
  }

  .mapping-value {
    font-size: 16px;
  }
}

@media (max-width: 380px) {
  .mapping-grid {
    gap: 4px;
  }

  .mapping-card {
    padding: 6px;
  }

  .mapping-list li {
    gap: 2px;
  }

  .mapping-key {
    font-size: 8.5px;
  }

  .mapping-arrow {
    font-size: 9px;
  }

  .mapping-value {
    font-size: 15px;
  }
}

/* Keyboard-info refinements: keep columns first, shrink text only on very narrow screens. */
.keyboard-info {
  margin-bottom: 14px;
}

.keyboard-info .info-card {
  background: #f8fbff;
}

.mapping-grid {
  grid-template-columns: minmax(0, 1.28fr) minmax(0, 0.78fr) minmax(0, 0.44fr);
  gap: clamp(4px, 1vw, 12px);
}

.mapping-card {
  min-width: 0;
  padding: clamp(6px, 1.2vw, 14px);
}

.mapping-card h3 {
  font-size: 18px;
}

.mapping-list {
  gap: clamp(4px, 0.8vw, 8px);
}

.mapping-list li {
  min-width: 0;
  grid-template-columns: max-content max-content max-content;
  gap: clamp(2px, 0.55vw, 6px);
}

.mapping-key {
  min-width: 0;
  font-size: 14px;
  white-space: nowrap;
}

.mapping-arrow {
  font-size: 14px;
}

.mapping-value {
  font-size: 24px;
}

@media (max-width: 560px) {
  .mapping-grid {
    grid-template-columns: minmax(0, 1.28fr) minmax(0, 0.78fr) minmax(0, 0.44fr);
    gap: 4px;
  }

  .mapping-card {
    padding: 6px;
  }

  .mapping-card h3 {
    font-size: 16px;
  }

  .mapping-key {
    font-size: 14px;
  }

  .mapping-arrow {
    font-size: 14px;
  }

  .mapping-value {
    font-size: 24px;
  }
}

@media (max-width: 360px) {
  .mapping-card h3 {
    font-size: 14px;
  }

  .mapping-key {
    font-size: 12.5px;
  }

  .mapping-arrow {
    font-size: 12px;
  }

  .mapping-value {
    font-size: 21px;
  }
}

@media (max-width: 330px) {
  .mapping-grid {
    gap: 3px;
  }

  .mapping-card {
    padding: 5px;
  }

  .mapping-list li {
    gap: 1.5px;
  }

  .mapping-key {
    font-size: 11.5px;
  }

  .mapping-arrow {
    font-size: 11px;
  }

  .mapping-value {
    font-size: 19px;
  }
}

.row[data-copy-hebrew][data-copy-deutsch] {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: pan-y;
}

.row.is-copy-pending {
  background: var(--row-hover);
}

.row.is-copied {
  background: var(--accent-soft);
}

.copy-toast {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 50%;
  z-index: 120;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(18, 32, 51, 0.08);
  border-radius: 999px;
  background: rgba(18, 32, 51, 0.88);
  color: #fff;
  box-shadow: 0 8px 18px rgba(16, 31, 50, 0.14);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -12px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.copy-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
