/* KBros Tashkil */
@font-face { font-family: "KTK Naskh"; src: url("../../shared/fonts/noto-naskh-var.ttf") format("truetype"); font-weight: 400 700; font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F, U+25CC; }
.ktk { display: block; --ktk-ar: "KTK Naskh", var(--k-font), "Geeza Pro", sans-serif; }
.ktk-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
.ktk-main > .ktk-card { display: flex; flex-direction: column; min-width: 0; }
.ktk-incard .ktk-in { flex: 1 1 auto; }
.ktk-outcard .ktk-out { flex: 1 1 auto; }
.ktk-card { padding: 18px; border-radius: 22px; background: var(--k-surface); border: 1px solid var(--k-line); }
.ktk-cardhead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; margin-bottom: 12px; min-height: 44px; }
.ktk-h { margin: 0; font-size: 19px; font-weight: 800; line-height: 1.35; letter-spacing: normal; }
.ktk-det { margin: 0; font-size: 14px; font-weight: 700; color: var(--k-accent-text, var(--k-accent)); }
.ktk-det:empty { display: none; }
.ktk-in { display: block; width: 100%; min-height: 240px; resize: vertical; padding: 14px 16px; border: 1.5px solid var(--k-line-2); border-radius: 16px; background: var(--k-bg);
  color: var(--k-ink); font: 400 21px/2 var(--ktk-ar); }
.ktk-in::placeholder { font-family: var(--k-font); }
.ktk-in::placeholder { font-size: 16px; color: var(--k-ink-3); }
.ktk-in:focus { outline: none; border-color: var(--k-accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--k-accent) 16%, transparent); }
.ktk-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ktk-row .k-btn, .ktk-acts .k-btn, .ktk-engrow2 .k-btn { min-height: 44px; }

/* options */
.ktk-opts { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr); gap: 14px 18px; margin: 0 0 16px; padding: 18px; border-radius: 22px;
  background: var(--k-surface); border: 1px solid var(--k-line); align-items: start; }
.ktk-opt { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.ktk-opt > .k-label { margin: 0; }
.ktk-opt .k-seg { width: 100%; }
.ktk-opt .k-seg button { min-height: 44px; flex: 1 1 0; }
.ktk-levelhelp { margin: 0; min-height: 2.6em; }
.ktk-switches { gap: 6px; }
.ktk-switch { position: relative; display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 4px; cursor: pointer; }
.ktk-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ktk-switch__ui { flex: none; position: relative; width: 44px; height: 26px; border-radius: 99px; background: var(--k-line-2); transition: background-color 160ms var(--k-ease); }
.ktk-switch__ui::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform 180ms var(--k-ease); }
.ktk-switch input:checked + .ktk-switch__ui { background: var(--k-accent); }
.ktk-switch input:checked + .ktk-switch__ui::after { transform: translateX(18px); }
[dir="rtl"] .ktk-switch input:checked + .ktk-switch__ui::after { transform: translateX(-18px); }
.ktk-switch input:focus-visible + .ktk-switch__ui { outline: 3px solid var(--k-focus); outline-offset: 2px; }
.ktk-switch__t { display: flex; flex-direction: column; min-width: 0; }
.ktk-switch__t b { font-size: 15px; font-weight: 700; }
.ktk-switch__t small { font-size: 13px; color: var(--k-ink-2); line-height: 1.4; }
.ktk-engrow { display: flex; gap: 8px; align-items: stretch; }
.ktk-engrow .k-seg { flex: 1 1 auto; }
.ktk-keybtn { flex: none; width: 48px; min-height: 44px; padding: 0; display: grid; place-items: center; }
.ktk-keybtn svg { width: 20px; height: 20px; }

/* result */
.ktk-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.ktk-savewrap { position: relative; }
.ktk-menu { position: absolute; z-index: 20; top: calc(100% + 6px); inset-inline-end: 0; min-width: 240px; padding: 6px; border-radius: 14px; background: var(--k-surface);
  border: 1px solid var(--k-line); box-shadow: 0 12px 32px rgba(11, 18, 32, .16); }
.ktk-menu__i { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--k-ink);
  font: inherit; font-size: 15px; font-weight: 600; text-align: start; cursor: pointer; }
