/* =============================================================================
   5IVESAW — shared styles for the in-site TOOLS (image / audio / video / dev).
   Linked by each tool module on mount and removed on cleanup.
   Everything is scoped under .tl and built only from main.css theme tokens.
   ============================================================================= */

.tl { --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  display: flex; flex-direction: column; gap: 16px; }

/* paper grain on cards (very subtle, works in light + dark) */
.tl .card::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: -1;
  background-image: var(--grain); background-size: 160px; opacity: .07; mix-blend-mode: multiply;
}
[data-tone="readme"] .tl .card::after, [data-tone="chainsaw"] .tl .card::after,
[data-tone="ostania"] .tl .card::after, [data-tone="cyber"] .tl .card::after { mix-blend-mode: screen; opacity: .05; }

/* ---- intro strip ------------------------------------------------------- */
.tl-intro { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 18px; }
.tl-intro .lede { font-family: var(--font-serif); font-size: clamp(18px, 2.4vw, 22px); color: var(--muted); line-height: 1.25; }
.tl-intro .lede em { color: var(--ink); font-style: italic; }
.tl-keys { display: flex; flex-wrap: wrap; gap: 6px 12px; font: 500 10.5px var(--font-mono); color: var(--faint); }
.tl-keys span { display: inline-flex; align-items: center; gap: 4px; }

