/* Customization system: wallpaper layer, settings panels, animations. */
#bl-wallpaper { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
#bl-wallpaper[hidden] { display: none; }
#bl-wallpaper .bl-wp-img, #bl-wallpaper .bl-wp-dim { position: absolute; inset: 0; }
#bl-wallpaper .bl-wp-img { background-repeat: no-repeat; }

/* ---------- settings panels ---------- */
.bl-group { margin: 0 0 18px; padding: 0; border: 0; min-width: 0; display: grid; gap: 12px; }
.bl-group > legend { padding: 0; margin-bottom: 10px; font-weight: 700; font-size: 14px; color: var(--text); }
.bl-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
.bl-color-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.bl-color-row > span:first-child { font-size: 13px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl-color-row .color-control { margin-left: auto; }
.bl-mini-reset { width: 28px; height: 28px; padding: 0 !important; justify-content: center !important; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; flex: none; }
.bl-mini-reset:hover { color: var(--text); }
.bl-row { display: flex; flex-wrap: wrap; gap: 10px; }
.bl-row > button { flex: 1 1 150px; justify-content: center !important; }
.bl-reset { width: 100%; justify-content: center !important; }
.bl-hint { margin: 0; font-size: 12px; color: var(--muted); }
.bl-sub { font-size: 13px; color: var(--muted); }
.bl-check { margin: 0; }

.bl-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.bl-seg button { flex: 1 1 auto; min-height: 38px; padding: 0 12px; justify-content: center !important; border: 1px solid var(--border); border-radius: 8px; background: var(--control); color: var(--text); cursor: pointer; font: inherit; font-size: 13px; }
.bl-seg button.active { border-color: var(--highlight, var(--accent)); background: var(--selected); }

.bl-wall-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.bl-wall { aspect-ratio: 16/10; border: 2px solid var(--border) !important; border-radius: 10px !important; padding: 0 !important; display: flex !important; align-items: flex-end; justify-content: flex-start !important; overflow: hidden; cursor: pointer; background-size: cover; }
.bl-wall span { width: 100%; padding: 3px 6px; font-size: 11px; color: #fff; background: rgba(0,0,0,.45); text-align: left; }
.bl-wall.active { border-color: var(--highlight, var(--accent)) !important; }
.bl-wall[hidden], .bl-group [hidden] { display: none !important; }

.bl-btn-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.bl-btn-card { padding: 10px !important; min-height: 64px; display: flex !important; align-items: center; justify-content: center !important; border: 1px solid var(--border) !important; border-radius: 10px !important; cursor: pointer; background: linear-gradient(135deg, var(--bg), var(--surface-2)) !important; box-shadow: none !important; }
.bl-btn-card.active { border-color: var(--highlight, var(--accent)) !important; }
.bl-btn-demo { display: inline-flex; align-items: center; justify-content: center; min-height: 32px; padding: 0 12px; font-size: 12px; color: var(--text); white-space: nowrap; }
.bl-btn-stage { display: none; }

.bl-preset-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.bl-preset { padding: 8px !important; display: flex !important; flex-direction: column; gap: 8px; align-items: stretch !important; justify-content: flex-start !important; border: 1px solid var(--border) !important; border-radius: 10px !important; cursor: pointer; background: var(--control) !important; box-shadow: none !important; }
.bl-preset.active { border-color: var(--highlight, var(--accent)) !important; background: var(--selected) !important; }
.bl-preset-sw { position: relative; display: block; height: 46px; border-radius: 6px; overflow: hidden; border: 1px solid rgba(128,128,128,.3); }
.bl-preset-sw i { position: absolute; left: 0; top: 0; bottom: 0; width: 28%; }
.bl-preset-sw i + i { left: 34%; top: 10px; bottom: auto; width: 58%; height: 10px; border-radius: 3px; }
.bl-preset-sw b { position: absolute; right: 8px; bottom: 8px; width: 30%; height: 10px; border-radius: 5px; }
.bl-custom-sw { display: grid; place-items: center; background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 6px, var(--surface-3) 6px, var(--surface-3) 12px); }
.bl-custom-sw i { position: static; width: auto; background: none !important; font-style: normal; font-size: 18px; color: var(--text); }
.bl-preset-name { font-size: 12px; color: var(--text); text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bl-mock { display: grid; grid-template-columns: 70px 1fr; height: 130px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--bg); }
.bl-mock-side { background: var(--surface); border-right: 1px solid var(--border); padding: 10px 8px; display: grid; align-content: start; gap: 8px; }
.bl-mock-side i { height: 10px; border-radius: 5px; background: var(--selected); }
.bl-mock-side i:first-child { background: var(--accent); }
.bl-mock-main { padding: 10px 12px; display: grid; gap: 8px; align-content: start; }
.bl-mock-row { display: flex; gap: 8px; align-items: center; }
.bl-mock-row b { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); flex: none; }
.bl-mock-row span { flex: 1; height: 10px; border-radius: 5px; background: var(--surface-2); }
.bl-mock-main button { justify-self: start; pointer-events: none; }

