/* Stretch the Cat — minimal, Apple-flavored UI (tokens shared with app.css) */

/* Dark variant of the app.css token set — same names, night values. */
:root {
  --bg: #12151c;
  --backdrop: radial-gradient(120% 92% at 50% 4%, #2b3444 0%, #1a202c 42%, #0d0f15 100%);
  --panel: #1c1f27;
  --border: rgba(255, 255, 255, 0.10);
  --border-soft: rgba(255, 255, 255, 0.06);
  --text: #f5f5f7;
  --text-2: #8e8e93;
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.16);
  --danger: #ff453a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-big: 0 2px 6px rgba(0, 0, 0, 0.35), 0 18px 50px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue",
    Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  background-image: var(--backdrop);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  user-select: none;
  overscroll-behavior: none;
  touch-action: none;
}

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
button:disabled { opacity: 0.35; cursor: default; }

/* ---------- Stage ---------- */

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: default;
  background: transparent;   /* the body gradient shows through */
  touch-action: none;
}
#stage.can-grab { cursor: grab; }
#stage.grabbing { cursor: grabbing; }

/* ---------- Top bar ---------- */

#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
  background: rgba(22, 26, 34, 0.6);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border-bottom: 1px solid var(--border-soft);
  z-index: 30;
}

.tb-group { display: flex; align-items: center; gap: 8px; }
.tb-left { flex: 1 1 0; min-width: 0; }
.tb-right { flex: 0 0 auto; }

.title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.seg-label {
  font-size: 12px;
  color: var(--text-2);
}

/* ---------- Segmented control ---------- */

.segmented {
  display: inline-flex;
  padding: 2px;
  border-radius: 9px;
  background: rgba(120, 120, 128, 0.22);
}
.segmented button {
  padding: 4px 13px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  transition: background 0.18s ease, box-shadow 0.18s ease, transform 0.1s ease;
}
.segmented button:active { transform: scale(0.97); }
.segmented button.on {
  background: rgba(120, 120, 128, 0.52);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 0 0 0.5px rgba(255, 255, 255, 0.08);
}

/* ---------- Bottom dock ---------- */

#dock {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 9px 7px 14px;
  border-radius: 980px;
  background: rgba(22, 26, 34, 0.62);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 30;
}

.dock-item { display: flex; align-items: center; gap: 10px; }
.dock-label { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.dock-sep { width: 1px; height: 18px; background: var(--border); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 116px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.18);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 0.5px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border: 0.5px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.icon-btn {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--text);
  transition: background 0.15s ease, transform 0.1s ease, color 0.15s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.1); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn .ico-off { display: none; }
.icon-btn[aria-pressed="true"] { color: var(--text-2); }
.icon-btn[aria-pressed="true"] .ico-on { display: none; }
.icon-btn[aria-pressed="true"] .ico-off { display: block; }

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: 980px;
  font-weight: 500;
  font-size: 12.5px;
  transition: background 0.15s ease, transform 0.1s ease;
}
.pill-btn:active { transform: scale(0.97); }
.pill-btn.ghost { color: var(--text); }
.pill-btn.ghost:hover { background: rgba(255, 255, 255, 0.1); }

/* ---------- Switch ---------- */

.switch { display: flex; align-items: center; gap: 8px; }

.switch-label {
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  transition: color 0.2s ease;
}
.switch:has([aria-checked="true"]) .switch-label { color: var(--text); }

.switch-track {
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 22px;
  padding: 0;
  border-radius: 999px;
  background: rgba(120, 120, 128, 0.34);
  transition: background 0.22s ease;
}
.switch-track:hover { background: rgba(120, 120, 128, 0.46); }
.switch-track[aria-checked="true"],
.switch-track[aria-checked="true"]:hover { background: var(--accent); }
.switch-track:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.switch-track[aria-checked="true"] .switch-knob { transform: translateX(16px); }

/* ---------- Hint ---------- */

#hint {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  font-size: 15px;
  color: var(--text-2);
  letter-spacing: -0.01em;
  pointer-events: none;
  z-index: 20;
  opacity: 0;
  transition: opacity 0.6s ease;
}
#hint.show { opacity: 1; }
#hint.gone { opacity: 0; }

/* ---------- Loader ---------- */

#loader {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: rgba(13, 15, 21, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 60;
  transition: opacity 0.45s ease;
}
#loader.hide { opacity: 0; pointer-events: none; }

.spinner {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--text-2);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#loader-text { font-size: 13px; color: var(--text-2); }

/* ---------- Fatal ---------- */

#fatal {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  background: rgba(13, 15, 21, 0.9);
  backdrop-filter: blur(10px);
  z-index: 70;
}
#fatal[hidden] { display: none; }
.fatal-card {
  max-width: 420px;
  padding: 22px 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-big);
}
.fatal-card h2 { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.fatal-card p { font-size: 13px; color: var(--text-2); line-height: 1.5; white-space: pre-wrap; }

/* ---------- Narrow screens ---------- */

@media (max-width: 560px) {
  .seg-label { display: none; }
  .dock-label { display: none; }
  .btn-label { display: none; }   /* «Сбросить» остаётся иконкой */
  #dock { gap: 9px; padding: 7px 10px; }
  .pill-btn { padding: 6px 8px; }
  input[type="range"] { width: 78px; }
}
