/* Kartai — дрібні доповнення SPA до kartai-components.css (підключати останнім). */

html, body { height: 100%; }
body { margin: 0; overflow: hidden; -webkit-tap-highlight-color: transparent; }
button { font-family: inherit; }
.k-hidden { display: none !important; }
.k-ico { flex: none; display: inline-block; vertical-align: middle; }

/* ── типографіка ── */
.k-title { margin: 0; font-size: 28px; }
.k-h2 { margin: 0; font-size: 22px; }
.k-section { display: flex; flex-direction: column; gap: 12px; }
.k-section__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.k-small { font-size: 13px; }
.k-stack { display: flex; flex-direction: column; gap: 12px; }
.k-row-flex { display: flex; align-items: center; gap: 10px; }
.k-grow { flex: 1; min-width: 0; }
.k-pad { padding: 18px; }

/* ── кнопки ── */
.btn { min-height: 44px; }
.btn-lg { min-height: 54px; font-size: 16px; }
.k-icon-btn { width: 44px; height: 44px; color: var(--color-text); }
.btn-ghost.k-icon-btn:hover { background: var(--color-neutral-100); }

/* ── пошук ── */
.k-sfield { display: flex; gap: 8px; }
.k-sfield__box { position: relative; flex: 1; min-width: 0; }
.k-sfield__box > .k-ico-left { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--color-neutral-600); pointer-events: none; }
.k-sfield__box > .btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.k-sfield .input { min-height: 54px; padding-left: 46px; padding-right: 54px; font-size: 16px; }
.k-fake-search { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 0 16px; text-align: left; font: inherit; font-size: 16px; color: var(--color-neutral-600); background: var(--color-surface); border: 1px solid var(--color-divider); border-radius: var(--radius-md); cursor: pointer; }
.k-fake-search:hover { border-color: var(--color-accent); }
.k-chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.k-chip:hover { border-color: var(--color-accent); }
.k-chip.is-known:hover { border-color: transparent; }

/* Клікабельний текст у режимі Текст/Фото — виглядає як звичайний абзац */
.k-read {
  font-size: 18px; line-height: 1.65; overflow-wrap: anywhere;
  padding: 4px 2px; display: flex; flex-direction: column; gap: 14px;
}
.k-sent {
  display: flex; flex-direction: column; gap: 8px;
  padding-bottom: 12px; border-bottom: 1px dashed var(--color-divider);
}
.k-sent:last-child { border-bottom: 0; padding-bottom: 0; }
.k-sent__text { line-height: 1.65; }
.k-sent__btn {
  align-self: flex-start; min-height: 36px; padding: 0 12px; font-size: 13px; gap: 6px;
  color: var(--color-accent-800);
}
.k-chunk {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 14px; border-radius: var(--radius-md);
  background: var(--color-surface); border: 1px solid var(--color-divider);
}
.k-chunk__h { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.k-w {
  display: inline; margin: 0; padding: 0 1px; border: 0; border-radius: 4px;
  background: transparent; color: inherit; font: inherit; line-height: inherit;
  cursor: pointer; text-align: inherit;
}
.k-w:hover, .k-w:focus-visible {
  background: var(--color-accent-100); color: var(--color-accent-800);
  outline: none;
}
.k-w.is-known {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  color: color-mix(in srgb, var(--color-text) 62%, transparent);
}
.k-w.is-active { background: var(--color-accent); color: var(--color-bg); }

.k-sheet-back {
  position: absolute; inset: 0; z-index: 40;
  background: color-mix(in srgb, var(--color-text) 28%, transparent);
}
.k-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 41;
  max-height: min(78dvh, 640px); display: flex; flex-direction: column;
  background: var(--color-bg); border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg); border-top: 1px solid var(--color-divider);
}
.k-sheet__bar {
  flex: none; display: flex; align-items: center; gap: 8px;
  min-height: 56px; padding: 8px 12px; border-bottom: 1px solid var(--color-divider);
}
.k-sheet__body { flex: 1; overflow-y: auto; padding: 18px 18px 28px; }

