/* Toolingo tools — premium, minimal UI. Works inside any theme; the Toolingo theme shares these tokens.
   Layout idea: quiet grey canvas, one white work surface per tool, pill controls, category colour only on icons and primary actions. */

:root {
  --tk-bg: #f5f5f7;
  --tk-surface: #ffffff;
  --tk-surface-2: #f2f2f4;
  --tk-text: #1d1d1f;
  --tk-muted: #6e6e73;
  --tk-border: #d2d2d7;
  --tk-hair: rgba(0, 0, 0, .08);
  --tk-accent: #ff5a1f;
  --tk-accent-ink: #ffffff;
  --tk-accent-soft: #fff1ea;
  --tk-ok: #1a7f4b;
  --tk-warn: #b26a00;
  --tk-err: #d70015;
  --tk-pdf: #e5382f;
  --tk-image: #0a9a8b;
  --tk-media: #7a4ee0;
  --tk-calc: #d98a00;
  --tk-dev: #2f6fe4;
  --tk-util: #e0457b;
  --tk-radius: 18px;
  --tk-radius-lg: 28px;
  --tk-shadow: 0 2px 6px rgba(0, 0, 0, .04), 0 18px 40px -24px rgba(0, 0, 0, .18);
  --tk-ease: cubic-bezier(.25, .1, .25, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tk-bg: #000000; --tk-surface: #1c1c1e; --tk-surface-2: #2c2c2e; --tk-text: #f5f5f7; --tk-muted: #a1a1a6;
    --tk-border: #3a3a3c; --tk-hair: rgba(255, 255, 255, .1); --tk-accent-soft: #3a1e12;
    --tk-shadow: 0 2px 6px rgba(0, 0, 0, .4), 0 18px 40px -24px rgba(0, 0, 0, .7); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --tk-bg: #000000; --tk-surface: #1c1c1e; --tk-surface-2: #2c2c2e; --tk-text: #f5f5f7; --tk-muted: #a1a1a6;
  --tk-border: #3a3a3c; --tk-hair: rgba(255, 255, 255, .1); --tk-accent-soft: #3a1e12;
  --tk-shadow: 0 2px 6px rgba(0, 0, 0, .4), 0 18px 40px -24px rgba(0, 0, 0, .7); color-scheme: dark;
}

.tk-cat-pdf { --cat: var(--tk-pdf); }
.tk-cat-image { --cat: var(--tk-image); }
.tk-cat-media { --cat: var(--tk-media); }
.tk-cat-calc { --cat: var(--tk-calc); }
.tk-cat-dev { --cat: var(--tk-dev); }
.tk-cat-util { --cat: var(--tk-util); }

.tk-wrap { color: var(--tk-text); font-size: 17px; line-height: 1.5; letter-spacing: -0.01em; }
.tk-wrap *, .tk-modal * { box-sizing: border-box; }
.tk-wrap [hidden], .tk-modal [hidden] { display: none !important; }
.tk-ico { flex: none; }

/* ------------------------------------------------------------------ tool surface */

.tk-tool {
  --cat: var(--tk-accent);
  background: var(--tk-surface);
  border-radius: var(--tk-radius-lg);
  padding: clamp(18px, 4vw, 40px);
  box-shadow: var(--tk-shadow);
  min-height: 240px;
}
.tk-tool.tk-cat-pdf { --cat: var(--tk-pdf); } .tk-tool.tk-cat-image { --cat: var(--tk-image); } .tk-tool.tk-cat-media { --cat: var(--tk-media); }
.tk-tool.tk-cat-calc { --cat: var(--tk-calc); } .tk-tool.tk-cat-dev { --cat: var(--tk-dev); } .tk-tool.tk-cat-util { --cat: var(--tk-util); }
.tk-tool.is-ready > * { animation: tk-in .45s var(--tk-ease) both; }
@keyframes tk-in { from { opacity: .001; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.tk-boot { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 200px; color: var(--tk-muted); }
.tk-spin { width: 20px; height: 20px; border: 2.5px solid var(--tk-border); border-top-color: var(--cat); border-radius: 50%; animation: tk-spin .8s linear infinite; }
@keyframes tk-spin { to { transform: rotate(360deg); } }

.tk-intro { color: var(--tk-muted); margin: 0 0 18px; font-size: .95rem; text-align: center; max-width: 62ch; margin-inline: auto; }
.tk-muted { color: var(--tk-muted); }
.tk-center { text-align: center; }
.tk-error { color: var(--tk-err); }

/* ------------------------------------------------------------------ dropzone */

.tk-drop {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  min-height: 260px; padding: 32px 16px; text-align: center; cursor: pointer;
  border: 1.5px dashed color-mix(in srgb, var(--cat) 35%, var(--tk-border));
  border-radius: 22px;
  background: radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--cat) 7%, var(--tk-surface)), var(--tk-surface) 70%);
  transition: background .25s var(--tk-ease), border-color .25s var(--tk-ease), transform .25s var(--tk-ease);
}
.tk-drop:hover, .tk-drop.is-over { border-color: var(--cat); background: radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--cat) 13%, var(--tk-surface)), var(--tk-surface) 75%); }
.tk-drop.is-over { transform: scale(1.01); }
.tk-drop:focus-visible { outline: 3px solid color-mix(in srgb, var(--cat) 45%, transparent); outline-offset: 3px; }
.tk-drop-ico { color: var(--cat); display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; background: color-mix(in srgb, var(--cat) 12%, var(--tk-surface)); }
.tk-drop-btn { display: inline-block; padding: 14px 30px; border-radius: 980px; background: var(--cat); color: #fff; font-weight: 600; font-size: 1.05rem; letter-spacing: -0.01em; }
.tk-drop:hover .tk-drop-btn { filter: brightness(1.07); }
.tk-drop-hint { color: var(--tk-muted); font-size: .9rem; }
.tk-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ------------------------------------------------------------------ file list */

.tk-file-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.tk-file { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--tk-surface-2); }
.tk-file-ico { color: var(--cat); display: flex; }
.tk-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: .95rem; }
.tk-file-size { color: var(--tk-muted); font-size: .85rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tk-add-row { margin-bottom: 14px; }

/* ------------------------------------------------------------------ buttons */

.tk-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 20px; border-radius: 980px; cursor: pointer;
  border: 1px solid var(--tk-border); background: var(--tk-surface); color: var(--tk-text);
  font: inherit; font-weight: 600; font-size: .95rem; line-height: 1.2; letter-spacing: -0.01em; text-decoration: none;
  transition: background .2s var(--tk-ease), border-color .2s var(--tk-ease), transform .1s, filter .2s;
}
.tk-btn:hover { border-color: color-mix(in srgb, var(--cat, var(--tk-accent)) 55%, var(--tk-border)); }
.tk-btn:active { transform: scale(.98); }
.tk-btn:disabled { opacity: .45; cursor: not-allowed; }
.tk-btn:focus-visible, .tk-icon-btn:focus-visible, .tk-chip:focus-visible, .tk-seg-btn:focus-visible, .tk-tab:focus-visible { outline: 3px solid color-mix(in srgb, var(--cat, var(--tk-accent)) 45%, transparent); outline-offset: 2px; }
.tk-btn-primary { background: var(--cat, var(--tk-accent)); border-color: transparent; color: #fff; }
.tk-btn-primary:hover { filter: brightness(1.08); border-color: transparent; }
.tk-btn-lg { min-height: 54px; padding: 14px 34px; font-size: 1.06rem; }
.tk-icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; color: var(--tk-muted); cursor: pointer; font: inherit; font-size: 1.1rem; }
.tk-icon-btn:hover:not(:disabled) { background: var(--tk-surface); color: var(--tk-text); }
.tk-icon-btn:disabled { opacity: .3; cursor: default; }