@media (max-width: 560px) {
  .bl-grid2 { grid-template-columns: 1fr; }
  .bl-wall-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bl-btn-grid, .bl-preset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- animations ---------- */
html { --bl-speed: 1; --bl-ease: cubic-bezier(.2, .8, .2, 1); }
@keyframes bl-fade { from { opacity: 0; } }
@keyframes bl-slide { from { opacity: 0; transform: translateY(18px); } }
@keyframes bl-zoom { from { opacity: 0; transform: scale(.86); } }
@keyframes bl-scale { from { opacity: .4; transform: scale(1.07); } }
@keyframes bl-blur { from { opacity: 0; filter: blur(14px); } }
@keyframes bl-spring { 0% { opacity: 0; transform: scale(.82); } 60% { transform: scale(1.04); } 100% { opacity: 1; transform: scale(1); } }
html[data-bl-anim="fade"] { --bl-kf: bl-fade; }
html[data-bl-anim="slide"] { --bl-kf: bl-slide; }
html[data-bl-anim="zoom"] { --bl-kf: bl-zoom; }
html[data-bl-anim="scale"] { --bl-kf: bl-scale; }
html[data-bl-anim="blur"] { --bl-kf: bl-blur; }
html[data-bl-anim="spring"] { --bl-kf: bl-spring; --bl-ease: cubic-bezier(.34, 1.56, .64, 1); }

html[data-bl-anim]:not([data-bl-anim="off"]):not([data-bl-off~="windows"]) :is(dialog[open], .compose-window) {
  animation: var(--bl-kf, bl-fade) calc(.26s / var(--bl-speed)) var(--bl-ease) both !important;
}
html[data-bl-anim]:not([data-bl-anim="off"]):not([data-bl-off~="modals"]) dialog.modal[open] {
  animation: var(--bl-kf, bl-fade) calc(.26s / var(--bl-speed)) var(--bl-ease) both !important;
}
html[data-bl-anim]:not([data-bl-anim="off"]):not([data-bl-off~="menus"]) :is(.account-menu, .header-dropdown, .sound-picker-options, .popover):not([hidden]) {
  animation: var(--bl-kf, bl-fade) calc(.2s / var(--bl-speed)) var(--bl-ease) both;
}
html[data-bl-anim]:not([data-bl-anim="off"]):not([data-bl-off~="toasts"]) .toast.visible {
  animation: var(--bl-kf, bl-fade) calc(.26s / var(--bl-speed)) var(--bl-ease) both;
}
html[data-bl-anim]:not([data-bl-anim="off"]):not([data-bl-off~="tooltips"]) :is([role="tooltip"], .tooltip) {
  animation: bl-fade calc(.18s / var(--bl-speed)) ease both;
}
html[data-bl-anim]:not([data-bl-anim="off"]) .settings-panel.bl-replay, html[data-bl-anim]:not([data-bl-anim="off"]) .bl-replay {
  animation: var(--bl-kf, bl-fade) calc(.5s / var(--bl-speed)) var(--bl-ease) both;
}
/* Buttons of the header and of the navigation appear one by one (the blocks themselves stay still):
   header buttons from right to left, menu buttons from the bottom up. customize.js sets data-bl-stg and --bl-i. */
@keyframes bl-stagger-up { from { opacity: 0; transform: translateY(16px); } }
@keyframes bl-stagger-left { from { opacity: 0; transform: translateX(18px); } }
html[data-bl-anim]:not([data-bl-anim="off"]):not([data-bl-off~="stagger"]) [data-bl-stg="up"] {
  animation: bl-stagger-up calc(.45s / var(--bl-speed)) var(--bl-ease) backwards;
  animation-delay: calc(var(--bl-i, 0) * 70ms / var(--bl-speed));
}
html[data-bl-anim]:not([data-bl-anim="off"]):not([data-bl-off~="stagger"]) [data-bl-stg="left"] {
  animation: bl-stagger-left calc(.45s / var(--bl-speed)) var(--bl-ease) backwards;
  animation-delay: calc(var(--bl-i, 0) * 70ms / var(--bl-speed));
}
/* speed of hover/press/transition effects */
html[data-bl-anim]:not([data-bl-anim="off"]):not([data-bl-off~="buttons"]):not([data-bl-off~="hover"]) :is(button, a, input, label, select, textarea) {
  transition-duration: calc(.28s / var(--bl-speed)) !important;
}
html[data-bl-anim]:not([data-bl-anim="off"]):not([data-bl-off~="sidebar"]) .sidebar { transition-duration: calc(.3s / var(--bl-speed)) !important; }
/* per-target switches */
html[data-bl-off~="buttons"] :is(button, a.button), html[data-bl-off~="hover"] :is(button, a, label, .message-row):hover,
html[data-bl-off~="transitions"] :is(.mail-content, .message-list, .reader, .settings-panel, .settings-function) {
  transition: none !important; animation: none !important;
}
html[data-bl-off~="sidebar"] .sidebar, html[data-bl-off~="sidebar"] .sidebar * { transition: none !important; }
html[data-bl-off~="windows"] :is(dialog[open], .compose-window), html[data-bl-off~="modals"] dialog.modal[open],
html[data-bl-off~="menus"] :is(.account-menu, .header-dropdown, .sound-picker-options),
html[data-bl-off~="toasts"] .toast, html[data-bl-off~="tooltips"] :is([role="tooltip"], .tooltip) { animation: none !important; transition: none !important; }
/* master switch */
html[data-bl-anim="off"] *, html[data-bl-anim="off"] *::before, html[data-bl-anim="off"] *::after {
  animation: none !important; transition: none !important; scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
  html[data-bl-reduce="1"] *, html[data-bl-reduce="1"] *::before, html[data-bl-reduce="1"] *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}

/* ---------- smooth range sliders ----------
   The native thumb is invisible (it only handles the pointer); the visible fill and thumb
   are drawn from --range-t (0..1), a registered property that eases to every new value. */
@property --range-t { syntax: "<number>"; inherits: true; initial-value: 0; }
html .sound-volume-control input[type="range"] {
  --thumb: 22px;
  --pos: calc(var(--thumb) / 2 + (100% - var(--thumb)) * var(--range-t));
  height: var(--thumb);
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  background:
    radial-gradient(circle at var(--pos) 50%, var(--accent) 0 5.5px, var(--surface) 6px 8.5px, var(--accent-soft) 9px 10.5px, transparent 11px),
    linear-gradient(to right, var(--accent) var(--pos), var(--surface-3) var(--pos)) center / 100% 8px no-repeat;
  border-radius: 0;
  transition: --range-t .18s cubic-bezier(.2, .8, .2, 1);
  cursor: pointer;
}
html .sound-volume-control input[type="range"]::-webkit-slider-runnable-track { height: var(--thumb); background: transparent; border: 0; }
html .sound-volume-control input[type="range"]::-moz-range-track { height: var(--thumb); background: transparent; border: 0; }
html .sound-volume-control input[type="range"]::-webkit-slider-thumb { width: var(--thumb); height: var(--thumb); opacity: 0; -webkit-appearance: none; }
html .sound-volume-control input[type="range"]::-moz-range-thumb { width: var(--thumb); height: var(--thumb); opacity: 0; border: 0; }
html[data-bl-anim="off"] .sound-volume-control input[type="range"] { transition: none; }
@media (prefers-reduced-motion: reduce) { html[data-bl-reduce="1"] .sound-volume-control input[type="range"] { transition: none; } }

html .settings-form .bl-color-row { display: flex !important; flex-direction: row; flex-wrap: nowrap; align-items: center; gap: 8px; padding: 0; border: 0; background: none; }
html .bl-color-row > span:first-child { flex: 1 1 auto; }
html .bl-color-row .color-control { flex: 0 0 auto; margin-left: 0; }
