:root {
    color-scheme: light;
    --surface: #fbfaf7;
    --surface-soft: #f5f2ec;
    --surface-muted: #eef2f2;
    --ink: #172027;
    --ink-soft: #52606a;
    --line: #d9e0e2;
    --line-strong: #bac7cb;
    --accent: #0b4f86;
    --accent-deep: #07375e;
    --accent-soft: #e5f1fa;
    --danger: #a23d35;
    --shadow: 0 18px 46px rgba(20, 42, 55, 0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --motion: 160ms ease;
    font-family: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body, #app {
    min-width: 320px;
    min-height: 100%;
    margin: 0;
}

body {
    background: var(--surface-soft);
    color: var(--ink);
    overflow: hidden;
}

button, input, select {
    font: inherit;
}

button {
    color: inherit;
}

button, select, input[type="range"] {
    cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
    outline: 3px solid rgba(22, 112, 177, 0.28);
    outline-offset: 2px;
}

.boot-loader {
    position: fixed;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 18px;
    background: #f5f7f7;
    color: var(--ink-soft);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.boot-loader__mark {
    width: 46px;
    aspect-ratio: 1;
    border: 3px solid #d4e1e8;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 800ms linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.pool-studio {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(500px, 31.8vw, 560px);
    width: 100vw;
    height: 100dvh;
    background: var(--surface-soft);
}

.viewport-panel {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    isolation: isolate;
    background: linear-gradient(180deg, #a8d1eb 0%, #dce9e6 43%, #d8d1c3 100%);
}

.pool-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.brand-lockup {
    position: absolute;
    z-index: 3;
    top: 26px;
    left: 26px;
    display: flex;
    align-items: center;
    gap: 16px;
    pointer-events: none;
}

.brand-lockup__name {
    color: #15212a;
    font-size: clamp(18px, 1.35vw, 24px);
    font-weight: 700;
    letter-spacing: -0.04em;
    text-shadow: 0 1px 18px rgba(255, 255, 255, 0.5);
}

.backend-badge {
    display: inline-flex;
    align-items: center;
    min-height: 29px;
    padding: 4px 10px;
    border: 1px solid rgba(11, 79, 134, 0.68);
    border-radius: 5px;
    background: rgba(241, 248, 252, 0.86);
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    backdrop-filter: blur(10px);
}

.backend-badge--webgl2 {
    border-color: rgba(72, 86, 96, 0.5);
    color: #41515c;
}

.backend-badge--starting {
    color: var(--ink-soft);
    border-color: rgba(82, 96, 106, 0.4);
}

.renderer-state {
    position: absolute;
    z-index: 4;
    inset: 50% auto auto 50%;
    width: min(360px, calc(100% - 40px));
    padding: 26px 28px;
    transform: translate(-50%, -50%);
    border: 1px solid rgba(255, 255, 255, 0.85);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.91);
    box-shadow: var(--shadow);
    text-align: center;
    backdrop-filter: blur(16px);
}

.renderer-state strong {
    display: block;
    margin-top: 13px;
    font-size: 17px;
}

.renderer-state p {
    margin: 7px 0 0;
    color: var(--ink-soft);
    font-size: 13px;
    line-height: 1.5;
}

.renderer-state .button {
    margin-top: 18px;
}

.renderer-state__spinner {
    display: inline-block;
    width: 31px;
    aspect-ratio: 1;
    border: 3px solid #d7e5ed;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 800ms linear infinite;
}

.renderer-state__icon {
    display: inline-grid;
    place-items: center;
    width: 34px;
    aspect-ratio: 1;
    border-radius: 50%;
    background: #f5ddd9;
    color: var(--danger);
    font-weight: 700;
}

.viewport-help {
    position: absolute;
    z-index: 3;
    left: 20px;
    bottom: 132px;
    display: grid;
    gap: 17px;
    min-width: 194px;
    padding: 17px 18px;
    border: 1px solid rgba(142, 156, 164, 0.55);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.84);
    color: #33414a;
    font-size: 15px;
    backdrop-filter: blur(10px);
}

.viewport-help span,
.viewport-button {
    display: flex;
    align-items: center;
    gap: 10px;
}

.viewport-help svg,
.viewport-button svg,
.icon-button svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.65;
}

