/* Toolhox.com — shared tool kit (canonical tool UI).
   Source of truth for freeform tools. Per-tool JS must reuse tk-* classes
   instead of shipping its own button/input gradients. Theme-aware via
   var(--surface-*, --border-*, --text-*) from theme-head.php. */
.tk-wrap{max-width:100%}
.tk-toolbar{display:flex;flex-wrap:wrap;gap:10px;margin-bottom:12px}
.tk-grid{display:grid;grid-template-columns:1fr;gap:12px;margin-bottom:12px}
.tk-label{font-size:11px;font-weight:700;color:var(--text-secondary,#64748b);margin:8px 0 4px}
.tk-select{padding:7px 9px;border-radius:8px;border:1px solid var(--border-default,#d3d9e3);background:var(--surface-2,#17191c);color:var(--text-primary,#f7f7f8);font-size:12px;outline:none;cursor:pointer;font-family:inherit;transition:border-color 150ms cubic-bezier(.2,.8,.2,1),box-shadow 150ms cubic-bezier(.2,.8,.2,1)}
.tk-input{padding:7px 9px;min-height:44px;border-radius:8px;border:1px solid var(--border-default,#d3d9e3);background:var(--surface-2,#17191c);color:var(--text-primary,#f7f7f8);font-size:12px;outline:none;font-family:inherit;transition:border-color 150ms cubic-bezier(.2,.8,.2,1),box-shadow 150ms cubic-bezier(.2,.8,.2,1)}
.tk-select:focus-visible,.tk-input:focus-visible,.tk-env:focus-visible{border-color:var(--search-border-focus,rgba(201,245,26,0.55));box-shadow:0 0 0 3px var(--primary-soft,rgba(201,245,26,0.08));outline:2px solid transparent;outline-offset:2px}
/* Click-silent: mouse/touch :focus shows no outer line app-wide; keyboard :focus-visible keeps the ring. */
*:focus:not(:focus-visible){outline:none !important;box-shadow:none !important}
.tk-select:focus:not(:focus-visible),.tk-input:focus:not(:focus-visible),.tk-env:focus:not(:focus-visible){border-color:var(--border-default,#d3d9e3)}
.tk-select:focus,.tk-input:focus,.tk-env:focus{outline:none;box-shadow:none}
.tk-check{display:inline-flex;align-items:center;gap:6px;font-size:12px;font-weight:600;color:var(--text-secondary,#475569);cursor:pointer;user-select:none}
.tk-code{width:100%;background:#060707;color:#e2e8f0;border:1px solid var(--border-subtle,rgba(255,255,255,0.06));outline:none;resize:vertical;font-family:ui-monospace,Menlo,Consolas,monospace;font-size:12.5px;line-height:1.65;padding:13px 15px;min-height:300px;tab-size:2;box-sizing:border-box;border-radius:12px}
[data-theme="light"] .tk-code{background:#0f172a;color:#e2e8f0;border-color:rgba(15,23,42,0.12)}
.tk-env{width:100%;min-height:64px;padding:9px 11px;border-radius:10px;border:1px solid var(--border-default,#d3d9e3);background:var(--surface-2,#f8fafc);color:var(--text-primary,#0f172a);font-family:ui-monospace,Menlo,Consolas,monospace;font-size:12px;line-height:1.6;box-sizing:border-box;resize:vertical}
.tk-actions{display:flex;flex-wrap:wrap;gap:10px;align-items:center;margin-top:4px}
.tk-btn{display:inline-flex;align-items:center;justify-content:center;gap:7px;min-height:44px;padding:10px 18px;font-size:12.5px;font-weight:600;letter-spacing:.01em;color:var(--text-secondary,#475569);background:var(--surface-2,#f1f5f9);border:1px solid var(--border-default,#e2e8f0);border-radius:12px;cursor:pointer;transition:background .25s,border-color .25s,color .25s,transform .16s ease,box-shadow .16s ease;font-family:inherit}
.tk-btn:hover{background:var(--surface-4,#e8ecf1);border-color:var(--border-strong,rgba(15,23,42,.18));color:var(--text-primary,#0f172a);transform:translateY(-1px);box-shadow:0 6px 16px -10px rgba(15,23,42,.35)}
.tk-btn:active{transform:translateY(0) scale(.98);box-shadow:none}
.tk-btn-primary{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:44px;padding:12px 24px;border-radius:var(--hf-radius-md);border:none;
  background:var(--hf-primary);color:var(--hf-primary-contrast);font-size:13px;font-weight:600;letter-spacing:.01em;cursor:pointer;font-family:inherit;
  transition:transform var(--motion-base) cubic-bezier(.2,.8,.2,1),box-shadow var(--motion-base) ease,background-color var(--motion-base) ease;}
.tk-btn-primary:hover{background:var(--hf-primary-hover);transform:translateY(-1px);
  box-shadow:0 0 12px rgba(201,245,26,0.20),0 0 24px rgba(201,245,26,0.12);}
.tk-btn-primary:active{transform:scale(0.98);}
.tk-btn-primary:focus-visible,.tk-btn:focus-visible,.tk-input:focus-visible{outline:2px solid var(--hf-primary);outline-offset:2px;}
.tk-tabs{display:inline-flex;gap:4px;margin-bottom:12px;padding:4px;border-radius:14px;background:var(--surface-2,#eef2f7);border:1px solid var(--border-subtle,rgba(15,23,42,.06))}
.tk-tab{padding:8px 16px;border-radius:10px;border:0;background:transparent;font-size:12px;font-weight:700;cursor:pointer;color:var(--text-secondary,#64748b);transition:color .18s ease,background .18s ease,box-shadow .18s ease;font-family:inherit}
.tk-tab:hover{color:var(--text-primary,#0f172a);background:rgba(148,163,184,.18)}
.tk-tab-on{background:var(--primary-soft,rgba(201,245,26,0.12));color:var(--primary,#c9f51a);box-shadow:none}
[data-theme="light"] .tk-tab-on{color:#6f8e00}
.tk-tab:focus-visible{outline:2px solid var(--primary,#c9f51a);outline-offset:2px}
.tk-stats{font-size:11.5px;color:var(--text-secondary,#475569);margin-top:10px}
.tk-err{display:none;margin-top:10px;padding:10px 12px;border-radius:10px;border:1px solid rgba(244,63,94,.35);background:rgba(244,63,94,.08);font-size:12.5px;color:var(--text-primary,#0f172a)}
@media (max-width:640px){.tk-toolbar{gap:8px}.tk-btn,.tk-btn-primary{min-height:44px}}
@media (prefers-reduced-motion:reduce){.tk-btn,.tk-btn-primary,.tk-tab,.tool-step-dot,.tool-spin,.tool-skeleton-shimmer{transition:none;animation:none}.tk-btn:hover,.tk-btn-primary:hover{transform:none}}

/* ===================== TASK 4: TOOL WORKSPACE =====================
   Canvas-first workspace: output > prompt > primary action > core params
   > secondary > metadata. Desktop 1fr_320px; tablet inspector becomes a
   <dialog class="drawer">; mobile stacks with sticky Generate. */

/* ---- Layout: desktop two-column, collapses below lg ---- */
.workspace{display:grid;grid-template-columns:minmax(0,1fr) 320px;gap:var(--space-8,32px);align-items:start}
@media (max-width:1023px){
  .workspace{grid-template-columns:minmax(0,1fr);gap:var(--space-6,24px)}
  /* Tablet: sidebar inspector lives in the drawer dialog instead */
  .workspace > aside[data-inspector]{display:none}
}
@media (max-width:767px){
  .workspace{gap:var(--space-4,16px)}
  /* Mobile: inspector stacks below the canvas */
  .workspace > aside[data-inspector]{display:block}
}

/* ---- Prompt box: the input card ---- */
.prompt-box{background:var(--surface-1);border:1px solid var(--border-subtle);border-radius:var(--hf-radius-card,18px);padding:var(--space-5,20px)}
@media (max-width:767px){.prompt-box{padding:var(--space-4,16px)}}

/* ---- Field hierarchy: label (+info icon) / control / error ---- */
.field-label{display:flex;align-items:center;gap:6px;font-size:12px;font-weight:600;color:var(--hf-text-primary);margin-bottom:8px;line-height:1.4;flex-wrap:wrap}
/* Tooltip icons nested inside field labels: 24px hit area, visible info glyph, lime focus ring */
.field-label .tooltip-wrap{position:relative;display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;min-width:24px;min-height:24px;margin-left:2px;border-radius:6px;color:var(--hf-text-secondary);cursor:help;vertical-align:middle}
.field-label .tooltip-wrap:hover{color:var(--hf-text-primary)}
.field-label .tooltip-wrap:focus-visible{outline:2px solid var(--hf-primary);outline-offset:1px}
.field-label .tooltip-wrap svg{display:block}
/* Hide legacy always-visible help lines on dynamic calculator/custom/converter/generator fields:
   help now lives in the label (i) icon tooltip only, so it cannot read as a second line under the name. */
label.field-label + p.field-help{display:none !important}
/* Static guidance blocks (advanced <details>, tips) keep their styling */
.tool-advanced-body .field-help{font-size:12px;color:var(--hf-text-tertiary);margin:0 0 8px;line-height:1.5}
.field-error{font-size:12px;font-weight:500;color:var(--hf-pink);margin:8px 0 0;display:flex;align-items:center;gap:6px}
.field-error[hidden]{display:none}
.tk-input[aria-invalid="true"],.tk-select[aria-invalid="true"]{border-color:var(--hf-pink)}

/* ---- Sticky Generate bar (mobile only; static on desktop) ---- */
.tool-generate-bar{margin-top:var(--space-4,16px)}
@media (max-width:1023px){
  .tool-generate-bar{position:sticky;bottom:0;z-index:30;padding:12px 0 calc(12px + env(safe-area-inset-bottom));background:linear-gradient(to bottom,transparent,var(--hf-bg) 32%)}
  .tool-generate-bar .tk-btn-primary{width:100%}
}

/* ---- Advanced params progressively disclosed in <details> ----
   Canonical pattern (§50): settings list rows + plain trigger + hairline
   dividers. No card, no pills. Dedicated templates must reuse these
   classes verbatim. */
details.tool-advanced{background:transparent;border:none;border-top:1px solid var(--border-subtle);border-radius:0;overflow:visible}
details.tool-advanced > summary{display:flex;align-items:center;gap:8px;min-height:48px;padding:8px 4px;font-size:13px;font-weight:600;color:var(--hf-text-primary);cursor:pointer;list-style:none}
details.tool-advanced > summary::-webkit-details-marker{display:none}
details.tool-advanced > summary::marker{content:""}
details.tool-advanced > summary:hover{color:var(--hf-text-primary)}
details.tool-advanced > summary:focus{outline:none}
details.tool-advanced > summary:focus-visible{outline:2px solid var(--hf-primary);outline-offset:2px;border-radius:8px}
details.tool-advanced > summary .tool-adv-icon{display:none}
details.tool-advanced > summary .tool-adv-chevron{display:grid;place-items:center;flex-shrink:0;width:24px;height:24px;margin-left:auto;background:transparent;border:none;color:var(--hf-text-tertiary);transition:transform 200ms cubic-bezier(.2,.8,.2,1),color 200ms ease}
details.tool-advanced[open] > summary .tool-adv-chevron{transform:rotate(180deg);color:var(--hf-text-primary)}
details.tool-advanced .tool-advanced-body{padding:4px 0 12px}
details.tool-advanced[open] .tool-advanced-body{animation:advIn 200ms ease}
@keyframes advIn{from{opacity:0}to{opacity:1}}
details.tool-advanced .tool-adv-grid{display:grid;grid-template-columns:minmax(0,1fr);gap:0}
@media (min-width:1024px){details.tool-advanced .tool-adv-grid.two-col{grid-template-columns:repeat(2,minmax(0,1fr))}}
details.tool-advanced .tool-opt{display:flex;align-items:center;gap:12px;min-height:56px;padding:12px 4px;border-bottom:1px solid var(--border-subtle);cursor:pointer;font-size:12px;color:var(--hf-text-secondary);line-height:1.4}
details.tool-advanced .tool-opt:first-child{border-top:1px solid var(--border-subtle)}
details.tool-advanced .tool-opt:hover{color:var(--hf-text-primary)}
details.tool-advanced .tool-opt input{width:20px;height:20px;margin-left:auto;flex-shrink:0;order:2;accent-color:var(--hf-primary);cursor:pointer}
details.tool-advanced .tool-opt input:focus{outline:none}
details.tool-advanced .tool-opt input:focus-visible{outline:2px solid var(--hf-primary);outline-offset:2px}
details.tool-advanced .tool-opt-text{display:flex;flex-direction:column;gap:2px;order:1;flex:1;min-width:0}
details.tool-advanced .tool-opt-title{font-weight:600;color:var(--hf-text-primary);font-size:13px}
details.tool-advanced .tool-opt-hint{font-weight:400;color:var(--hf-text-tertiary);font-size:12px}
details.tool-advanced .tool-opt-code{font-family:ui-monospace,monospace}
details.tool-advanced .tool-opt-group{margin:12px 0 0;padding:0;border:none;background:transparent}
details.tool-advanced .tool-opt-group legend{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:0.06em;color:var(--hf-text-tertiary);padding:0 4px;margin-bottom:4px}
details.tool-advanced .tool-opt-group-row{display:flex;flex-direction:column;gap:0}
details.tool-advanced .tool-opt-group-row .tool-opt{border-bottom:1px solid var(--border-subtle)}
details.tool-advanced .tool-opt-group-row .tool-opt:first-child{border-top:1px solid var(--border-subtle)}
@media (max-width:639px){details.tool-advanced .tool-adv-grid{grid-template-columns:minmax(0,1fr)}details.tool-advanced .tool-advanced-body{padding:4px 0 12px}details.tool-advanced .tool-opt{min-height:56px;padding:12px 4px}}
@media (prefers-reduced-motion:reduce){details.tool-advanced > summary .tool-adv-chevron{transition:none}details.tool-advanced[open] .tool-advanced-body{animation:none}}

/* ---- Generation progress: Preparing > Generating > Rendering > Finalizing ---- */
.tool-progress{display:flex;flex-direction:column;gap:10px;padding:4px 0}
.tool-step{display:flex;align-items:center;gap:10px;font-size:13px;color:var(--hf-text-tertiary)}
.tool-step-dot{width:20px;height:20px;border-radius:9999px;border:2px solid var(--border-strong);display:inline-grid;place-items:center;flex-shrink:0;transition:border-color var(--motion-base,160ms) ease,background-color var(--motion-base,160ms) ease}
.tool-step.is-active{color:var(--hf-text-primary);font-weight:600}
.tool-step.is-active .tool-step-dot{border-color:var(--hf-primary)}
.tool-step.is-active .tool-spin{width:10px;height:10px;border-radius:9999px;border:2px solid var(--hf-primary);border-top-color:transparent;animation:toolSpin 0.8s linear infinite}
.tool-step.is-done{color:var(--hf-text-secondary)}
.tool-step.is-done .tool-step-dot{border-color:var(--hf-primary);background:var(--hf-primary);color:var(--hf-primary-contrast)}
.tool-step.is-done .tool-step-dot svg{display:block}
.tool-step-dot svg{display:none;width:11px;height:11px}
@keyframes toolSpin{to{transform:rotate(360deg)}}

/* ---- Useful empty state (icon + text + hint) ---- */
.tool-empty{display:flex;flex-direction:column;align-items:center;gap:8px;padding:32px 20px;text-align:center;background:var(--surface-2);border:1px dashed var(--border-default);border-radius:var(--hf-radius-control,10px);color:var(--hf-text-tertiary);font-size:13px;line-height:1.6}
.tool-empty svg{width:28px;height:28px;opacity:0.55}
.tool-empty strong{color:var(--hf-text-primary);font-size:14px}
.tool-empty[hidden]{display:none}

/* ---- Skeleton loading (matches result-card geometry) ---- */
.tool-skeleton{display:grid;gap:12px;padding:4px 0}
.tool-skeleton-card{position:relative;overflow:hidden;background:var(--surface-2);border:1px solid var(--border-subtle);border-radius:var(--hf-radius-card,18px);padding:16px;display:flex;flex-direction:column;gap:10px}
.tool-skeleton-line{height:12px;border-radius:6px;background:var(--surface-4)}
.tool-skeleton-line.short{width:42%}
.tool-skeleton-shimmer{position:absolute;inset:0;background:linear-gradient(100deg,transparent 20%,rgba(255,255,255,0.08) 50%,transparent 80%);animation:toolShimmer 1.4s ease-in-out infinite}
[data-theme="light"] .tool-skeleton-shimmer{background:linear-gradient(100deg,transparent 20%,rgba(20,24,28,0.06) 50%,transparent 80%)}
@keyframes toolShimmer{from{transform:translateX(-100%)}to{transform:translateX(100%)}}

/* ---- Inline error + Retry (never toast-only) ---- */
.tool-error{display:flex;align-items:flex-start;gap:10px;padding:12px 16px;border-radius:var(--hf-radius-control,10px);font-size:13px;line-height:1.5;background:rgba(239,68,68,0.08);border:1px solid rgba(239,68,68,0.25);color:var(--hf-text-primary)}
.tool-error[hidden]{display:none}
.tool-error svg{flex-shrink:0;width:18px;height:18px;color:var(--hf-pink);margin-top:1px}
.tool-error .tool-retry{margin-left:auto;flex-shrink:0;min-height:44px;padding:8px 16px;border-radius:var(--hf-radius-control,10px);font-size:12.5px;font-weight:600;cursor:pointer;background:var(--surface-2);border:1px solid var(--border-default);color:var(--hf-text-primary)}
.tool-error .tool-retry:hover{background:var(--surface-4);border-color:var(--border-strong)}
.tool-error .tool-retry:focus-visible{outline:2px solid var(--hf-primary);outline-offset:2px}

/* ---- Autosave indicator ---- */
.tool-saved{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--hf-text-tertiary);min-height:44px}
.tool-saved svg{width:14px;height:14px}
.tool-saved.is-saved{color:var(--hf-text-secondary)}

/* ---- Tablet inspector drawer ---- */
dialog.drawer{border:1px solid var(--border-default);background:var(--surface-1);color:var(--text-primary);border-radius:var(--hf-radius-xl,24px) 0 0 var(--hf-radius-xl,24px);padding:0;margin:0 0 0 auto;max-height:100dvh;height:100dvh;width:min(360px,92vw)}
dialog.drawer::backdrop{background:var(--hf-overlay);backdrop-filter:blur(4px)}
dialog.drawer .drawer-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:12px 12px 12px 20px;border-bottom:1px solid var(--border-subtle);position:sticky;top:0;background:var(--surface-1);z-index:1}
dialog.drawer .drawer-title{font-size:15px;font-weight:700}
dialog.drawer .drawer-close{min-width:44px;min-height:44px;display:inline-grid;place-items:center;border-radius:10px;border:1px solid var(--border-default);background:var(--surface-2);color:var(--text-primary);cursor:pointer}
dialog.drawer .drawer-close:hover{background:var(--surface-4)}
dialog.drawer .drawer-close:focus-visible{outline:2px solid var(--hf-primary);outline-offset:2px}
dialog.drawer .drawer-body{padding:20px;display:flex;flex-direction:column;gap:20px;overflow-y:auto}
.drawer-trigger{display:none}
@media (min-width:768px) and (max-width:1023px){.drawer-trigger{display:inline-flex}}

/* ---- Workspace form controls: 44px targets, 8px inputs ---- */
[data-workspace] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
[data-workspace] textarea,
[data-workspace] select{min-height:44px}
[data-workspace] input[type="color"]{min-width:44px;min-height:44px}
[data-workspace] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):focus,
[data-workspace] textarea:focus,
[data-workspace] select:focus{outline:none !important;box-shadow:none !important}
[data-workspace] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):focus-visible,
[data-workspace] textarea:focus-visible,
[data-workspace] select:focus-visible{border-color:var(--search-border-focus);box-shadow:0 0 0 3px var(--primary-soft)}

/* ---- Tool header glyph cap (40px max; gradients allowed here only) ---- */
.tool-glyph{width:40px;height:40px;border-radius:14px}

/* ---- Result numbers: Poppins tabular, no rainbow inline colors ---- */
.result-card-number{font-variant-numeric:tabular-nums}

/* ---- Result tones: semantic result colors, token-only (Task 1) ---- */
.tone-ok{color:var(--hf-primary-dark);}
.tone-info{color:var(--hf-cyan);}
.tone-alert{color:var(--hf-pink);}
.req{color:var(--hf-pink);}
[data-theme="dark"] .tone-ok{color:var(--hf-primary-hover);}
