/* Tools page: a precise, quiet instrument panel on glass.
   Every selector starts with .tl; logical properties throughout for Arabic. */

.tl { --tl-gap: clamp(10px, 1.2vw, 14px); --tl-pad: clamp(18px, 2.6vw, 34px); --tl-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; }
.tl .sheet { background: rgba(15, 17, 24, .72); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.tl-jump { display: flex; flex-wrap: wrap; gap: 8px; }
.tl-jump .chip { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; }

/* ------------------------------------------------------------ shared bits */
.tl-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tl-chips .chip { min-height: 44px; }
.tl-hint { font-size: .875rem; color: var(--ink-2); line-height: 1.55; max-width: 40em; }
.tl-msg { font-size: .875rem; color: var(--ink); line-height: 1.5; }
.tl-msg:empty { display: none; }
.tl-small { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; font-size: .8125rem; color: var(--ink-2); line-height: 1.5; }
.tl-small li { padding-inline-start: 16px; position: relative; }
.tl-small li::before { content: ""; position: absolute; inset-inline-start: 2px; top: .62em; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); opacity: .7; }
.tl .btn svg { width: 14px; height: 14px; }
.tl .toggle { font-size: .875rem; line-height: 1.4; }
.tl .field small { font-weight: 400; color: var(--ink-2); font-size: .8125rem; line-height: 1.45; }

.tl-card { margin-top: clamp(14px, 2vw, 22px); padding: var(--tl-pad); display: grid; gap: clamp(20px, 3vw, 32px); scroll-margin-top: 90px; }
.tl-card-head { display: grid; gap: 10px; }
.tl-card-head p { color: var(--ink-2); max-width: 44em; }
.tl-card-title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.tl-card-title h3 { font-size: 1.25rem; font-weight: 400; letter-spacing: -.015em; }
:lang(ar) .tl-card-title h3 { letter-spacing: 0; }
.tl-tier { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: .6875rem; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; border: 1px solid var(--line); color: var(--ink-2); }
:lang(ar) .tl-tier { letter-spacing: 0; text-transform: none; font-size: .8125rem; }
.tl-tier svg { width: 10px; height: 10px; }
.tl-tier-free { border-color: rgba(63, 207, 196, .45); color: var(--turq-ink); }
.tl-tier-pro, .tl-tier-student { border-color: rgba(131, 148, 255, .45); color: var(--accent-ink); }

/* Lock card: what the plan adds, and one way to get it */
.tl-lock { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 24px; padding: 16px 18px; border-radius: 18px; background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(131, 148, 255, .28); }
.tl-lock[hidden] { display: none; }
.tl-lock > div { display: grid; gap: 4px; flex: 1 1 260px; }
.tl-lock p { font-size: .875rem; color: var(--ink-2); line-height: 1.5; }
.tl-lock .tl-lock-h { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 500; font-size: .9375rem; }
.tl-lock-h svg { width: 14px; height: 14px; color: var(--accent); flex: none; }