.tk-run-row { display: flex; justify-content: center; margin: 22px 0 4px; }
.tk-run { min-width: 240px; }
.tk-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 0; }
.tk-actions.tk-center { justify-content: center; }
.tk-row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

/* ------------------------------------------------------------------ fields */

.tk-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px 20px; margin: 8px 0; padding: 20px; border-radius: 20px; background: var(--tk-surface-2); }
.tk-field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.tk-field-wide { grid-column: 1 / -1; }
.tk-field > label, .tk-label { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; font-size: .88rem; color: var(--tk-text); }
.tk-label { margin: 16px 0 8px; }
.tk-field output { color: var(--cat, var(--tk-accent)); font-variant-numeric: tabular-nums; }
.tk-field-check label { display: flex; align-items: center; justify-content: flex-start; gap: 10px; font-weight: 500; font-size: .95rem; cursor: pointer; }
.tk-help { color: var(--tk-muted); font-size: .82rem; line-height: 1.45; }

.tk-input {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--tk-border); background: var(--tk-surface); color: var(--tk-text);
  font: inherit; font-size: 16px; letter-spacing: normal;
  transition: border-color .2s, box-shadow .2s;
}
textarea.tk-input { resize: vertical; line-height: 1.55; }
.tk-input:focus { outline: none; border-color: var(--cat, var(--tk-accent)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--cat, var(--tk-accent)) 18%, transparent); }
.tk-mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 14px; }
.tk-output { background: var(--tk-surface-2); }
input[type="range"] { accent-color: var(--cat, var(--tk-accent)); width: 100%; }
input[type="color"].tk-input { padding: 4px; height: 46px; cursor: pointer; }
.tk-check { width: 22px; height: 22px; accent-color: var(--cat, var(--tk-accent)); flex: none; }

