/* components.css – buttons, form controls, segmented controls, tabs, switches, sliders, value chips, toasts, modal, menu. */

/* ---------- buttons ---------- */
.btn, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--ctrl-h);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: var(--radius);
  font-weight: 600; font-size: 12.5px; line-height: 1.2; cursor: pointer; transition: background-color .12s, border-color .12s, color .12s;
}
.btn { padding: 0 14px; white-space: nowrap; }
.btn:hover, .icon-btn:hover { background: var(--surface-3); border-color: var(--text-2); }
.btn:active, .icon-btn:active { transform: translateY(.5px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
/* outlined action used for "Export CSS" in the top bar */
.btn-outline {
  min-height: 40px; padding: 0 18px; background: var(--surface); border-color: var(--text); color: var(--text);
  font-size: 10.5px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase;
}
.btn-outline:hover { background: var(--text); border-color: var(--text); color: var(--bg); }
:root[data-skin="modern"] .btn-outline { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 600; letter-spacing: 0; text-transform: none; min-height: var(--ctrl-h); }
:root[data-skin="modern"] .btn-outline:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
:root[data-theme="dark"] .btn-danger { color: #1b0f0e; }
.btn-danger:hover { filter: brightness(.94); background: var(--danger); border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 12px; }
.btn[disabled], .icon-btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn { width: var(--ctrl-h); padding: 0; flex: none; }
.icon-btn.is-small { width: 28px; min-height: 28px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- inputs ---------- */
.input, .select, .textarea {
  width: 100%; min-height: var(--ctrl-h); padding: 0 10px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius); font-size: 13px;
}
.textarea { padding: 10px 12px; min-height: 84px; resize: vertical; line-height: 1.5; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.input.is-invalid { border-color: var(--danger); background: var(--danger-soft); }
.input.hex { font-family: var(--mono-font); text-transform: lowercase; }
.select { appearance: none; padding-right: 30px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text) 50%), linear-gradient(135deg, var(--text) 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.select.is-compact { width: auto; min-height: 30px; font-size: 12px; padding-right: 26px; }
.input-code { font-family: var(--mono-font); font-size: 12px; }

/* value chip: the number box next to a slider (and other small numeric inputs) */
.input.num {
  width: auto; min-width: 58px; max-width: 92px; min-height: 26px; padding: 0 10px; flex: none; text-align: center; font-family: var(--mono-font); font-size: 11px;
  font-variant-numeric: tabular-nums; border-color: var(--border); border-radius: var(--radius-chip); box-shadow: var(--shadow-chip); -moz-appearance: textfield;
}
.input.num::-webkit-outer-spin-button, .input.num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input.num:hover { border-color: var(--border-strong); }

.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field + .field { margin-top: 16px; }
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 26px; }
.field-label { font-size: var(--field-label-size); font-weight: var(--label-weight); letter-spacing: var(--field-label-ls); text-transform: var(--field-label-case); color: var(--text); }
.field-body { display: flex; align-items: center; gap: 10px; }
.field-help { font-size: 12px; color: var(--text-3); }
.field.is-disabled .field-label, .field.is-disabled .field-help { opacity: .55; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row > .field + .field { margin-top: 0; }
.field-color .field-body { gap: 8px; }
.color-swatch { width: var(--ctrl-h); height: var(--ctrl-h); padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); cursor: pointer; flex: none; }
.color-swatch::-webkit-color-swatch-wrapper { padding: 0; }
.color-swatch::-webkit-color-swatch { border: 0; border-radius: calc(var(--radius) - 1px); }
.color-swatch::-moz-color-swatch { border: 0; border-radius: calc(var(--radius) - 1px); }

/* ---------- range slider ---------- */
.range { -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; height: 22px; background: transparent; margin: 0; cursor: pointer; }
.range::-webkit-slider-runnable-track { height: 2px; border-radius: 2px; background: var(--border-strong); }
.range::-moz-range-track { height: 2px; border-radius: 2px; background: var(--border-strong); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -7px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--accent); }
.range::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--accent); }
.range:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- segmented control ---------- */
.seg { display: inline-flex; padding: 0; gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); max-width: 100%; overflow: hidden; }
.seg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: calc(var(--ctrl-h) - 2px); padding: 0 12px; border: 0; background: transparent;
  color: var(--text-2); font-size: 12px; font-weight: 600; border-radius: 0; white-space: nowrap; flex: 1 1 auto;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--hairline); }
.seg-btn:hover:not([disabled]) { color: var(--text); background: var(--surface-3); }
.seg-btn.is-on, .seg-btn.is-on:hover:not([disabled]) { background: var(--accent); color: var(--accent-ink); }
:root[data-skin="modern"] .seg { padding: 2px; gap: 2px; background: var(--surface-3); overflow: visible; }
:root[data-skin="modern"] .seg-btn { border-radius: calc(var(--radius) - 2px); }
:root[data-skin="modern"] .seg-btn + .seg-btn { border-left: 0; }
.seg-btn[disabled] { opacity: .45; cursor: not-allowed; }
.seg.is-block { display: flex; width: 100%; }
.seg.is-small .seg-btn { min-height: 26px; padding: 0 10px; font-size: 11.5px; }
.seg.is-icons .seg-btn { padding: 0 9px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 11px 14px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: transparent;
  color: var(--text-2); font-weight: 600; font-size: 12.5px; white-space: nowrap; border-radius: var(--radius) var(--radius) 0 0;
}
.tabs:not(.is-pills) .tab-btn { font-size: var(--section-label-size); font-weight: 700; letter-spacing: var(--section-label-ls); text-transform: var(--section-label-case); }
.tab-btn:hover { color: var(--text); background: var(--surface-3); }
.tab-btn.is-on { color: var(--text); border-bottom-color: var(--accent); }
.tabs.is-pills { border-bottom: 0; gap: 0; }
.tabs.is-pills .tab-btn { border: 1px solid var(--border); border-radius: 0; margin: 0 -1px 0 0; padding: 6px 12px; position: relative; }
.tabs.is-pills .tab-btn.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); z-index: 1; }
:root[data-skin="modern"] .tabs.is-pills { gap: 4px; }
:root[data-skin="modern"] .tabs.is-pills .tab-btn { border-color: transparent; border-radius: var(--radius); margin: 0; }

