/* ==========================================================================
   Shared chrome for the tools (Focus, Spend, Hue): top bar, cards, buttons,
   inputs, switches, dialogs and toasts. Tokens come from tokens.css.
   ========================================================================== */

body.app { min-height: 100vh; overflow-x: hidden; }

.app-bg { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.app-bg i { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .5; background-color: var(--orb1, var(--accent-soft)); transition: background-color 1.2s var(--ease-io); animation: orbFloat 22s ease-in-out infinite; }
.app-bg i:nth-child(1) { width: 46vmax; height: 46vmax; left: -12vmax; top: -16vmax; }
.app-bg i:nth-child(2) { width: 38vmax; height: 38vmax; right: -10vmax; top: 10vh; background-color: var(--orb2, #d6dbf8); animation-duration: 28s; animation-delay: -8s; opacity: .55; }
.app-bg i:nth-child(3) { width: 34vmax; height: 34vmax; left: 25%; bottom: -22vmax; background-color: var(--orb1, var(--accent-soft)); animation-duration: 25s; animation-delay: -14s; opacity: .35; }
@keyframes orbFloat { 0%,100% { transform: translate3d(0,0,0) scale(1); } 50% { transform: translate3d(3vmax,2vmax,0) scale(1.1); } }

/* ───── top bar ───── */
.topbar { position: sticky; top: 0; z-index: 60; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px clamp(16px, 4vw, 40px); background: rgba(251, 251, 254, .72); -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px); border-bottom: 1px solid var(--line); }
.back { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: .86rem; color: var(--ink-2); padding: 8px 14px 8px 10px; border-radius: 999px; transition: background .3s, color .3s; }
.back span { transition: transform .5s var(--ease-out); display: inline-block; }
.back:hover { background: var(--accent-ghost); color: var(--accent-lo); } .back:hover span { transform: translateX(-4px); }
.app-title { position: absolute; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.12rem; letter-spacing: -.04em; }
.app-title .logo { width: 30px; height: 30px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 16px rgba(82,96,189,.38); }
.app-title .logo svg { width: 18px; height: 18px; }
.top-actions { display: flex; align-items: center; gap: 8px; }

/* ───── buttons ───── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 11px 18px; border-radius: 999px; border: 1px solid transparent; font-weight: 700; font-size: .88rem; cursor: pointer; letter-spacing: -.01em; transition: background .3s, color .3s, border-color .3s, box-shadow .3s, transform .35s var(--ease-spring); user-select: none; }
.btn:active { transform: scale(.95); }
.btn-primary { background: var(--ink); color: #fff; box-shadow: 0 8px 22px rgba(18,20,43,.2); }
.btn-primary:hover { background: var(--accent); box-shadow: 0 10px 26px rgba(82,96,189,.36); }
.btn-accent { background: var(--accent); color: #fff; box-shadow: 0 8px 22px rgba(82,96,189,.32); }
.btn-accent:hover { background: var(--accent-lo); }
.btn-soft { background: var(--accent-ghost); color: var(--accent-lo); }
.btn-soft:hover { background: var(--accent-tint); }
.btn-ghost { background: rgba(255,255,255,.7); border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-lo); background: #fff; }
.btn-danger { background: rgba(194,90,112,.1); color: var(--bad); } .btn-danger:hover { background: rgba(194,90,112,.18); }
.btn-sm { padding: 8px 14px; font-size: .8rem; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,.75); display: grid; place-items: center; cursor: pointer; color: var(--ink-2); transition: background .3s, color .3s, border-color .3s, transform .4s var(--ease-spring); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { border-color: var(--accent-soft); color: var(--accent); background: #fff; transform: translateY(-1px); }
.icon-btn:active { transform: scale(.92); }

/* ───── cards ───── */
.card { background: rgba(255,255,255,.82); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow-md); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 18px; }
.card-title h2 { font-size: 1.05rem; font-weight: 800; letter-spacing: -.035em; margin: 0; }
.eyebrow-s { font: 500 .66rem var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

/* ───── inputs ───── */
.input, .select { width: 100%; font: 600 .92rem var(--sans); color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 14px; padding: 12px 14px; outline: none; transition: border-color .25s, box-shadow .25s; }
.input::placeholder { color: var(--muted); font-weight: 500; }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ghost); }
.select { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23858aa5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
label.field { display: grid; gap: 7px; }
label.field > span { font: 500 .66rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

/* light range slider */
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; cursor: pointer; margin: 0; }
.range::-webkit-slider-runnable-track { height: 5px; border-radius: 5px; background: linear-gradient(90deg, var(--accent) var(--fill, 50%), var(--accent-tint) var(--fill, 50%)); }
.range::-moz-range-track { height: 5px; border-radius: 5px; background: var(--accent-tint); }
.range::-moz-range-progress { height: 5px; border-radius: 5px; background: var(--accent); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6.5px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); box-shadow: 0 2px 8px rgba(82,96,189,.35); transition: transform .25s var(--ease-spring); }
.range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); box-shadow: 0 2px 8px rgba(82,96,189,.35); }
.range:hover::-webkit-slider-thumb { transform: scale(1.18); }

/* switch */
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--line-strong); transition: background .35s; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(18,20,43,.25); transition: transform .45s var(--ease-spring); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ───── dialog ───── */
dialog.sheet { border: 0; padding: 0; background: transparent; max-width: min(520px, 94vw); width: 100%; color: var(--ink); overflow: visible; }
dialog.sheet::backdrop { background: rgba(20, 24, 56, .35); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fadeIn .3s ease; }
dialog.sheet[open] .sheet-card { animation: sheetIn .55s var(--ease-out); }
.sheet-card { background: #fff; border-radius: 28px; padding: 28px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); max-height: 88vh; overflow: auto; }
.sheet-card h2 { font-size: 1.35rem; letter-spacing: -.04em; margin: 0 0 4px; font-weight: 800; }
.sheet-card .sub { color: var(--muted); font-size: .86rem; margin: 0 0 22px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes sheetIn { from { opacity: 0; transform: translateY(24px) scale(.96); } }

/* ───── toasts ───── */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200; display: grid; gap: 10px; justify-items: center; pointer-events: none; width: max-content; max-width: 92vw; }
.toast { background: var(--ink); color: #fff; font-weight: 600; font-size: .86rem; padding: 12px 18px; border-radius: 999px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; animation: toastIn .6s var(--ease-spring) both; }
.toast.out { animation: toastOut .4s var(--ease-io) forwards; }
.toast i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-soft); }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px) scale(.9); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(.95); } }

/* ───── entrance ───── */
.rise { opacity: 0; transform: translateY(24px); animation: rise .9s var(--ease-out) forwards; animation-delay: calc(var(--i, 0) * .08s + .05s); }
@keyframes rise { to { opacity: 1; transform: none; } }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 720px) {
  .app-title { position: static; transform: none; }
  .back { padding-right: 10px; }
  .back b { display: none; }
}
@media (prefers-reduced-motion: reduce) { .rise { opacity: 1; transform: none; } }
[hidden] { display: none !important; }
.toast-action { margin-left: 4px; border: 0; background: rgba(255,255,255,.16); color: #fff; font: 700 .78rem var(--sans); padding: 6px 12px; border-radius: 999px; cursor: pointer; transition: background .25s; }
.toast-action:hover { background: rgba(255,255,255,.3); }