.tk-seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--tk-surface); border-radius: 14px; box-shadow: inset 0 0 0 1px var(--tk-hair); }
.tk-seg-btn { flex: 1 1 auto; min-height: 38px; padding: 7px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--tk-muted); font: inherit; font-weight: 600; font-size: .88rem; cursor: pointer; transition: background .2s var(--tk-ease), color .2s; }
.tk-seg-btn:hover { color: var(--tk-text); }
.tk-seg-btn[aria-pressed="true"] { background: var(--cat, var(--tk-accent)); color: #fff; box-shadow: 0 2px 8px -3px color-mix(in srgb, var(--cat, var(--tk-accent)) 70%, transparent); }

/* ------------------------------------------------------------------ status & results */

.tk-status { margin-top: 14px; }
.tk-progress { height: 6px; border-radius: 999px; background: var(--tk-surface-2); overflow: hidden; }
.tk-progress span { display: block; height: 100%; width: 2%; background: var(--cat, var(--tk-accent)); border-radius: inherit; transition: width .25s var(--tk-ease); }
.tk-msg { margin: 12px 0 0; padding: 12px 16px; border-radius: 14px; background: var(--tk-surface-2); font-size: .93rem; }
.tk-msg-error { background: color-mix(in srgb, var(--tk-err) 10%, var(--tk-surface)); color: var(--tk-err); }
.tk-msg-warn { background: color-mix(in srgb, var(--tk-warn) 12%, var(--tk-surface)); }
.tk-msg-success { background: color-mix(in srgb, var(--tk-ok) 10%, var(--tk-surface)); color: var(--tk-ok); }
.tk-msg-info { background: color-mix(in srgb, var(--cat, var(--tk-accent)) 9%, var(--tk-surface)); }

.tk-results { margin-top: 22px; padding: 20px; border-radius: 22px; background: var(--tk-surface-2); animation: tk-in .4s var(--tk-ease) both; }
.tk-summary { margin: 0 0 14px; font-weight: 700; font-size: 1.05rem; }
.tk-result-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 520px; overflow: auto; }
.tk-result { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 16px; background: var(--tk-surface); }
.tk-result-media { flex-wrap: wrap; }
.tk-result-media .tk-media-preview { flex: 1 1 100%; }
.tk-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 12px; background: var(--tk-surface-2); flex: none; }
.tk-thumb-file { display: grid; place-items: center; color: var(--cat, var(--tk-accent)); }
.tk-result-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tk-result-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-result-name small { color: var(--tk-muted); }
.tk-media-preview { width: 100%; max-height: 380px; border-radius: 14px; background: #000; margin: 6px 0; }
audio.tk-media-preview { background: transparent; }

/* ------------------------------------------------------------------ previews */

.tk-preview-box { display: grid; place-items: center; padding: 14px; margin: 8px 0; border-radius: 20px; background: repeating-conic-gradient(var(--tk-surface-2) 0 25%, var(--tk-surface) 0 50%) 50% / 20px 20px; overflow: hidden; }
.tk-preview { max-width: 100%; max-height: 460px; transition: transform .3s var(--tk-ease); }
canvas.tk-preview { height: auto; }
.tk-extra:not(:empty) { margin-bottom: 16px; }

.tk-crop-stage { position: relative; display: block; width: fit-content; max-width: 100%; margin: 0 auto 10px; touch-action: none; user-select: none; }
.tk-crop-img { display: block; max-width: 100%; max-height: 70vh; border-radius: 6px; }
.tk-crop-box { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .55); cursor: move; outline: 1px dashed rgba(0, 0, 0, .6); }
.tk-crop-h { position: absolute; width: 24px; height: 24px; background: #fff; border: 2px solid var(--cat); border-radius: 50%; }
.tk-crop-nw { left: -12px; top: -12px; cursor: nwse-resize; } .tk-crop-ne { right: -12px; top: -12px; cursor: nesw-resize; }
.tk-crop-sw { left: -12px; bottom: -12px; cursor: nesw-resize; } .tk-crop-se { right: -12px; bottom: -12px; cursor: nwse-resize; }
.tk-blur-canvas { cursor: crosshair; touch-action: none; }

/* PDF page grid (organize) */
.tk-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; }
.tk-page { border-radius: 16px; background: var(--tk-surface-2); overflow: hidden; cursor: grab; transition: transform .2s var(--tk-ease); }
.tk-page:hover { transform: translateY(-2px); }
.tk-page.is-drag { opacity: .4; }
.tk-page.is-deleted .tk-page-img { opacity: .2; }
.tk-page-img { display: grid; place-items: center; aspect-ratio: 3 / 4; padding: 10px; overflow: hidden; }
.tk-page-img img { max-width: 100%; max-height: 100%; box-shadow: 0 2px 8px rgba(0, 0, 0, .18); background: #fff; transition: transform .25s var(--tk-ease); }
.tk-page-bar { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px; background: var(--tk-surface); }
.tk-page-bar .tk-icon-btn { width: 30px; height: 30px; font-size: 1rem; }
.tk-page-num { font-weight: 700; font-size: .85rem; padding: 0 4px; }

/* Redact */
.tk-redact { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.tk-redact-page { position: relative; max-width: 100%; box-shadow: 0 2px 10px rgba(0, 0, 0, .15); touch-action: none; cursor: crosshair; background: #fff; }
.tk-redact-page canvas { display: block; height: auto; }
.tk-redact-layer { position: absolute; inset: 0; }
.tk-redact-box { position: absolute; padding: 0; border: 0; background: #000; cursor: pointer; opacity: .9; }
.tk-redact-box:hover { outline: 2px solid var(--cat); }

/* Compare */
.tk-diff { max-height: 560px; overflow: auto; border-radius: 14px; background: var(--tk-surface); font: 14px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.tk-diff-row { display: grid; grid-template-columns: 42px 18px 1fr; gap: 6px; padding: 3px 10px; }
.tk-diff-pg { color: var(--tk-muted); font-size: 12px; }
.tk-diff-text { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.tk-diff-add { background: color-mix(in srgb, var(--tk-ok) 14%, transparent); }
.tk-diff-rem { background: color-mix(in srgb, var(--tk-err) 12%, transparent); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--tk-err) 50%, transparent); }
.tk-diff-eq { color: var(--tk-muted); }

/* ------------------------------------------------------------------ PDF editor */

.tk-editor { position: relative; }
.tk-ed-toolbar {
  position: sticky; top: var(--tk-sticky-top, 0px); z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
  padding: 8px; margin-bottom: 10px; border-radius: 18px;
  background: color-mix(in srgb, var(--tk-surface) 86%, transparent); backdrop-filter: saturate(1.8) blur(18px); -webkit-backdrop-filter: saturate(1.8) blur(18px);
  box-shadow: 0 0 0 1px var(--tk-hair), var(--tk-shadow);
}
.tk-ed-group { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.tk-ed-save { margin-left: auto; }
.tk-ed-tool { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; min-width: 58px; padding: 7px 6px 5px; border: 0; border-radius: 12px; background: transparent; color: var(--tk-text); font: inherit; font-size: .72rem; font-weight: 600; cursor: pointer; transition: background .15s; }
.tk-ed-tool:hover { background: var(--tk-surface-2); }
.tk-ed-tool[aria-pressed="true"] { background: color-mix(in srgb, var(--cat) 14%, var(--tk-surface)); color: var(--cat); }
.tk-ed-style .tk-input { width: auto; min-height: 38px; padding: 4px 10px; font-size: 14px; border-radius: 10px; }
.tk-ed-color { width: 42px; height: 38px; padding: 2px; border: 1px solid var(--tk-border); border-radius: 10px; background: var(--tk-surface); cursor: pointer; }
.tk-ed-hint { margin: 0 0 12px; color: var(--tk-muted); font-size: .88rem; min-height: 1.3em; text-align: center; }
.tk-ed-pages { display: flex; flex-direction: column; align-items: safe center; gap: 22px; padding: 20px 6px; border-radius: 22px; background: var(--tk-surface-2); overflow-x: auto; }
.tk-ed-page { position: relative; flex: none; background: #fff; box-shadow: 0 2px 12px rgba(0, 0, 0, .18); }
.tk-ed-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.tk-ed-overlay { position: absolute; inset: 0; touch-action: none; }
.tk-editor[data-tool="select"] .tk-ed-overlay, .tk-editor[data-tool="edit"] .tk-ed-overlay { touch-action: pan-x pan-y; }
.tk-editor[data-tool="text"] .tk-ed-overlay { cursor: text; }
.tk-editor[data-tool="draw"] .tk-ed-overlay, .tk-editor[data-tool="highlight"] .tk-ed-overlay,
.tk-editor[data-tool="rect"] .tk-ed-overlay, .tk-editor[data-tool="whiteout"] .tk-ed-overlay { cursor: crosshair; }
.tk-ed-items, .tk-ed-hits { position: absolute; inset: 0; }
.tk-ed-hits { display: none; z-index: 2; }
.tk-editor[data-tool="edit"] .tk-ed-hits { display: block; }
.tk-ed-hit { position: absolute; cursor: text; border-radius: 2px; }
.tk-ed-hit:hover { background: rgba(255, 90, 31, .15); outline: 1px solid rgba(255, 90, 31, .7); }
.tk-ed-item { position: absolute; touch-action: none; cursor: move; }
.tk-ed-text { white-space: pre; line-height: 1.2; min-width: 6px; padding: 0; outline: none; }
.tk-ed-text.is-editing { cursor: text; outline: 1.5px dashed var(--cat); background: rgba(255, 255, 255, .6); }
.tk-ed-whiteout { background: #fff; }
.tk-ed-highlight { mix-blend-mode: multiply; }
.tk-ed-image img { width: 100%; height: 100%; display: block; pointer-events: none; user-select: none; }
.tk-ed-draw { overflow: visible; }
.tk-ed-item.is-sel { outline: 1.5px solid var(--cat); outline-offset: 2px; }
.tk-ed-whiteout.is-sel { outline-style: dashed; }
.tk-ed-handle { position: absolute; right: -10px; bottom: -10px; width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 2px solid var(--cat); cursor: nwse-resize; }
.tk-ed-pnum { position: absolute; right: 6px; bottom: -22px; font-size: .75rem; color: var(--tk-muted); }

/* Signature */
.tk-sig-pad { width: 100%; height: auto; aspect-ratio: 3 / 1; border: 1px dashed var(--tk-border); border-radius: 16px; background: #fff; touch-action: none; margin: 12px 0; cursor: crosshair; }
.tk-sig-pane { margin-top: 12px; display: grid; gap: 10px; }
.tk-sig-colors { display: flex; gap: 8px; }
.tk-sig-swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--tk-surface); box-shadow: 0 0 0 1px var(--tk-border); cursor: pointer; }
.tk-sig-saved { max-width: 100%; max-height: 160px; background: #fff; border-radius: 10px; padding: 8px; }

/* Recorders & waveform */
.tk-rec { display: grid; justify-items: center; gap: 12px; padding: 24px 8px 8px; }
.tk-rec-clock { font: 600 clamp(2.6rem, 8vw, 4rem)/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.tk-rec-meter { width: min(100%, 520px); height: 64px; }
.tk-rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #fff; display: inline-block; }
.tk-rec-btn:disabled .tk-rec-dot { animation: tk-pulse 1s ease-in-out infinite; }
@keyframes tk-pulse { 50% { opacity: .3; } }
.tk-wave { width: 100%; height: 110px; margin: 6px 0 10px; border-radius: 14px; background: var(--tk-surface-2); cursor: crosshair; touch-action: none; }

/* ------------------------------------------------------------------ modal & switcher */

.tk-modal { width: min(640px, calc(100vw - 24px)); padding: 0; border: 0; border-radius: 22px; background: var(--tk-surface); color: var(--tk-text); box-shadow: 0 40px 100px -30px rgba(0, 0, 0, .5); }
.tk-modal::backdrop { background: rgba(0, 0, 0, .4); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.tk-modal[open] { animation: tk-pop .28s var(--tk-ease); }
@keyframes tk-pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.tk-modal form { padding: 24px; }
.tk-modal h3 { margin: 0 0 8px; font-size: 1.3rem; letter-spacing: -0.02em; }
.tk-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.tk-modal .tk-btn-primary { background: var(--tk-accent); }

.tk-switch { width: min(720px, calc(100vw - 20px)); max-height: min(78vh, 680px); margin-top: 8vh; overflow: hidden; display: flex; flex-direction: column; }
.tk-switch[open] { display: flex; }
.tk-switch-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 12px; color: var(--tk-muted); }
.tk-switch-input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--tk-text); font: 600 1.35rem/1.2 inherit; letter-spacing: -0.02em; outline: none; box-shadow: none; }
.tk-switch-input:focus, .tk-switch-input:focus-visible { outline: none; }
.tk-switch-head:focus-within { color: var(--tk-accent); }
.tk-switch-input::-webkit-search-cancel-button { display: none; }
.tk-switch-head kbd, .tk-kbd { font: 600 .72rem ui-monospace, Menlo, monospace; padding: 3px 7px; border-radius: 6px; border: 1px solid var(--tk-border); color: var(--tk-muted); }
.tk-switch-tabs { padding: 0 16px 10px; margin: 0; border-bottom: 1px solid var(--tk-hair); }
.tk-switch-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.tk-switch-sep { padding: 10px 12px 4px; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--tk-muted); }
.tk-switch-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; cursor: pointer; }
.tk-switch-item[aria-selected="true"] { background: var(--tk-surface-2); }
.tk-switch-ico { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: var(--cat); background: color-mix(in srgb, var(--cat) 12%, var(--tk-surface)); flex: none; }
.tk-switch-name { flex: 1; font-weight: 600; }
.tk-switch-cat { color: var(--tk-muted); font-size: .82rem; }
.tk-switch-item.is-current .tk-switch-cat { color: var(--cat); font-weight: 600; }
.tk-switch-empty { padding: 28px; text-align: center; color: var(--tk-muted); }
.tk-switch-foot { margin: 0; padding: 10px 18px; border-top: 1px solid var(--tk-hair); color: var(--tk-muted); font-size: .78rem; }
@media (max-width: 600px) { .tk-switch { margin-top: 0; max-height: 92vh; } .tk-switch-foot { display: none; } }

/* Category tabs (directory + switcher) */
.tk-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px; margin: 0 0 24px; scrollbar-width: none; }
.tk-tabs::-webkit-scrollbar { display: none; }
.tk-tab { display: inline-flex; align-items: center; gap: 6px; flex: none; padding: 8px 16px; border-radius: 980px; border: 0; background: var(--tk-surface); color: var(--tk-text); font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; box-shadow: inset 0 0 0 1px var(--tk-hair); transition: background .2s, color .2s; }
.tk-tab .tk-ico, .tk-tab svg { color: var(--cat); }
.tk-tab[aria-pressed="true"] { background: var(--tk-text); color: var(--tk-surface); box-shadow: none; }
.tk-tab[aria-pressed="true"] svg { color: inherit; }

/* Chapter strip — switch between tools of one category */
.tk-chapter { --cat: var(--tk-accent); position: relative; margin: 0 0 8px; }
.tk-chapter-track { display: flex; gap: 4px; justify-content: safe center; overflow-x: auto; padding: 6px 8px 10px; scroll-behavior: smooth; scrollbar-width: none; -webkit-mask: linear-gradient(90deg, transparent, #000 24px, #000 calc(100% - 24px), transparent); mask: linear-gradient(90deg, transparent, #000 24px, #000 calc(100% - 24px), transparent); }
.tk-chapter-track::-webkit-scrollbar { display: none; }
.tk-chapter-item { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: none; width: 96px; padding: 8px 4px; border-radius: 14px; color: var(--tk-text); text-decoration: none; text-align: center; transition: background .2s, transform .2s var(--tk-ease); }
.tk-chapter-item:hover { background: var(--tk-surface); transform: translateY(-1px); }
.tk-chapter-ico { display: grid; place-items: center; width: 44px; height: 44px; color: var(--tk-muted); transition: color .2s; }
.tk-chapter-item:hover .tk-chapter-ico, .tk-chapter-item.is-current .tk-chapter-ico { color: var(--cat); }
.tk-chapter-label { font-size: .74rem; font-weight: 500; line-height: 1.25; color: var(--tk-muted); }
.tk-chapter-item.is-current .tk-chapter-label { color: var(--tk-text); font-weight: 700; }
.tk-chapter-item.is-current { position: relative; }
.tk-chapter-item.is-current::after { content: ""; position: absolute; left: 28%; right: 28%; bottom: 0; height: 2px; border-radius: 2px; background: var(--cat); }

/* ------------------------------------------------------------------ utilities */

.tk-split { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
.tk-split > * { min-width: 0; }
@media (min-width: 760px) { .tk-split { grid-template-columns: 1fr 1fr; } }
.tk-qr { width: min(100%, 320px); height: auto; border-radius: 16px; image-rendering: pixelated; transition: opacity .2s; box-shadow: 0 0 0 1px var(--tk-hair); }
.tk-out-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tk-out-row .tk-input { flex: 1 1 240px; }
.tk-big-out { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 1.15rem; letter-spacing: .02em; }
.tk-meter { height: 6px; border-radius: 99px; background: var(--tk-surface-2); margin: 14px 0 4px; overflow: hidden; }
.tk-meter span { display: block; height: 100%; transition: width .25s; }
.tk-meter-bad span { background: var(--tk-err); } .tk-meter-warn span { background: var(--tk-warn); } .tk-meter-good span { background: var(--tk-ok); }
.tk-pw-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.tk-pw-list li { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 6px 6px 6px 14px; border-radius: 14px; background: var(--tk-surface-2); }
.tk-pw-list code { overflow-wrap: anywhere; font-size: .95rem; min-width: 0; }
.tk-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 16px 0; }
.tk-stat { padding: 16px; border-radius: 18px; background: var(--tk-surface-2); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tk-stat strong { font-size: 1.4rem; font-variant-numeric: tabular-nums; line-height: 1.15; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.tk-stat span { color: var(--tk-muted); font-size: .82rem; }
.tk-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.tk-chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 15px; border-radius: 980px; border: 0; background: var(--tk-surface); color: var(--tk-text); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; text-decoration: none; box-shadow: inset 0 0 0 1px var(--tk-hair); transition: color .2s, box-shadow .2s; }
a.tk-chip:hover, button.tk-chip:hover, label.tk-chip:hover { color: var(--cat, var(--tk-accent)); box-shadow: inset 0 0 0 1px var(--cat, var(--tk-accent)); }
.tk-keywords .tk-chip { cursor: default; font-weight: 500; }
.tk-conv-row { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 12px 0; }
@media (min-width: 640px) { .tk-conv-row { grid-template-columns: 1.2fr 1fr auto 1fr; align-items: center; } }
.tk-big-in { font-size: 1.2rem; font-weight: 700; }
.tk-big-result { padding: 18px 20px; border-radius: 18px; background: color-mix(in srgb, var(--cat) 9%, var(--tk-surface)); font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.tk-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: .92rem; font-variant-numeric: tabular-nums; }
.tk-table th, .tk-table td { padding: 9px 10px; border-bottom: 1px solid var(--tk-hair); text-align: left; }
.tk-table td:not(:first-child), .tk-table th:not(:first-child) { text-align: right; }
.tk-details { margin-top: 12px; overflow-x: auto; }
.tk-details summary { cursor: pointer; font-weight: 700; padding: 8px 0; }
.tk-donut { width: 180px; height: 180px; margin: 8px auto; border-radius: 50%; -webkit-mask: radial-gradient(circle, transparent 54%, #000 55%); mask: radial-gradient(circle, transparent 54%, #000 55%); }
.tk-legend { display: flex; justify-content: center; gap: 16px; font-size: .88rem; }
.tk-leg::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.tk-leg-a::before { background: var(--tk-accent); } .tk-leg-b::before { background: var(--tk-warn); }
.tk-panel { padding: 18px; margin-bottom: 12px; border-radius: 20px; background: var(--tk-surface-2); min-width: 0; }
.tk-panel h4 { margin: 0 0 10px; }
.tk-pct-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.tk-inline { width: 130px; flex: none; }
.tk-pct-result { font-size: 1.15rem; color: var(--cat); }
.tk-codes { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.tk-code { padding: 9px 13px; border-radius: 10px; border: 0; background: var(--tk-surface-2); color: var(--tk-text); font: 600 .9rem ui-monospace, "SF Mono", Menlo, Consolas, monospace; cursor: pointer; overflow-wrap: anywhere; text-align: left; }
.tk-code:hover { box-shadow: inset 0 0 0 1px var(--cat); }
.tk-palette { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; min-height: 8px; }
.tk-color-chip { width: 42px; height: 42px; border-radius: 12px; border: 1px solid rgba(0, 0, 0, .12); cursor: pointer; }
.tk-color-big { width: 64px; height: 54px; padding: 2px; border: 1px solid var(--tk-border); border-radius: 14px; background: var(--tk-surface); cursor: pointer; }
.tk-swatch-big { display: block; width: 76px; height: 76px; border-radius: 18px; border: 1px solid var(--tk-hair); flex: none; }
.tk-pick { display: grid; gap: 16px; margin-top: 16px; }
@media (min-width: 760px) { .tk-pick { grid-template-columns: 1.6fr 1fr; } }
.tk-pick-canvas { max-width: 100%; height: auto; border-radius: 12px; cursor: crosshair; display: block; }
.tk-pick-current { display: flex; gap: 12px; align-items: center; }
.tk-pick-current .tk-codes { flex-direction: column; margin: 0; }

/* Calculators */
.tk-bars { display: flex; align-items: flex-end; gap: 3px; height: 200px; padding: 10px 0 22px; margin-top: 8px; overflow-x: auto; }
.tk-bar { position: relative; flex: 1 0 14px; height: 100%; display: flex; flex-direction: column-reverse; }
.tk-bar span { display: block; width: 100%; }
.tk-bar-a { background: var(--tk-accent); border-radius: 0 0 3px 3px; }
.tk-bar-b { background: var(--tk-warn); border-radius: 3px 3px 0 0; }
.tk-bar small { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: .68rem; color: var(--tk-muted); }
.tk-compare { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-top: 14px; }
.tk-compare-col { padding: 18px; border-radius: 20px; background: var(--tk-surface-2); box-shadow: inset 0 0 0 1px transparent; }
.tk-compare-col.is-best { box-shadow: inset 0 0 0 2px var(--cat); }
.tk-compare-col h4 { display: flex; align-items: center; justify-content: space-between; margin: 0 0 10px; font-size: 1.1rem; }
.tk-compare-col dl { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0; font-variant-numeric: tabular-nums; }
.tk-compare-col dt { color: var(--tk-muted); font-size: .9rem; }
.tk-compare-col dd { margin: 0; text-align: right; font-weight: 600; }
.tk-dl-total { padding-top: 8px; border-top: 1px solid var(--tk-hair); font-size: 1.05rem !important; color: var(--tk-text) !important; font-weight: 800 !important; }
.tk-badge { display: inline-block; padding: 3px 10px; border-radius: 980px; background: var(--cat); color: #fff; font-size: .72rem; font-weight: 700; }

/* Developer tools */
.tk-regex-view { min-height: 3em; padding: 12px 14px; border-radius: 12px; background: var(--tk-surface-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.tk-regex-view mark { background: color-mix(in srgb, var(--cat) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.tk-regex-list { margin: 10px 0 0; padding-left: 26px; display: grid; gap: 4px; }
.tk-regex-list li { overflow-wrap: anywhere; }
.tk-rgroup { display: inline-block; margin-left: 10px; color: var(--tk-muted); font-size: .85em; }
.tk-hashes { display: grid; gap: 8px; margin-top: 14px; }
.tk-hash-row { display: grid; grid-template-columns: 80px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 14px; background: var(--tk-surface-2); }
.tk-hash-row code { font-size: .82rem; overflow-wrap: anywhere; min-width: 0; }
@media (max-width: 520px) { .tk-hash-row { grid-template-columns: 1fr auto; } .tk-hash-row code { grid-column: 1 / -1; grid-row: 2; } }

/* ------------------------------------------------------------------ directory & cards */

.tk-search { display: flex; align-items: center; gap: 12px; padding: 0 20px; margin: 0 0 18px; min-height: 60px; border-radius: 18px; background: var(--tk-surface); box-shadow: 0 0 0 1px var(--tk-hair), var(--tk-shadow); color: var(--tk-muted); transition: box-shadow .2s; }
.tk-search:focus-within { box-shadow: 0 0 0 2px var(--tk-accent), var(--tk-shadow); }
.tk-search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--tk-text); font: inherit; font-size: 1.08rem; outline: none; padding: 16px 0; }
.tk-noresult { text-align: center; color: var(--tk-muted); }
.tk-group { margin-bottom: 44px; }
.tk-group-title { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; font-size: 1.5rem; letter-spacing: -0.02em; }
.tk-group-title a { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.tk-group-title a:hover { color: var(--tk-accent); }
.tk-group-title span { font-size: .78rem; padding: 3px 10px; border-radius: 99px; background: var(--tk-surface); color: var(--tk-muted); letter-spacing: 0; }
.tk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.tk-card {
  display: flex; gap: 14px; align-items: flex-start; padding: 20px; border-radius: 20px;
  background: var(--tk-surface); color: var(--tk-text); text-decoration: none;
  box-shadow: 0 0 0 1px var(--tk-hair);
  transition: transform .3s var(--tk-ease), box-shadow .3s var(--tk-ease);
}
.tk-card:hover { transform: translateY(-3px) scale(1.01); box-shadow: 0 0 0 1px var(--tk-hair), var(--tk-shadow); }
.tk-card:focus-visible { outline: 3px solid color-mix(in srgb, var(--cat, var(--tk-accent)) 45%, transparent); outline-offset: 2px; }
.tk-card-ico { display: grid; place-items: center; flex: none; width: 46px; height: 46px; border-radius: 14px; color: var(--cat, var(--tk-accent)); background: color-mix(in srgb, var(--cat, var(--tk-accent)) 11%, var(--tk-surface)); }
.tk-card-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tk-card-body strong { font-size: 1.02rem; letter-spacing: -0.01em; }
.tk-card-body span { color: var(--tk-muted); font-size: .86rem; line-height: 1.4; }

.tk-privacy { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 18px 0 0; color: var(--tk-muted); font-size: .86rem; text-align: center; }
.tk-privacy .tk-ico { color: var(--tk-ok); }
.tk-howto, .tk-related, .tk-faq { margin-top: 72px; }
.tk-howto h2, .tk-related h2, .tk-faq h2 { font-size: clamp(1.6rem, 3.4vw, 2.2rem); margin: 0 0 20px; letter-spacing: -0.03em; text-align: center; }
.tk-howto ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.tk-howto li { display: flex; flex-direction: column; gap: 8px; padding: 22px; border-radius: 22px; background: var(--tk-surface); font-size: 1.02rem; line-height: 1.45; }
.tk-step-n { font-size: .78rem; font-weight: 700; color: var(--tk-accent); text-transform: uppercase; letter-spacing: .08em; }
.tk-faq { max-width: 760px; margin-inline: auto; }
.tk-faq details { border-bottom: 1px solid var(--tk-hair); }
.tk-faq summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 2px; cursor: pointer; list-style: none; font-weight: 600; font-size: 1.05rem; }
.tk-faq summary::-webkit-details-marker { display: none; }
.tk-faq summary::after { content: "+"; font-size: 1.5rem; font-weight: 300; color: var(--tk-muted); transition: transform .25s var(--tk-ease); }
.tk-faq details[open] summary::after { transform: rotate(45deg); }
.tk-faq details p { margin: 0 0 18px; color: var(--tk-muted); }
.tk-ad { margin: 22px 0; text-align: center; min-height: 0; overflow: hidden; }

@media (max-width: 600px) {
  .tk-ed-tool span { display: none; }
  .tk-ed-tool { min-width: 42px; padding: 9px; }
  .tk-ed-save { margin-left: 0; width: 100%; }
  .tk-ed-save .tk-btn { width: 100%; }
  .tk-result { flex-wrap: wrap; }
  .tk-result .tk-btn { width: 100%; }
  .tk-fields { padding: 14px; }
  .tk-chapter-item { width: 82px; }
}
@media (prefers-reduced-motion: reduce) {
  .tk-wrap *, .tk-modal *, .tk-modal { transition: none !important; animation: none !important; }
}

/* ------------------------------------------------------------------ v3 additions */

.tk-about { max-width: 760px; margin: 72px auto 0; text-align: center; }
.tk-about h2 { font-size: clamp(1.6rem, 3.4vw, 2.2rem); margin: 0 0 14px; letter-spacing: -0.03em; }
.tk-about p { margin: 0; color: var(--tk-muted); font-size: 1.08rem; line-height: 1.6; }

.tk-next { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--tk-hair); }
.tk-next-label { font-size: .85rem; font-weight: 700; color: var(--tk-muted); margin-right: 4px; }
.tk-next .tk-chip { font-size: .85rem; padding: 7px 13px; }
.tk-next .tk-chip svg { color: var(--cat); }

.tk-file.is-draggable { cursor: grab; }
.tk-file.is-drag { opacity: .45; }
.tk-file.is-target { box-shadow: inset 0 2px 0 var(--cat); }
.tk-grip { color: var(--tk-muted); font-size: .8rem; letter-spacing: -2px; user-select: none; }

.tk-hp { position: absolute !important; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.tk-contact { max-width: 720px; margin: 20px 0; }

.tk-ad-sticky { display: none; }
@media (max-width: 760px) {
  .tk-ad-sticky { position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; display: flex; justify-content: center; min-height: 50px; padding: 4px 0 calc(4px + env(safe-area-inset-bottom, 0px)); background: var(--tk-surface); box-shadow: 0 -6px 20px rgba(0, 0, 0, .12); }
  .tk-ad-close { position: absolute; top: -26px; right: 8px; width: 26px; height: 26px; border: 0; border-radius: 50% 50% 0 0; background: var(--tk-surface); color: var(--tk-muted); font-size: 18px; line-height: 1; cursor: pointer; box-shadow: 0 -4px 10px rgba(0, 0, 0, .08); }
}

.tk-hindi-out { font-size: 1.15rem; line-height: 1.7; font-family: "Noto Sans Devanagari", "Kohinoor Devanagari", "Mangal", system-ui, sans-serif; }
.tk-tips td, .tk-tips th { text-align: left !important; }
.tk-tips code { font-weight: 700; }