/* ---------- switch ---------- */
.switch { position: relative; }
.switch-input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch-label { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--text); min-height: 28px; }
.switch-track { position: relative; flex: none; width: 38px; height: 22px; border-radius: 22px; background: var(--border-strong); transition: background-color .15s; }
.switch-thumb { position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.switch-input:checked + .switch-label .switch-track { background: var(--accent); }
.switch-input:checked + .switch-label .switch-thumb { transform: translateX(16px); background: var(--accent-ink); }
.switch-input:focus-visible + .switch-label .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch-input:disabled, .switch.is-disabled .switch-input { cursor: not-allowed; }
.switch.is-disabled .switch-label { opacity: .5; }

/* ---------- chips / badges / cards ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; min-height: 28px; border-radius: var(--radius-pill); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-2); font-size: 12px; font-weight: 600;
}
button.chip:hover { background: var(--surface-3); color: var(--text); }
.chip[aria-pressed="true"], .chip.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 700; background: var(--surface-3); color: var(--text-2); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); box-shadow: var(--shadow-1); }
.card-pad { padding: 16px; }
.hr { height: 1px; background: var(--hairline); border: 0; margin: 14px 0; }
.muted { color: var(--text-3); }
.kbd { font-family: var(--mono-font); font-size: 11px; padding: 1px 5px; border: 1px solid var(--border-strong); border-radius: 3px; background: var(--surface-2); }

.code-block {
  margin: 0; padding: 14px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text);
  font-family: var(--mono-font); font-size: 12px; line-height: 1.55; overflow: auto; white-space: pre; tab-size: 2; max-height: 52vh;
}

.spinner { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: tp-spin .7s linear infinite; }
@keyframes tp-spin { to { transform: rotate(360deg); } }

/* ---------- accordion sections (settings panel) ---------- */
.acc { border-top: 1px solid var(--hairline); }
.acc:first-child { border-top: 0; }
.acc > summary {
  list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 0 14px; cursor: pointer; user-select: none;
  font-size: var(--section-label-size); font-weight: 800; letter-spacing: var(--section-label-ls); text-transform: var(--section-label-case); color: var(--text);
}
:root[data-skin="modern"] .acc > summary { font-weight: 700; color: var(--text-2); }
.acc > summary::-webkit-details-marker { display: none; }
.acc > summary::after { content: ""; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translateY(-2px); transition: transform .15s; margin-right: 4px; }
.acc[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
.acc > summary:hover { color: var(--text); }
.acc-body { padding: 0 0 22px; }
.acc-body > * + * { margin-top: 20px; }                                   /* one vertical rhythm for everything inside a settings section */
.acc-body > .field-help, .acc-body > * + .field-help { margin-top: 8px; }
.acc-body > .field-row + .field-row { margin-top: 14px; }

/* ---------- toast ---------- */
.toasts { position: fixed; z-index: 1200; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; background: var(--text); color: var(--bg); border-radius: var(--radius); box-shadow: var(--shadow-2);
  font-size: 13px; font-weight: 500; animation: tp-in .2s ease; pointer-events: auto;
}
.toast svg { margin-top: 1px; }
.toast-error { background: var(--danger); color: #fff; }
:root[data-theme="dark"] .toast-error { color: #1b0f0e; }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
@keyframes tp-in { from { opacity: 0; transform: translateY(8px); } }
@media (max-width: 1180px) { .toasts { bottom: 76px; } }

/* ---------- modal ---------- */
.tp-modal-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(10, 10, 10, .55); }
.tp-modal {
  width: min(520px, 100%); max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); display: flex; flex-direction: column; background: var(--surface); color: var(--text);
  border: 1px solid var(--text-2); border-radius: var(--radius-l); box-shadow: var(--shadow-2); animation: tp-in .18s ease;
}
:root[data-skin="modern"] .tp-modal { border-color: var(--border-strong); }
.tp-modal.is-wide { width: min(980px, 100%); }
.tp-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 12px; border-bottom: 1px solid var(--border); }
.tp-modal-title { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.tp-modal-body { padding: 16px 18px; overflow: auto; min-height: 0; flex: 1; }
.tp-modal-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--border); }
.tp-modal-text { line-height: 1.55; color: var(--text-2); }
.tp-modal-text + .tp-modal-text { margin-top: 10px; }
@media (max-width: 560px) { .tp-modal-overlay { padding: 8px; align-items: flex-end; } }

/* ---------- popover menu ---------- */
.menu-host { position: relative; }
.tp-menu {
  position: absolute; z-index: 60; top: calc(100% + 6px); left: 0; min-width: 220px; padding: 5px; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-2);
}
.tp-menu.align-end { left: auto; right: 0; }
.tp-menu-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border: 0; background: none; text-align: left; border-radius: var(--radius-s); font-size: 13px; font-weight: 500; color: var(--text); }
.tp-menu-item:hover, .tp-menu-item:focus-visible { background: var(--surface-3); }
.tp-menu-item small { margin-left: auto; color: var(--text-3); font-size: 11px; }
.tp-menu-sep { height: 1px; background: var(--border); margin: 4px 0; }
.tp-menu-heading { padding: 6px 10px 3px; font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