.ktk-menu__i:hover, .ktk-menu__i:focus-visible { background: var(--k-surface-2); outline: none; }
.ktk-menu__i svg { width: 20px; height: 20px; color: var(--k-ink-2); }
.ktk-out { min-height: 240px; padding: 14px 16px; border-radius: 16px; background: var(--k-bg); border: 1.5px solid var(--k-line); white-space: pre-wrap; overflow-wrap: anywhere;
  font: 400 21px/2 var(--ktk-ar); color: var(--k-ink); unicode-bidi: plaintext; text-align: start; }
.ktk-empty, .ktk-err { margin: 0; font: 500 15px/1.6 var(--k-font); color: var(--k-ink-3); white-space: normal; }
.ktk-err { color: var(--k-ink-2); }
.ktk-w { border-radius: 6px; cursor: pointer; transition: background-color 120ms; }
.ktk-w:hover, .ktk-w:focus-visible { background: color-mix(in srgb, var(--k-accent) 13%, transparent); outline: none; }
.ktk-w.is-unsure { text-decoration: underline dotted color-mix(in srgb, var(--k-accent) 70%, transparent); text-decoration-thickness: 2px; text-underline-offset: 10px; }
.ktk-w.is-picked { background: color-mix(in srgb, var(--k-accent) 9%, transparent); }
.ktk-l { cursor: pointer; text-decoration: underline wavy #e5484d; text-decoration-thickness: 1.5px; text-underline-offset: 5px; border-radius: 4px; font-family: var(--k-font); }
.ktk-l[data-kind="gram"] { text-decoration-color: #3d7bf0; }
.ktk-l:hover, .ktk-l:focus-visible { background: color-mix(in srgb, #e5484d 10%, transparent); outline: none; }
.ktk-under { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.ktk-hint { margin: 8px 0 0; }
.ktk-under .k-btn { min-height: 44px; }
.ktk-eng { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--k-line); display: flex; flex-direction: column; gap: 10px; }
.ktk-engrow2 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.ktk-engrow2 > .k-label { margin: 0; min-width: 92px; }
.ktk-engnotes { margin: 0; padding-inline-start: 20px; font-size: 14px; line-height: 1.5; color: var(--k-ink-2); }
.ktk-engstatus { font-size: 14px; font-weight: 700; color: var(--k-ink-2); }
.ktk-engstatus.is-ok { color: #1f8a4c; }
.ktk-cases button { min-height: 44px; font-family: var(--k-font); }

/* tap-a-word card */
.ktk { position: relative; }
.ktk-pop { position: absolute; z-index: 30; top: var(--y, 0); left: var(--x, 0); width: min(340px, 100%); padding: 10px; border-radius: 16px; background: var(--k-surface);
  border: 1px solid var(--k-line); box-shadow: 0 16px 40px rgba(11, 18, 32, .2); display: flex; flex-direction: column; gap: 4px; }
.ktk-pop__now { margin: 0 4px 4px; font: 400 30px/1.9 var(--ktk-ar); text-align: center; }
.ktk-pop__h { margin: 4px 6px 0; font-size: 12.5px; font-weight: 800; color: var(--k-ink-3); }
.ktk-pop__msg { margin: 2px 6px 6px; font-size: 14px; line-height: 1.5; color: var(--k-ink-2); }
.ktk-pop__opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding: 4px 12px; border: 0; border-radius: 10px; background: transparent;
  color: var(--k-ink); font: 400 24px/1.8 var(--ktk-ar); cursor: pointer; text-align: start; }
.ktk-pop__opt[lang="en"] { font: 600 16px/1.4 var(--k-font); }
.ktk-pop__opt small { font: 600 13px/1.3 var(--k-font); color: var(--k-ink-2); }
.ktk-pop__opt:hover, .ktk-pop__opt:focus-visible { background: var(--k-surface-2); outline: none; }
.ktk-pop__own { display: flex; gap: 6px; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--k-line); }
.ktk-ownin { flex: 1 1 auto; min-width: 0; min-height: 48px; padding: 4px 12px; border: 1.5px solid var(--k-line-2); border-radius: 12px; background: var(--k-bg); color: var(--k-ink);
  font: 400 22px/1.6 var(--ktk-ar); }
.ktk-ownin:focus { outline: none; border-color: var(--k-accent); }

/* AI key sheet */
.ktk-keylead { margin: 0 0 10px; line-height: 1.6; }
.ktk-keysteps { margin: 0 0 14px; padding-inline-start: 22px; line-height: 1.7; color: var(--k-ink-2); }
.ktk-getkey { display: inline-flex; margin-bottom: 16px; min-height: 44px; text-decoration: none; }
.ktk-keyrow { display: flex; gap: 8px; }
.ktk-keyin { flex: 1 1 auto; min-width: 0; min-height: 48px; padding: 8px 12px; border: 1.5px solid var(--k-line-2); border-radius: 12px; background: var(--k-bg); color: var(--k-ink); font: 600 15px var(--k-font); }
.ktk-keyin:focus { outline: none; border-color: var(--k-accent); }
.ktk-keymsg { min-height: 1.5em; margin: 8px 0; font-size: 14px; font-weight: 700; }
.ktk-keymsg[data-s="ok"] { color: #1f8a4c; }
.ktk-keymsg[data-s="bad"] { color: #d23b40; }

@media (max-width: 1080px) {
  .ktk-main { grid-template-columns: 1fr; }
  .ktk-in, .ktk-out { min-height: 170px; }
}
@media (max-width: 900px) {
  .ktk-opts { grid-template-columns: 1fr 1fr; }
  .ktk-opts > .ktk-opt:first-child { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .ktk-card, .ktk-opts { padding: 14px; border-radius: 18px; }
  .ktk-opts { grid-template-columns: 1fr; }
  .ktk-out, .ktk-in { font-size: 19px; padding: 12px 14px; }
  .ktk-cardhead { align-items: flex-start; }
  .ktk-acts { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .ktk-acts .k-btn { width: 100%; justify-content: center; }
  .ktk-under .k-btn { flex: 1 1 auto; justify-content: center; }
  .ktk-engrow2 > .k-label { min-width: 0; width: 100%; }
  .ktk-cases { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .ktk-engrow .k-seg button { font-size: 14px; }
  .ktk-levelhelp { min-height: 0; }
  .ktk-seg4 button { font-size: 14px; padding-inline: 4px; white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) {
  .ktk .ktk-switch__ui, .ktk .ktk-switch__ui::after { transition-duration: 260ms !important; transition-timing-function: ease-out; }
}

/* Dialect picker (20 Nov): a button under Engine opens chips grouped by region */
.ktk-dialabel { margin-top: 4px !important; }
.ktk-diabtn { width: 100%; min-height: 44px; justify-content: flex-start; gap: 10px; }
.ktk-diabtn svg { width: 20px; height: 20px; flex: none; }
.ktk-dianow { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: start; }
.ktk-diachev { display: grid; opacity: .7; }
.ktk-diachev svg { width: 18px; height: 18px; }
.ktk-diasheet .ktk-dialead { margin: 0 0 14px; }
.ktk-diagroup { margin-top: 14px; }
.ktk-diag { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--k-ink-2); letter-spacing: .01em; }
.ktk-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ktk-chip { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--k-line); background: var(--k-surface); color: var(--k-ink);
  font: 500 15px/1 var(--k-font); cursor: pointer; transition: background-color .18s ease, border-color .18s ease, color .18s ease; }
.ktk-chip:hover { border-color: var(--k-accent); }
.ktk-chip:focus-visible { outline: 2px solid var(--k-accent); outline-offset: 2px; }
.ktk-chip[aria-pressed="true"] { background: var(--k-accent-tint, color-mix(in srgb, var(--k-accent) 14%, transparent)); border-color: var(--k-accent); color: var(--k-accent-text, var(--k-accent)); font-weight: 700; }
.ktk-diawords { margin: 0 0 6px; padding: 10px 12px; border-radius: 14px; background: var(--k-surface-2); }
.ktk-diawords small { line-height: 1.5; }
.ktk-diacredit { margin: 18px 0 0; font-size: 12px; }
.ktk-diacredit a { color: inherit; }