.viewport-button {
    position: absolute;
    z-index: 3;
    left: 20px;
    bottom: 44px;
    min-height: 58px;
    min-width: 174px;
    padding: 0 20px;
    border: 1px solid rgba(11, 79, 134, 0.65);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--accent);
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 5px 22px rgba(22, 45, 60, 0.08);
    backdrop-filter: blur(10px);
    transition: background var(--motion), transform var(--motion);
}

.viewport-button:hover {
    background: #fff;
    transform: translateY(-1px);
}

.viewport-panel--night .brand-lockup__name {
    color: #f6fbff;
    text-shadow: 0 2px 14px rgba(4, 12, 27, 0.72);
}

.viewport-panel--night .backend-badge {
    border-color: rgba(185, 222, 255, 0.72);
    background: rgba(8, 27, 52, 0.7);
    color: #d9eeff;
}

.config-panel {
    position: relative;
    z-index: 5;
    min-width: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 38px 34px 24px;
    border-left: 1px solid #e0e5e6;
    background: var(--surface);
    box-shadow: -8px 0 28px rgba(22, 44, 54, 0.045);
    scrollbar-width: none;
}

.config-panel::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.config-panel__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 23px;
}

.config-panel__context {
    margin: 0 0 4px;
    color: #6c7981;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

h1, h2, p {
    margin-top: 0;
}

.config-panel h1 {
    margin-bottom: 0;
    color: var(--ink);
    font-size: clamp(30px, 2vw, 35px);
    font-weight: 600;
    letter-spacing: -0.045em;
    line-height: 1.12;
}

.config-panel h1:focus {
    outline: none;
}

.icon-button {
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    width: 39px;
    height: 39px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: #50606a;
    transition: border var(--motion), color var(--motion), background var(--motion);
}

.icon-button:hover {
    border-color: var(--line-strong);
    background: var(--surface-soft);
    color: var(--accent);
}

.validation-summary {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-left: 3px solid #c48b39;
    background: #fff8e9;
    color: #6d542e;
    font-size: 12px;
    line-height: 1.4;
}

.config-section {
    padding: 20px 0 21px;
    border-top: 1px solid var(--line);
}

.config-section:first-of-type {
    border-top: 0;
}

.config-section h2 {
    margin-bottom: 13px;
    color: #1e282e;
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -0.025em;
}

.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 17px;
}

.section-heading h2 {
    margin-bottom: 0;
}

.section-heading--action {
    align-items: center;
}

.section-heading__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.camera-preset-button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 0 11px;
    color: var(--accent);
    white-space: nowrap;
}

.camera-preset-button svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.section-heading p {
    margin: 4px 0 0;
    color: #748088;
    font-size: 11px;
    line-height: 1.4;
}

.unit-toggle {
    display: inline-grid;
    grid-template-columns: 1fr 1fr;
    overflow: hidden;
    min-width: 126px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: #fff;
}

.unit-toggle__button {
    min-height: 40px;
    padding: 0 18px;
    border: 0;
    background: #fff;
    color: #4d5c65;
    font-size: 16px;
    transition: background var(--motion), color var(--motion);
}

.unit-toggle__button + .unit-toggle__button {
    border-left: 1px solid var(--line);
}

.unit-toggle__button--active {
    background: var(--accent);
    color: #fff;
}

.lighting-toggle {
    min-width: 150px;
}

.lighting-toggle .unit-toggle__button {
    padding-inline: 14px;
    font-size: 13px;
}

.range-field {
    display: grid;
    gap: 8px;
    margin-top: 13px;
}

.config-section--primary .range-field {
    grid-template-columns: 70px minmax(0, 1fr);
    align-items: center;
    gap: 18px;
    margin-top: 27px;
}

.config-section--primary .range-field__header {
    display: block;
}

.config-section--primary .range-field__header label {
    color: #20272b;
    font-size: 16px;
    font-weight: 400;
}

.config-section--primary .range-field__controls {
    grid-template-columns: minmax(120px, 1fr) 126px;
    gap: 24px;
}

.config-section--water .range-field {
    margin-top: 0;
}

.config-section--water {
    padding-bottom: 4px;
}

.config-section--water .range-field__header {
    display: none;
}

.config-section--water .range-field__controls {
    grid-template-columns: minmax(150px, 1fr) 126px;
    gap: 24px;
}