/* sticker: tilted mono label like tape on paper */
.tl-sticker {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 3px;
  font: 700 10px var(--font-mono); letter-spacing: .16em; text-transform: uppercase;
  color: var(--on-accent); background: var(--accent); border-radius: 4px;
  transform: rotate(-2.2deg); box-shadow: 0 3px 0 -1px color-mix(in srgb, var(--accent) 40%, #000), 0 6px 14px -6px rgba(0,0,0,.4);
  transition: transform .5s var(--ease-spring);
}
.tl-sticker:hover { transform: rotate(1.5deg) scale(1.04); }
.tl-sticker.alt { background: var(--ink); color: var(--bg); transform: rotate(1.8deg); box-shadow: 0 6px 14px -6px rgba(0,0,0,.4); }
.tl-sticker svg { width: 12px; height: 12px; }

/* hand-drawn scribble underline under a word */
.tl-scrib { position: relative; display: inline-block; white-space: nowrap; }
.tl-scrib svg { position: absolute; left: -3%; bottom: -.32em; width: 106%; height: .5em; overflow: visible; color: var(--accent); pointer-events: none; }
.tl-scrib path { stroke-dasharray: 260; stroke-dashoffset: 260; animation: tlDraw 1.1s .35s var(--ease) forwards; }

/* section title inside panels */
.tl h3.tl-h { display: flex; align-items: center; gap: 8px; font: 600 10.5px var(--font-mono); text-transform: uppercase; letter-spacing: .16em; color: var(--accent); }
.tl h3.tl-h::after { content: ""; flex: 1; height: 1px; background: repeating-linear-gradient(90deg, var(--line) 0 4px, transparent 4px 8px); }

.tl .lbl { font: 500 10.5px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.tl .val { font: 500 11px var(--font-mono); color: var(--ink); font-variant-numeric: tabular-nums; }
.tl .field-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tl .tl-range { display: flex; flex-direction: column; gap: 2px; }
.tl .tl-range .field-row .val { min-width: 3.5em; text-align: right; }
.tl .tl-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tl .tl-grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tl .seg.full { display: flex; } .tl .seg.full > button { flex: 1; padding: 0 6px; }
.tl .switch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font: 500 11.5px var(--font-mono); color: var(--muted); cursor: pointer; }
.tl .input.sq, .tl .select.sq { border-radius: var(--r-sm); }
.tl .num { font-variant-numeric: tabular-nums; }

/* press feedback + springy primary */
.tl .btn { transition: transform .35s var(--ease-spring), background-color .2s ease, border-color .2s ease, color .2s ease, opacity .2s, box-shadow .25s ease; }
.tl .btn:active { transform: scale(.93); transition-duration: .08s; }
.tl .btn.primary { box-shadow: 0 6px 16px -8px var(--accent), inset 0 1px 0 rgba(255,255,255,.18); }
.tl .btn.primary:hover { transform: translateY(-1px); }
.tl .btn[aria-pressed="true"] { border-color: var(--line-strong); color: var(--accent); background: var(--spot); }
.tl .btn.wide { width: 100%; }

/* dropzone polish */
.tl .dropzone { min-height: 230px; overflow: hidden; isolation: isolate; }
.tl .dropzone::before {
  content: ""; position: absolute; inset: 10px; border-radius: calc(var(--r-lg) - 8px); z-index: -1;
  background-image: var(--grain); background-size: 160px; opacity: .08;
}
.tl .dropzone .big { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 16px; background: var(--elevated); border: 1px solid var(--line); box-shadow: var(--shadow), inset 0 1px 0 var(--hi); transform: rotate(-4deg); }
.tl .dropzone .big svg { width: 26px; height: 26px; }
.tl .dropzone:hover .big, .tl .dropzone.drag .big { transform: rotate(3deg) translateY(-5px) scale(1.08); }
.tl .dropzone h4 { font: 400 clamp(22px, 3vw, 28px) var(--font-serif); color: var(--ink); letter-spacing: -.01em; }
.tl .dropzone .hint { font-size: 11px; color: var(--faint); }
.tl .dropzone .tl-sticker { position: absolute; top: 16px; right: 16px; }

/* privacy foot note */
.tl-local { display: inline-flex; align-items: center; gap: 7px; font: 500 10.5px var(--font-mono); color: var(--faint); letter-spacing: .04em; }
.tl-local::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #30a46c; box-shadow: 0 0 0 3px color-mix(in srgb, #30a46c 22%, transparent); }

/* success check draw-on */
.tl-done { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #30a46c; color: #fff; animation: tlPop .5s var(--ease-spring) both; }
.tl-done svg { width: 14px; height: 14px; }
.tl-done path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: tlDraw .45s .15s var(--ease) forwards; }

/* progress with label */
.tl-prog { display: flex; flex-direction: column; gap: 6px; }
.tl-prog .row { justify-content: space-between; font: 500 11px var(--font-mono); color: var(--muted); }
.tl-prog .progress { height: 8px; }
.tl-prog .progress > i { position: relative; overflow: hidden; transition: width .3s var(--ease); }
.tl-prog .progress > i::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(-45deg, rgba(255,255,255,.18) 0 6px, transparent 6px 12px); background-size: 17px 17px; animation: tlStripe .6s linear infinite; }

/* copy button + output boxes */
.tl .out { position: relative; }
.tl .out .copy { position: absolute; top: 6px; right: 6px; }
.tl .out .textarea, .tl .out .input { padding-right: 46px; }
.tl .copy.ok { color: #30a46c; border-color: #30a46c; }

/* tab content transitions */
.tl .tl-pane { animation: tlPane .4s var(--ease) both; }

/* stage with soft vignette */
.tl .stage { box-shadow: inset 0 2px 10px rgba(0,0,0,.18); }

/* empty-state illustration text */
.tl .empty { display: grid; place-items: center; gap: 6px; padding: 28px; text-align: center; color: var(--faint); font: 500 12px var(--font-mono); }

@keyframes tlDraw { to { stroke-dashoffset: 0; } }
@keyframes tlPop { from { transform: scale(.3); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes tlStripe { to { background-position: 17px 0; } }
@keyframes tlPane { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes tlWiggle { 0%, 100% { transform: rotate(-2.2deg); } 50% { transform: rotate(2deg); } }

@media (max-width: 520px) {
  .tl .tl-grid2 { grid-template-columns: 1fr; }
  .tl-keys { display: none; }
}
