/* KBros Web Tools: shared interface (used on khbros.app and inside the Mac, Windows and Android apps).
   Colours come from the site's tokens when present; the app shell (shell.css) defines the same tokens. */

.kbt {
  --k-ink: var(--text, #0b1220);
  --k-ink-2: var(--text-2, #3a4559);
  --k-ink-3: var(--text-3, #566176);
  --k-bg: var(--bg, #f6f7f9);
  --k-surface: var(--surface, #ffffff);
  --k-surface-2: var(--surface-2, #f9fafc);
  --k-line: var(--line, #e2e6ee);
  --k-line-2: var(--line-strong, #c9d1de);
  --k-accent: var(--fam-app, #6a4cff);
  --k-accent-2: var(--fam-app-2, #3d66f0);
  --k-accent-text: var(--fam-app-text, #4f3bd0);
  --k-accent-tint: var(--fam-app-chip, #ece8ff);
  --k-focus: var(--focus, #1e88e5);
  --k-radius: 16px;
  --k-font: "Montserrat Arabic", var(--font, ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", Tahoma, Arial, sans-serif);
  --k-ease: cubic-bezier(.23, 1, .32, 1);
  font-family: var(--k-font);
  color: var(--k-ink);
  -webkit-tap-highlight-color: transparent;
}
.kbt *, .kbt *::before, .kbt *::after { box-sizing: border-box; }
.kbt [hidden], .kbt[hidden] { display: none !important; }
.kbt button, .kbt input, .kbt select { font: inherit; color: inherit; }
.kbt :focus-visible { outline: 3px solid var(--k-focus); outline-offset: 2px; }
.kbt .k-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.kbt [dir="rtl"], .kbt:lang(ar), .kbt :lang(ar) { letter-spacing: normal; }

/* ---------- buttons ---------- */
.k-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--k-line-2); background: var(--k-surface); color: var(--k-ink);
  font-weight: 600; font-size: 15px; line-height: 1.2; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform 120ms var(--k-ease), background-color 150ms, border-color 150ms;
}
.k-btn svg { width: 18px; height: 18px; flex: none; }
.k-btn:active { transform: scale(.97); }
@media (hover: hover) { .k-btn:hover { border-color: var(--k-ink-3); } }
.k-btn--primary { border: 0; color: #fff; background: linear-gradient(115deg, var(--k-accent), var(--k-accent-2)); }
@media (hover: hover) { .k-btn--primary:hover { filter: brightness(1.06); } }
.k-btn--ghost { border-color: transparent; background: transparent; }
@media (hover: hover) { .k-btn--ghost:hover { background: var(--hover, rgba(11, 18, 32, .05)); border-color: transparent; } }
.k-btn[disabled] { opacity: .45; pointer-events: none; }

/* ---------- segmented control ---------- */
.k-seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 14px; background: var(--k-surface-2); border: 1px solid var(--k-line); }
.k-seg button {
  min-height: 36px; padding: 0 14px; border: 0; border-radius: 10px; background: transparent; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--k-ink-2);
  transition: background-color 160ms var(--k-ease), color 160ms, box-shadow 160ms;
}
.k-seg button[aria-pressed="true"] { background: var(--k-surface); color: var(--k-ink); box-shadow: 0 1px 2px rgba(11, 18, 32, .12), 0 0 0 1px var(--k-line); }

/* ---------- fields ---------- */
.k-label { display: block; font-size: 13px; font-weight: 700; color: var(--k-ink-2); margin: 0 0 8px; }
.k-field { display: grid; gap: 0; }
.k-group + .k-group { margin-top: 22px; }
.k-help { font-size: 13px; color: var(--k-ink-3); margin: 8px 0 0; line-height: 1.5; }

/* ---------- colour swatches ---------- */
.k-swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.k-swatch {
  position: relative; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--k-line-2); cursor: pointer; padding: 0;
  transition: transform 140ms var(--k-ease), box-shadow 160ms;
}
.k-swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--k-surface), 0 0 0 5px var(--k-accent); }
.k-swatch:active { transform: scale(.94); }

/* ---------- panel / sheet (Settings) ---------- */
.k-sheet { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px; }
.k-sheet__scrim { position: absolute; inset: 0; background: rgba(6, 10, 20, .45); }
.k-sheet__card {
  position: relative; width: min(460px, 100%); max-height: min(88vh, 720px); overflow: auto;
  background: var(--k-surface); color: var(--k-ink); border-radius: 22px; padding: 22px;
  box-shadow: 0 24px 60px rgba(6, 10, 20, .28);
}
.k-sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.k-sheet__head h2 { font-size: 20px; margin: 0; }
.k-sheet[data-state="open"] .k-sheet__scrim { animation: k-fade 200ms ease-out both; }
.k-sheet[data-state="open"] .k-sheet__card { animation: k-rise 260ms var(--k-ease) both; }
@keyframes k-fade { from { opacity: 0; } }
@keyframes k-rise { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@media (prefers-reduced-motion: reduce) {
  @keyframes k-rise { from { opacity: 0; } }
}

/* ---------- toast ---------- */
.k-toast {
  position: fixed; inset-inline: 0; bottom: 24px; margin-inline: auto; width: max-content; max-width: calc(100% - 32px); z-index: 95;
  padding: 12px 18px; border-radius: 12px; background: var(--k-ink); color: var(--k-surface); font-size: 14px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(6, 10, 20, .25); animation: k-rise 240ms var(--k-ease) both;
}

/* ---------- "get the app" strip (site only) ---------- */
.k-getapp {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px;
  margin-top: 20px; padding: 16px 18px; border-radius: var(--k-radius);
  background: var(--k-accent-tint); border: 1px solid var(--fam-app-line, #ddd6ff);
}
.k-getapp p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--k-ink-2); }
.k-getapp strong { color: var(--k-ink); }
.k-getapp .k-btn { background: var(--k-surface); }

.k-privacy { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--k-ink-3); margin: 14px 0 0; }
.k-privacy svg { width: 16px; height: 16px; flex: none; }

.k-skel { background: linear-gradient(90deg, var(--k-surface-2), var(--k-line), var(--k-surface-2)); background-size: 200% 100%; animation: k-shimmer 1.4s linear infinite; border-radius: 8px; }
@keyframes k-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .k-skel { animation-duration: 3s; } }

/* ---------- on khbros.app: the tool page around the tool ---------- */
.tool-hero { padding: clamp(18px, 3vw, 34px) 0 6px; }
.tool-head { display: flex; align-items: center; gap: 16px; margin-top: 12px; }
.tool-head h1 { margin: 0 0 6px; font-size: clamp(26px, 3.4vw, 40px); line-height: 1.25; letter-spacing: normal; }
.tool-head .lead { margin: 0; }
.tool-icon { width: 64px; height: 64px; border-radius: 15px; flex: none; }
@media (max-width: 560px) { .tool-icon { width: 48px; height: 48px; border-radius: 12px; } }
/* phones (17 Nov 2026): on a tool page only the follow strip and the logo bar stay on screen (owner, 17 Oct); the
   category tabs scroll away so the tool has the room. The title sits beside the icon, the line under it full width. */
@media (max-width: 760px) {
  :root:has(.tool-mount) { --cat-h: 0px; }
  body:has(.tool-mount) .cat-bar { position: static; }
  .tool-hero { padding-top: 14px; }
  .tool-head { display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: center; gap: 12px 14px; margin-top: 10px; }
  .tool-head > div { display: contents; }
  .tool-head h1 { margin: 0; font-size: 25px; line-height: 1.2; text-wrap: balance; }
  .tool-head .lead { grid-column: 1 / -1; font-size: 16px; line-height: 1.55; }
  .tool-wrap { padding-top: 10px; }
}
.tool-wrap { padding: 18px 0 44px; }
.tool-mount { --kbt-sticky-top: calc(var(--header-h, 108px) + var(--cat-h, 57px) + 14px); min-height: 60vh; }
.k-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 760px) { .k-steps { grid-template-columns: 1fr; } }
.k-step { display: flex; gap: 14px; padding: 18px; border-radius: 18px; background: var(--surface, #fff); border: 1px solid var(--line, #e2e6ee); }
.k-step__n { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; font-weight: 800;
  background: var(--fam-app-chip, #ece8ff); color: var(--fam-app-text, #4f3bd0); }
.k-step h3 { margin: 4px 0 6px; font-size: 17px; }
.k-step p { margin: 0; color: var(--text-2, #3a4559); line-height: 1.55; }

/* "Download" in front of PNG: dropped on narrow screens, the icon says it */
@media (max-width: 480px) { .k-dlw { display: none; } }

/* the × that empties a text field (shows only while it has text) */
.k-xw { position: relative; display: block; flex: 1 1 auto; min-width: 0; }
.k-xw > input, .k-xw > textarea { padding-inline-end: 44px !important; }
.k-x { position: absolute; inset-block: 0; inset-inline-end: 4px; margin-block: auto; width: 36px; height: 36px; display: grid; place-items: center;
  padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--k-ink-3); cursor: pointer;
  transition: background-color 150ms, color 150ms, opacity 150ms; }
.k-x svg { width: 16px; height: 16px; padding: 3px; box-sizing: content-box; border-radius: 50%; background: color-mix(in srgb, var(--k-ink) 10%, transparent); }
@media (hover: hover) { .k-x:hover { color: var(--k-ink); } .k-x:hover svg { background: color-mix(in srgb, var(--k-ink) 18%, transparent); } }
.k-x:focus-visible { outline: 3px solid var(--k-focus); outline-offset: 0; }
.k-x:active { transform: scale(.92); }
.k-xw > :placeholder-shown + .k-x { opacity: 0; pointer-events: none; visibility: hidden; }
.k-xw--area > .k-x { inset-block: 6px auto; margin: 0; }

/* rows that scroll sideways can be dragged with the mouse */
@media (hover: hover) and (pointer: fine) { .k-drag-x.k-drag-on { cursor: grab; } }
.k-drag-x.is-dragging { cursor: grabbing; scroll-snap-type: none !important; user-select: none; -webkit-user-select: none; }
.k-drag-x.is-dragging * { cursor: grabbing !important; pointer-events: none; }

/* guidelines pass (18 Nov): no double-tap zoom delay on controls; scrolling panels never drag the page; menus readable in dark mode */
.kbt button, .kbt select, .kbt input, .kbt label, .kbt summary, .kbt a { touch-action: manipulation; }
.k-sheet__card, .kan-layers__list, .kan-tray__row, .kan-grid, .kqr-gallery, .kqr-side { overscroll-behavior: contain; }
.kbt select { color: var(--k-ink); background-color: var(--k-surface); }
.kbt select option, .kbt select optgroup { color: var(--k-ink); background-color: var(--k-surface); }
.k-btn.is-armed { border-color: #dc2626; color: #dc2626; }