.water-level-note {
    margin: 8px 0 0;
    color: #62686b;
    font-size: 15px;
}

.range-field__header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.range-field__header label,
.select-field label {
    color: #37444c;
    font-size: 13px;
    font-weight: 500;
}

.range-field__hint {
    color: #7a868d;
    font-size: 10px;
}

.range-field__controls {
    display: grid;
    grid-template-columns: minmax(94px, 1fr) 126px;
    align-items: center;
    gap: 18px;
}

.range-field__slider {
    width: 100%;
    height: 20px;
    margin: 0;
    appearance: none;
    background: transparent;
}

.range-field__slider::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--accent), #cfd7da);
}

.range-field__slider::-webkit-slider-thumb {
    width: 19px;
    height: 19px;
    margin-top: -7.5px;
    appearance: none;
    border: 2px solid var(--accent);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(27, 55, 70, 0.15);
}

.range-field__slider::-moz-range-track {
    height: 3px;
    border-radius: 2px;
    background: #cfd7da;
}

.range-field__slider::-moz-range-progress {
    height: 3px;
    background: var(--accent);
}

.range-field__slider::-moz-range-thumb {
    width: 15px;
    height: 15px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    background: #fff;
}

.range-field__number-wrap {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    min-height: 40px;
    grid-template-columns: minmax(0, 1fr) 25px;
    gap: 7px;
    overflow: visible;
    border: 0;
    background: transparent;
}

.range-field__number {
    min-width: 0;
    width: 100%;
    height: 38px;
    padding: 0 4px 0 11px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: #fff;
    color: #27343b;
    font-size: 16px;
    font-variant-numeric: tabular-nums;
    outline: 0;
}

.range-field__unit {
    min-width: 25px;
    padding-right: 0;
    color: #63717a;
    font-size: 14px;
    text-align: right;
}

.control-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.control-grid .range-field__controls {
    grid-template-columns: 1fr 88px;
    gap: 10px;
}

.select-field {
    display: grid;
    gap: 7px;
    margin-top: 15px;
}

.select-field select {
    width: 100%;
    min-height: 40px;
    padding: 0 34px 0 11px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: #fff;
    color: #2e3b43;
    font-size: 13px;
}

.detail-panel {
    margin-top: 16px;
    padding: 0 12px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f9fbfb;
}

.detail-panel summary {
    margin: 0 -12px;
    padding: 11px 12px;
    color: #44535c;
    font-size: 12px;
    font-weight: 600;
    list-style-position: inside;
    cursor: pointer;
}

.detail-panel[open] summary {
    border-bottom: 1px solid var(--line);
}

.detail-panel__body {
    padding-top: 3px;
}

.switch {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    width: 42px;
    height: 24px;
    cursor: pointer;
}

.switch input {
    position: absolute;
    opacity: 0;
}

.switch > span:first-of-type {
    position: absolute;
    inset: 0;
    border-radius: 12px;
    background: #c9d1d4;
    transition: background var(--motion);
}

.switch > span:first-of-type::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(24, 48, 62, 0.25);
    transition: transform var(--motion);
}

.switch input:checked + span {
    background: var(--accent);
}

.switch input:checked + span::after {
    transform: translateX(18px);
}

.material-picker {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
    gap: 13px;
}

.material-option {
    position: relative;
    min-width: 0;
    overflow: hidden;
    padding: 0;
    border: 1px solid #c7d0d3;
    aspect-ratio: 1;
    border-radius: 9px;
    background: #fff;
    text-align: left;
    transition: border var(--motion), box-shadow var(--motion), transform var(--motion);
}

.material-option:hover {
    transform: translateY(-1px);
    border-color: #8fa5b0;
}

.material-option--selected {
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 2px rgba(11, 79, 134, 0.12);
}

.material-option img {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    height: 100%;
    border-radius: 7px;
    transform: scale(2.8);
}

.material-option--catalog img {
    transform: none;
}

.tile-library {
    width: min(1480px, calc(100vw - 48px));
    max-width: none;
    height: min(860px, calc(100dvh - 48px));
    max-height: none;
    margin: auto;
    padding: 0;
    overflow: hidden;
    border: 1px solid #d5dcde;
    border-radius: 14px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 26px 90px rgba(15, 34, 45, 0.28);
}