/* ------------------------------------------------------------ picker */
.tl-pick { padding: var(--tl-pad); display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.4fr); gap: clamp(22px, 3.4vw, 48px); }
.tl-pick-controls { display: grid; gap: 18px; align-content: start; }
.tl-now { display: grid; gap: 18px; align-content: start; }
.tl-now-head { display: grid; gap: 6px; }
.tl-name { font-size: clamp(1.9rem, 1.2rem + 2.2vw, 3rem); font-weight: 300; letter-spacing: -.035em; line-height: 1.05; }
:lang(ar) .tl-name { letter-spacing: 0; line-height: 1.3; font-weight: 400; }
.tl-tonic-line { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tl-combo { font-size: .875rem; color: var(--accent-ink); }
.tl-combo[hidden] { display: none; }
.tl-degs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.tl-deg { width: 100%; min-height: 64px; display: grid; gap: 2px; align-content: center; justify-items: center; padding: 8px 6px; border-radius: 14px; border: 1px solid var(--line); background: rgba(242, 243, 247, .03); color: var(--ink); cursor: pointer; font: inherit; transition: background-color .3s var(--ease), border-color .3s var(--ease), color .3s var(--ease); }
.tl-deg b { font-size: 1.0625rem; font-weight: 500; }
.tl-deg span { font-size: .75rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tl-deg small { font-size: .6875rem; color: var(--ink-2); opacity: .75; font-variant-numeric: tabular-nums; }
.tl-deg:hover { border-color: var(--ink-2); }
.tl-deg:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tl-deg.is-heard { border-color: var(--turq); background: rgba(63, 207, 196, .12); }
.tl-deg.is-sounding { animation: tl-flash .9s var(--ease); }
@keyframes tl-flash { 0% { background: var(--accent); color: #05060A; } 100% { background: rgba(242, 243, 247, .03); } }
.tl-now-do { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; }
.tl-now .tune { max-width: 520px; }

/* ------------------------------------------------------------ tuner */
.tl-tuner { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: clamp(22px, 3vw, 44px); align-items: start; }
.tl-meter { position: relative; display: grid; justify-items: center; gap: 10px; padding: clamp(16px, 2.4vw, 28px); border-radius: 22px; background: rgba(5, 6, 10, .55); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .05); }
.tl-gauge { width: min(100%, var(--tl-dial-w, 360px)); height: auto; overflow: visible; transition: width .4s var(--ease); }
.tl-g-arc { fill: none; stroke: var(--line); stroke-width: 2; }
.tl-g-zone { fill: none; stroke: var(--turq); stroke-width: 6; stroke-linecap: round; opacity: .35; transition: opacity .4s var(--ease); }
.tl-g-tick { stroke: var(--ink-2); stroke-width: 1.2; opacity: .55; }
.tl-g-tick.is-major { stroke-width: 2; opacity: .9; }
.tl-g-num { font: 500 11px var(--sans); fill: var(--ink-2); font-variant-numeric: tabular-nums; }
.tl-g-needle { transform-box: view-box; transform-origin: 160px 160px; transition: opacity .5s var(--ease); }
.tl-g-needle line { stroke: var(--tl-pitch, var(--ink)); stroke-width: 3; stroke-linecap: round; }
.tl-g-needle circle, .tl-g-dot, .tl-g-marker rect { fill: var(--tl-pitch, var(--ink)); }
.tl-meter[data-state="idle"] .tl-g-needle, .tl-meter[data-state="listening"] .tl-g-needle { opacity: .25; }
.tl-meter[data-state="holding"] .tl-g-needle { opacity: 0; }
.tl-meter[data-state="intune"] .tl-g-zone { opacity: 1; }
.tl-meter[data-state="intune"] .tl-g-needle line, .tl-meter[data-state="intune"] .tl-g-needle circle { stroke: var(--turq); fill: var(--turq); }
.tl-read { display: grid; justify-items: center; gap: 2px; margin-top: -6px; min-height: 88px; text-align: center; }
.tl-note { font-size: clamp(2.6rem, 2rem + 2.4vw, 3.6rem); font-weight: 300; line-height: 1.05; letter-spacing: -.03em; }
:lang(ar) .tl-note { letter-spacing: 0; font-size: clamp(2rem, 1.6rem + 1.6vw, 2.8rem); line-height: 1.3; }
.tl-off { font-size: .9375rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tl-meter[data-state="intune"] .tl-off { color: var(--turq-ink); }
.tl-hold { display: grid; justify-items: center; gap: 8px; font-size: .8125rem; color: var(--ink-2); }
.tl-hold[hidden] { display: none; }
.tl-hold-bar { width: 140px; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.tl-hold-bar span { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; }
[dir="rtl"] .tl-hold-bar span { transform-origin: right; }
.tl-facts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 28px; margin: 4px 0 0; font-size: .8125rem; }
.tl-facts div { display: flex; gap: 8px; align-items: baseline; }
.tl-facts dt { color: var(--ink-2); }
.tl-facts dd { margin: 0; font-weight: 500; font-variant-numeric: tabular-nums; min-width: 4ch; }
.tl-tuner-side { display: grid; gap: 18px; align-content: start; }
.tl-mic { justify-self: start; min-height: 52px; padding-inline: 24px; }
.tl-mic[aria-pressed="true"] { background: var(--accent); color: var(--bg); }

/* ------------------------------------------------------------ rhythm */
.tl-rhythm { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: clamp(22px, 3vw, 44px); align-items: start; }
.tl-ring-wrap { position: relative; width: min(100%, 400px); justify-self: center; aspect-ratio: 1; }
.tl-ring, .tl-ring svg { width: 100%; height: 100%; }
.tl-r-track { fill: none; stroke: var(--line); stroke-width: 1.5; }
.tl-r-beat { stroke: var(--ink-2); stroke-width: 2; stroke-linecap: round; opacity: .6; }
.tl-r-step { transition: fill .18s ease-out, transform .18s ease-out; transform-box: fill-box; transform-origin: center; }
.tl-r-D { fill: var(--ink); }
.tl-r-T { fill: var(--accent); }
.tl-r-K { fill: none; stroke: var(--accent); stroke-width: 2; }
.tl-r-K.is-filled { stroke-dasharray: 2 3; opacity: .8; }
.tl-r-rest { fill: var(--line); }
.tl-r-step.is-now { transform: scale(1.35); fill: var(--turq); stroke: var(--turq); transition: none; }
.tl-r-rest.is-now { fill: var(--ink-2); transform: scale(1.6); }
.tl-ring-mid { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 4px; pointer-events: none; }
.tl-ring-mid b { font-size: clamp(1.3rem, 1rem + 1vw, 1.8rem); font-weight: 400; letter-spacing: -.02em; }
.tl-ring-mid span { color: var(--ink-2); font-variant-numeric: tabular-nums; font-size: .9375rem; }
.tl-rhythm-side { display: grid; gap: 18px; align-content: start; }
.tl-cells { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(var(--n, 8), minmax(0, 1fr)); gap: 3px; }
.tl-cell { min-height: 38px; display: grid; place-items: center; border-radius: 8px; background: rgba(242, 243, 247, .04); font-size: .6875rem; color: var(--ink-2); overflow: hidden; white-space: nowrap; }
.tl-cell.is-beat { box-shadow: inset 0 2px 0 rgba(242, 243, 247, .3); }
.tl-c-D { color: var(--ink); background: rgba(242, 243, 247, .12); font-weight: 500; }
.tl-c-T { color: var(--accent-ink); background: rgba(131, 148, 255, .14); }
.tl-c-K { color: var(--accent-ink); }
.tl-c-K.is-filled { opacity: .6; }
.tl-cell.is-now { background: var(--turq); color: #05060A; }
.tl-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .8125rem; color: var(--ink-2); }
.tl-legend span { display: inline-flex; align-items: center; gap: 7px; }
.tl-dot { display: inline-block; border-radius: 50%; }
.tl-dot-D { width: 12px; height: 12px; background: var(--ink); }
.tl-dot-T { width: 9px; height: 9px; background: var(--accent); }
.tl-dot-K { width: 7px; height: 7px; box-shadow: inset 0 0 0 1.5px var(--accent); }
.tl-check { font-size: .8125rem; color: var(--ink-2); border-inline-start: 2px solid var(--accent); padding-inline-start: 10px; }
.tl-check[hidden] { display: none; }
.tl-slider { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 0 16px; max-width: 460px; }
.tl-slider label { font-size: .875rem; font-weight: 500; }
.tl-slider output { font-size: .8125rem; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tl-slider output b { color: var(--ink); font-weight: 500; font-size: .9375rem; }
.tl-slider input { grid-column: 1 / -1; }
.tl-slider input[type=range]::-webkit-slider-runnable-track { background: linear-gradient(to right, var(--accent) var(--p, 50%), rgba(242, 243, 247, .2) var(--p, 50%)); }
.tl-slider input[type=range]::-moz-range-track { background: rgba(242, 243, 247, .2); }
.tl-slider input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
.tl [data-tl-rplay][aria-pressed="true"] { background: var(--accent); color: #05060A; }

/* ------------------------------------------------------------ tuning files */
.tl-files { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(18px, 2.6vw, 36px); align-items: start; }
.tl-files-list { display: grid; gap: 20px; }
.tl-field { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 10px; }
.tl-field legend { padding: 0; margin-bottom: 10px; }
.tl-formats { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.tl-format { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.tl-format-text { display: grid; gap: 3px; flex: 1 1 220px; min-width: 0; }
.tl-format-text p:first-child { font-size: .9375rem; }
.tl-format-text p:first-child b { font-family: var(--tl-mono); font-weight: 500; color: var(--accent-ink); margin-inline-end: 6px; }
.tl-format-text p + p { font-size: .8125rem; color: var(--ink-2); line-height: 1.5; }
.tl-format-do { display: flex; gap: 6px; align-items: center; }
.tl-format-do .chip { min-height: 44px; }
.tl-format-do .chip:disabled { opacity: .4; cursor: not-allowed; }
.tl-dl[hidden] { display: none; }
.tl-pre-wrap { display: grid; gap: 10px; min-width: 0; position: sticky; top: 96px; }
.tl-pre { margin: 0; max-height: 460px; overflow: auto; padding: 16px 18px; border-radius: 16px; background: rgba(5, 6, 10, .7); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06); font: 400 .8125rem/1.6 var(--tl-mono); color: #C9CDD8; white-space: pre; tab-size: 4; text-align: left; }
.tl-pre.is-note { white-space: pre-wrap; font-family: var(--sans); }
.tl-pre:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tl-files[data-locked="true"] .tl-pre { -webkit-mask-image: linear-gradient(to bottom, #000 70%, transparent); mask-image: linear-gradient(to bottom, #000 70%, transparent); }

/* ------------------------------------------------------------ MIDI */
.tl-midi-go { gap: 12px 18px; }
.tl-midi-go .tl-msg { color: var(--ink-2); }
.tl-midi { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--tl-gap); }
.tl-panel { display: grid; gap: 14px; align-content: start; padding: clamp(16px, 2vw, 24px); border-radius: 20px; background: rgba(242, 243, 247, .035); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .05); }
.tl-panel-body { display: grid; gap: 16px; }
.tl-panel-body[hidden] { display: none; }
.tl-panel .field select:disabled { opacity: .5; cursor: not-allowed; }
.tl-last { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; font-size: .875rem; color: var(--ink-2); }
.tl-last b { color: var(--ink); font-weight: 500; font-size: 1.25rem; }
.tl-last small { font-size: .8125rem; color: var(--ink-2); font-weight: 400; }

/* ------------------------------------------------------------ narrow screens */
@media (max-width: 960px) {
  .tl-pick, .tl-tuner, .tl-rhythm, .tl-files { grid-template-columns: minmax(0, 1fr); }
  .tl-pre-wrap { position: static; }
}
@media (max-width: 720px) {
  .tl-midi { grid-template-columns: minmax(0, 1fr); }
  .tl-cell { font-size: 0; min-height: 30px; }
  .tl-c-D::after, .tl-c-T::after, .tl-c-K::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
  .tl-c-K::after { width: 5px; height: 5px; }
  .tl-read { min-height: 76px; }
}
@media (max-width: 420px) {
  .tl-degs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tl-deg small { display: none; }
  .tl-format-do { width: 100%; }
  .tl-format-do .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .tl-deg.is-sounding { animation: none; }
  .tl-r-step, .tl-g-needle, .tl-g-zone { transition: none; }
  .tl-r-step.is-now { transform: none; }
}
.tl .voices .chip { min-height: 44px; }

/* ------------------------------------------------------------ the dial, as the display preferences set it */
/* sizes: the dial's width comes from --tl-dial-w (tools-dial.js SIZES); the note name follows */
.tl-meter[data-size="s"] .tl-note { font-size: clamp(2rem, 1.7rem + 1.2vw, 2.4rem); }
.tl-meter[data-size="l"] .tl-note { font-size: clamp(3rem, 2.2rem + 3vw, 4.6rem); }
/* bar */
.tl-g-track { fill: var(--line); }
.tl-meter[data-dial="bar"] .tl-g-zone { fill: var(--turq); stroke: none; opacity: .3; }
.tl-g-centre { stroke: var(--ink-2); stroke-width: 1.5; opacity: .7; }
.tl-meter[data-dial="bar"] .tl-read { margin-top: 6px; }
/* arc: fills from the centre to your pitch */
.tl-g-fill { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; opacity: .85; }
/* in tune: the target colour, with a glow that eye comfort and calm scenes soften */
.tl-meter[data-state="intune"] .tl-g-needle line { stroke: var(--turq); }
.tl-meter[data-state="intune"] .tl-g-needle circle, .tl-meter[data-state="intune"] .tl-g-dot, .tl-meter[data-state="intune"] .tl-g-marker rect { fill: var(--turq); }
.tl-meter[data-state="intune"] .tl-g-fill { stroke: var(--turq); }
.tl-meter[data-state="intune"] .tl-g-needle { filter: drop-shadow(0 0 calc(9px * var(--tl-glow, 1)) var(--turq)); }
/* numbers off: no cent values anywhere on the dial */
.tl-meter[data-numbers="false"] .tl-g-num, .tl-meter[data-numbers="false"] .tl-piano-off { display: none; }

/* scenes other than night recolour the tuner panel with the scene's palette (prefs.palette) */
.tl-card[data-scene]:not([data-scene="night"]) {
  --bg: var(--tl-s-bg); --card: var(--tl-s-surface); --ink: var(--tl-s-ink);
  --bg-2: color-mix(in srgb, var(--tl-s-ink) 10%, var(--tl-s-surface));
  --ink-2: color-mix(in srgb, var(--tl-s-ink) 68%, var(--tl-s-surface));
  --line: color-mix(in srgb, var(--tl-s-ink) 22%, var(--tl-s-surface));
  --accent: var(--tl-s-ring); --accent-ink: var(--tl-s-note); --accent-soft: color-mix(in srgb, var(--tl-s-ring) 18%, transparent);
  --turq: var(--tl-s-target); --turq-ink: var(--tl-s-target); --tl-pitch: var(--tl-s-pitch);
  background: var(--tl-s-surface); color: var(--ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tl-s-ink) 10%, transparent);
  transition: background-color .5s var(--ease), color .5s var(--ease);
}
.tl-card[data-scene]:not([data-scene="night"]) .tl-meter { background: var(--tl-s-bg); }
.tl-card[data-scene]:not([data-scene="night"]) .h-sub { text-shadow: none; }

/* eye comfort: softer glow, no flashes, gentler motion */
.tl[data-comfort="true"] .tl-r-step.is-now { transform: none; }
.tl[data-comfort="true"] .tl-cell.is-now { background: color-mix(in srgb, var(--turq) 45%, transparent); color: var(--ink); }
.tl[data-comfort="true"] .tl-g-needle, .tl[data-comfort="true"] .tl-g-zone { transition-duration: .9s; }

/* the Display panel beside the tuner (prefs.mountSettings) */
.tl-display { border-top: 1px solid var(--line); padding-top: 6px; }
.tl-display summary { display: grid; gap: 2px; min-height: 44px; padding-block: 8px; padding-inline-end: 28px; cursor: pointer; list-style: none; position: relative; }
.tl-display summary::-webkit-details-marker { display: none; }
.tl-display summary span { font-weight: 500; font-size: .9375rem; }
.tl-display summary small { font-size: .8125rem; color: var(--ink-2); }
.tl-display summary::after { content: ""; position: absolute; inset-inline-end: 6px; top: 18px; width: 8px; height: 8px; border-inline-end: 1.6px solid var(--ink-2); border-bottom: 1.6px solid var(--ink-2); transform: rotate(45deg); transition: transform .3s var(--ease); }
.tl-display[open] summary::after { transform: rotate(-135deg); top: 22px; }
.tl-display summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.tl-display-body { padding: 10px 0 4px; }