.k-tr-box {
  padding: 14px 16px; border-radius: var(--radius-lg);
  background: var(--color-surface); border: 1px solid var(--color-divider);
  font-size: 15px; line-height: 1.55;
}

/* Пояснення граматичної форми (tarihin ← tarih) */
.k-form-note {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 14px; border-radius: var(--radius-md);
  background: var(--color-accent-100); color: var(--color-accent-900);
}
.k-form-note__q { font-size: 13px; }
.k-form-note .k-kicker { color: var(--color-accent-700); }
.k-result-grid { display: grid; gap: 22px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); align-items: start; }
.k-meaning { display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 12px 0; background: none; border: 0; border-bottom: 1px solid var(--color-divider); color: inherit; font: inherit; text-align: left; }
.k-meaning:last-child { border-bottom: 0; }
button.k-meaning { cursor: pointer; }
.k-meaning .k-check { margin-top: 2px; }
.k-meaning__n { flex: none; width: 22px; height: 22px; margin-top: 2px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 600; background: var(--color-accent-100); color: var(--color-accent-700); }
.k-m-tr { font-size: 18px; font-weight: 500; line-height: 1.35; }
.k-m-ex { margin-top: 2px; font-size: 14px; font-style: italic; }
.k-m-extr { font-size: 13px; color: color-mix(in srgb, var(--color-text) 55%, transparent); }
.k-mic.is-on { color: var(--color-bg); background: var(--color-accent); }
.k-spin { animation: k-spin 1s linear infinite; }
@keyframes k-spin { to { transform: rotate(360deg); } }

/* ── рядки колоди / списки ── */
.k-row .k-dots { flex: none; }
.k-row__meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.k-list { display: flex; flex-direction: column; }
.k-empty { padding: 36px 12px; text-align: center; color: color-mix(in srgb, var(--color-text) 55%, transparent); }

/* ── чат ── */
.k-chat { display: flex; flex-direction: column; gap: 10px; }
.k-composer { position: sticky; bottom: 0; z-index: 3; display: flex; align-items: flex-end; gap: 8px; margin: 0 -18px -28px; padding: 10px 18px 12px; background: var(--color-bg); }
.k-composer .input,
.k-composer textarea.input {
  flex: 1; min-height: 72px; max-height: 180px; font-size: 16px; line-height: 1.4;
  border-radius: 18px; padding: 12px 16px; resize: vertical; field-sizing: content;
}
.k-composer--tall .input,
.k-composer--tall textarea.input { min-height: 110px; max-height: 240px; }
.k-composer .btn { width: 48px; height: 48px; min-height: 48px; padding: 0; flex: none; margin-bottom: 2px; }
.k-typing { display: inline-flex; gap: 5px; align-items: center; padding: 6px 2px; }
.k-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--color-neutral-500); animation: k-pulse 1.1s ease-in-out infinite; }
.k-typing i:nth-child(2) { animation-delay: .15s; } .k-typing i:nth-child(3) { animation-delay: .3s; }
.k-bubble--error { color: var(--color-neutral-800); border-style: dashed; }

/* ── налаштування ── */
.k-set-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; padding: 14px 0; border-bottom: 1px solid var(--color-divider); }
.k-set-row:last-child { border-bottom: 0; }
.k-set-row__t { min-width: 0; flex: 1 1 200px; }
.k-set-row__s { font-size: 13px; color: color-mix(in srgb, var(--color-text) 55%, transparent); }
.k-set-block { padding: 6px 18px; }
.k-lang-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--color-divider); }
.k-lang-row:last-child { border-bottom: 0; }
.k-lang-code { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--color-accent-100); color: var(--color-accent-700); font-family: var(--font-heading); font-weight: 600; font-size: 14px; letter-spacing: .04em; }
.k-input-inline { display: flex; gap: 8px; }