.tile-library::backdrop {
    background: rgba(15, 28, 36, 0.56);
    backdrop-filter: blur(4px);
}

.tile-library__shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    height: 100%;
}

.tile-library__header {
    position: relative;
    display: grid;
    grid-template-columns: minmax(240px, 1fr) minmax(320px, 540px) 40px;
    align-items: center;
    gap: 22px;
    padding: 22px 24px 20px;
    border-bottom: 1px solid var(--line);
    background: rgba(252, 251, 248, 0.98);
}

.tile-library__eyebrow {
    margin: 0 0 3px;
    color: var(--accent);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.13em;
}

.tile-library__header h2 {
    margin: 0;
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.035em;
}

.tile-library__close {
    grid-column: 3;
    grid-row: 1;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: #fff;
    color: #41515b;
    font-size: 25px;
    line-height: 1;
}

.tile-library__search {
    position: relative;
    grid-column: 2;
    grid-row: 1;
}

.tile-library__search svg {
    position: absolute;
    top: 50%;
    left: 13px;
    width: 18px;
    height: 18px;
    transform: translateY(-50%);
    fill: none;
    stroke: #64737c;
    stroke-width: 1.8;
}

.tile-library__search input {
    width: 100%;
    height: 44px;
    padding: 0 14px 0 42px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font-size: 14px;
}

.tile-library__body {
    display: grid;
    grid-template-columns: 190px minmax(420px, 1fr) minmax(250px, 310px);
    min-height: 0;
}

.tile-library__filters,
.tile-library__detail {
    overflow-y: auto;
    padding: 20px;
    background: #f7f7f4;
}

.tile-library__filters {
    border-right: 1px solid var(--line);
}

.tile-library__filters details > summary {
    margin-bottom: 14px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.tile-library__filter-grid {
    display: grid;
    gap: 13px;
}

.tile-library__filter-grid label {
    display: grid;
    gap: 5px;
    color: #435159;
    font-size: 11px;
    font-weight: 700;
}

.tile-library__filter-grid select {
    width: 100%;
    min-height: 39px;
    padding: 0 28px 0 9px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: #fff;
    color: #334149;
    font-size: 12px;
}

.tile-library__clear {
    margin-top: 15px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
}

.tile-library__results {
    overflow-y: auto;
    min-width: 0;
    padding: 20px;
    background: #fff;
}

.tile-library__result-summary {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
    color: #75828a;
    font-size: 11px;
}

.tile-library__result-summary strong {
    color: #334149;
    font-size: 13px;
}

.tile-library__grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.tile-card {
    min-width: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid #ccd4d7;
    border-radius: 8px;
    background: #fff;
    color: #34434b;
    text-align: left;
    transition: transform var(--motion), border var(--motion), box-shadow var(--motion);
}

.tile-card:hover {
    transform: translateY(-1px);
    border-color: #8ca3af;
}

.tile-card--selected {
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 2px rgba(11, 79, 134, 0.12);
}

.tile-card__image {
    position: relative;
    display: block;
    aspect-ratio: 1;
    overflow: hidden;
    background: #edf1f2;
}

.tile-card__image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.tile-card__check {
    position: absolute;
    top: 7px;
    right: 7px;
    display: grid;
    place-items: center;
    width: 23px;
    height: 23px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
}

.tile-card__copy {
    display: grid;
    gap: 2px;
    padding: 9px;
    font-size: 10px;
}

.tile-card__copy strong {
    overflow: hidden;
    color: #1f2b31;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tile-card__copy span {
    overflow: hidden;
    color: #76828a;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tile-library__load-more {
    display: block;
    margin: 20px auto 0;
}

.tile-library__empty {
    padding: 80px 20px;
    color: #64717a;
    text-align: center;
}

.tile-library__detail {
    border-left: 1px solid var(--line);
}

.tile-library__hero {
    overflow: hidden;
    aspect-ratio: 1;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
}

.tile-library__hero img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.tile-library__gallery {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
    margin-top: 9px;
}

.tile-library__gallery-button {
    overflow: hidden;
    padding: 0;
    aspect-ratio: 1;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: #fff;
}

.tile-library__gallery-button--active {
    border: 2px solid var(--accent);
}

.tile-library__gallery-button img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tile-library__series {
    margin: 20px 0 3px;
    color: var(--accent);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.tile-library__detail h3 {
    margin: 0 0 13px;
    font-size: 20px;
}

.tile-library__detail dl {
    display: grid;
    gap: 7px;
    margin: 0;
    font-size: 11px;
}

.tile-library__detail dl div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
}

.tile-library__detail dt {
    color: #78858c;
}

.tile-library__detail dd {
    margin: 0;
    color: #344149;
    text-align: right;
}

.tile-library__apply-note {
    margin: 16px 0 0;
    color: #6f7c83;
    font-size: 11px;
    line-height: 1.45;
}

.tile-library__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-height: 72px;
    padding: 14px 24px;
    border-top: 1px solid var(--line);
    background: rgba(252, 251, 248, 0.98);
}