/* ── меню мови ── */
.k-menu-back { position: absolute; inset: 0; z-index: 50; }
.k-menu { position: absolute; z-index: 51; top: 56px; right: 12px; min-width: 270px; max-width: calc(100% - 24px); padding: 6px; background: var(--color-surface); border: 1px solid var(--color-divider); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.k-menu__item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 6px 10px; background: none; border: 0; border-radius: var(--radius-md); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.k-menu__item:hover { background: var(--color-neutral-100); }
.k-menu__item[aria-checked="true"] { background: var(--color-accent-100); }

/* ── серія ── */
.k-streak { font-weight: 600; }
.k-streak.is-done { color: var(--color-accent); }
.k-streak.is-pending { color: #c44536; }
:root[data-theme="dark"] .k-streak.is-pending { color: #ef6b5a; }
.k-day.is-pending { border-color: #c44536; background: color-mix(in srgb, #c44536 18%, transparent); }

/* ── сесія ── */
.k-overlay__bar .k-progress { flex: 1; }
.k-counter { font-size: 14px; min-width: 52px; text-align: right; }
.k-session { max-width: 600px; }
.k-overlay__body.k-session-wrap {
  display: flex; flex-direction: column; overflow: hidden; padding: 0;
}
.k-session-scroll {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.k-session-scroll .k-overlay__inner { padding-bottom: 16px; }
.k-session-foot {
  flex: none; width: 100%; max-width: 600px; margin: 0 auto;
  padding: 12px 16px max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--color-divider);
  background: var(--color-bg);
  display: flex; flex-direction: column; gap: 8px;
  box-shadow: 0 -8px 24px color-mix(in srgb, var(--color-text) 6%, transparent);
}
.k-kbd-hint { display: none; margin: 0; text-align: center; font-size: 12px; }
@media (min-width: 860px) { .k-kbd-hint { display: block; } }
.k-kbd { display: inline-block; padding: 1px 6px; border: 1px solid var(--color-divider); border-radius: 6px; font-size: 11px; background: var(--color-surface); }
.k-sum-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.k-sum-grid .card { align-items: center; text-align: center; padding: 16px 8px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: color-mix(in srgb, var(--color-text) 70%, transparent); }

/* ── статистика ── */
.k-stat-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); }
.k-stat-grid .card { padding: 16px; gap: 6px; }
.k-stack-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--color-neutral-200); }
.k-stack-bar > span { display: block; height: 100%; }
.k-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; }
.k-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.k-record { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--color-divider); }
.k-record:last-child { border-bottom: 0; }

/* ── захоплення тексту ── */
.k-dropzone { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 40px 20px; text-align: center; border: 2px dashed var(--color-accent-300); border-radius: var(--radius-lg); background: var(--color-accent-100); color: var(--color-accent-700); cursor: pointer; }
.k-footer-bar { position: sticky; bottom: 0; padding-top: 8px; background: var(--color-bg); }
textarea.input { font-size: 16px; line-height: 1.5; }
.k-preview { max-height: 160px; width: auto; border-radius: var(--radius-md); border: 1px solid var(--color-divider); }

/* ── слово дня, клітинки ── */
.k-cell { padding: 18px; gap: 10px; }
.k-cell .k-kicker { display: block; }
.k-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; justify-items: center; }
.k-week span { font-size: 11px; }
.k-forecast-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; min-width: 0; }
.k-forecast-col .k-bar { min-height: 4px; }

/* ── стани ── */
.k-skel-block { height: 120px; border-radius: var(--radius-lg); background: var(--color-neutral-200); animation: k-pulse 1.2s ease-in-out infinite; }
.k-error { border-color: color-mix(in srgb, var(--color-accent-2) 50%, transparent); }

@media (max-width: 400px) {
  .k-hero { padding: 20px 16px; }
  .k-num--hero { font-size: 52px; }
}