.tile-library__error {
    margin-right: auto;
    color: #963d34;
    font-size: 11px;
}

.material-option__check {
    position: absolute;
    top: 6px;
    right: 6px;
    display: grid;
    place-items: center;
    width: 23px;
    height: 23px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(18, 45, 61, 0.25);
}

.material-option__check svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2.2;
}

.environment-picker {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 11px;
}

.environment-option {
    position: relative;
    overflow: hidden;
    min-width: 0;
    padding: 0;
    border: 1px solid #c7d0d3;
    border-radius: 8px;
    background: #fff;
    text-align: left;
    transition: border var(--motion), box-shadow var(--motion), transform var(--motion);
}

.environment-option:hover {
    transform: translateY(-1px);
    border-color: #8fa5b0;
}

.environment-option--selected {
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 2px rgba(11, 79, 134, 0.12);
}

.environment-option img {
    display: block;
    width: 100%;
    aspect-ratio: 2 / 1;
    object-fit: cover;
}

.environment-option__name {
    display: block;
    padding: 7px 9px 8px;
    color: #435159;
    font-size: 11px;
}

.environment-option__check {
    position: absolute;
    top: 7px;
    right: 7px;
    display: grid;
    place-items: center;
    width: 23px;
    height: 23px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px rgba(18, 45, 61, 0.25);
}

.environment-option__check svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2.2;
}

.advanced-config {
    margin-top: 20px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.advanced-config > summary {
    padding: 18px 0;
    color: #45535a;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.advanced-config__body {
    padding: 0 0 22px;
}

.advanced-config__subheading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.advanced-config__subheading h2 {
    margin: 0;
    font-size: 16px;
}

.advanced-config__subheading p {
    margin: 4px 0 0;
    color: #748088;
    font-size: 11px;
}

.config-panel__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding-top: 4px;
    color: #879198;
    font-size: 10px;
}

.button {
    min-height: 40px;
    padding: 0 15px;
    border: 1px solid transparent;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
}

.button--primary {
    background: var(--accent);
    color: #fff;
}

.button--primary:hover {
    background: var(--accent-deep);
}

.button--quiet {
    border-color: var(--line-strong);
    background: #fff;
    color: #40515b;
}

.button--quiet:hover {
    background: var(--surface-soft);
}

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

#blazor-error-ui {
    position: fixed;
    z-index: 10000;
    right: 20px;
    bottom: 20px;
    left: auto;
    display: none;
    width: min(430px, calc(100% - 40px));
    padding: 14px 50px 14px 16px;
    border: 1px solid #e9b8b2;
    border-radius: 8px;
    background: #fff5f3;
    box-shadow: var(--shadow);
    color: #6f302b;
    font-size: 12px;
}

#blazor-error-ui .reload {
    margin-left: 8px;
    color: #87362f;
    font-weight: 700;
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 7px;
    right: 8px;
    width: 30px;
    height: 30px;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 20px;
}

@media (max-width: 1180px) {
    .pool-studio {
        grid-template-columns: minmax(0, 1fr) 430px;
    }

    .config-panel {
        padding-right: 24px;
        padding-left: 24px;
    }

    .control-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .tile-library__body {
        grid-template-columns: 170px minmax(360px, 1fr) 250px;
    }

    .tile-library__grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    body {
        overflow: auto;
    }

    .pool-studio {
        display: block;
        width: 100%;
        height: auto;
        min-height: 100dvh;
    }

    .viewport-panel {
        height: 58svh;
        min-height: 420px;
    }

    .config-panel {
        overflow: visible;
        min-height: 42svh;
        padding: 28px clamp(20px, 5vw, 48px) 30px;
        border-top: 1px solid var(--line);
        border-left: 0;
        box-shadow: 0 -12px 30px rgba(23, 43, 54, 0.08);
    }

    .material-picker {
        grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
    }

    .tile-library {
        inset: 0;
        width: 100vw;
        height: 100dvh;
        margin: 0;
        border: 0;
        border-radius: 0;
    }

    .tile-library__header {
        position: sticky;
        z-index: 3;
        top: 0;
        grid-template-columns: 1fr 40px;
        gap: 12px;
        padding: 16px 18px 14px;
    }

    .tile-library__header h2 {
        font-size: 22px;
    }

    .tile-library__search {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .tile-library__close {
        grid-column: 2;
    }

    .tile-library__body {
        display: block;
        overflow-y: auto;
    }

    .tile-library__filters,
    .tile-library__results,
    .tile-library__detail {
        overflow: visible;
        padding: 16px 18px;
        border: 0;
    }

    .tile-library__filters {
        border-bottom: 1px solid var(--line);
    }

    .tile-library__filters details:not([open]) {
        padding-bottom: 0;
    }

    .tile-library__filter-grid {
        grid-template-columns: 1fr 1fr;
    }

    .tile-library__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .tile-library__detail {
        display: grid;
        grid-template-columns: minmax(150px, 0.8fr) minmax(170px, 1fr);
        gap: 0 18px;
        border-top: 1px solid var(--line);
        background: #f7f7f4;
    }

    .tile-library__hero,
    .tile-library__gallery {
        grid-column: 1;
    }

    .tile-library__series,
    .tile-library__detail h3,
    .tile-library__detail dl,
    .tile-library__apply-note {
        grid-column: 2;
    }

    .tile-library__series {
        grid-row: 1;
        margin-top: 0;
    }

    .tile-library__detail h3 {
        grid-row: 2;
    }

    .tile-library__detail dl {
        grid-row: 3 / span 2;
    }

    .tile-library__apply-note {
        grid-row: 5;
    }

    .tile-library__footer {
        position: sticky;
        z-index: 3;
        bottom: 0;
        padding: 12px 18px max(12px, env(safe-area-inset-bottom));
    }
}

@media (max-width: 560px) {
    .viewport-panel {
        height: 52svh;
        min-height: 360px;
    }

    .brand-lockup {
        top: 17px;
        left: 16px;
        gap: 10px;
    }

    .brand-lockup__name {
        font-size: 17px;
    }

    .backend-badge {
        min-height: 25px;
        padding: 3px 7px;
        font-size: 9px;
    }

    .viewport-help {
        display: none;
    }

    .viewport-button {
        left: 14px;
        bottom: 14px;
        min-height: 40px;
    }

    .config-panel {
        padding: 24px 18px 28px;
    }

    .config-panel h1 {
        font-size: 27px;
    }

    .range-field__controls {
        grid-template-columns: minmax(90px, 1fr) 100px;
        gap: 12px;
    }

    .config-section--primary .range-field {
        grid-template-columns: 1fr;
        gap: 8px;
        margin-top: 18px;
    }

    .config-section--primary .range-field__controls,
    .config-section--water .range-field__controls {
        grid-template-columns: minmax(90px, 1fr) 100px;
        gap: 12px;
    }

    .material-picker {
        grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
        gap: 8px;
    }

    .section-heading--action {
        align-items: flex-start;
    }

    .section-heading__actions {
        max-width: 170px;
    }

    .section-heading__actions .button {
        flex: 1 1 100%;
    }

    .tile-library__filter-grid,
    .tile-library__detail {
        grid-template-columns: 1fr;
    }

    .tile-library__hero,
    .tile-library__gallery,
    .tile-library__series,
    .tile-library__detail h3,
    .tile-library__detail dl,
    .tile-library__apply-note {
        grid-column: 1;
        grid-row: auto;
    }

    .tile-library__hero {
        max-width: 310px;
        width: 100%;
        margin-inline: auto;
    }

    .tile-library__footer {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .tile-library__error {
        grid-column: 1 / -1;
        margin: 0;
    }

}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
