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

html {
    height: 100%;
}

body {
    min-height: 100%;
    background: #08080a;
    font-family: 'Georgia', serif;
    color: #6b7280;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
    padding-top: max(1.5rem, calc(env(safe-area-inset-top) + 0.75rem));
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.container {
    max-width: 400px;
    width: 100%;
    text-align: center;
    padding-bottom: 2rem;
}

h1 {
    font-size: 1.1rem;
    font-weight: 400;
    letter-spacing: 0.5em;
    text-transform: uppercase;
    color: #e5e7eb;
    margin-bottom: 1.25rem;
}

.visualizer {
    height: 120px;
    margin-bottom: 1.25rem;
    position: relative;
}

.visualizer canvas {
    width: 100%;
    height: 100%;
}

.control-section {
    margin-bottom: 1.25rem;
}

.control-label {
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #9ca3af;
    margin-bottom: 0.75rem;
    display: block;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    max-width: 280px;
    height: 20px;
    background: transparent;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 1px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #e5e7eb;
    border-radius: 50%;
    cursor: pointer;
    margin-top: -8px;
    border: none;
}

input[type="range"]::-moz-range-track {
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 1px;
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #e5e7eb;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.control-labels {
    display: flex;
    justify-content: space-between;
    max-width: 280px;
    margin: 0.5rem auto 0;
    font-size: 0.55rem;
    letter-spacing: 0.1em;
    color: #d1d5db;
}

.control-group {
    margin-bottom: 1.5rem;
}

.control-group-label {
    font-size: 0.5rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: #4b5563;
    margin-bottom: 1rem;
    display: block;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.5rem;
}

.play-button {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #e5e7eb;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1rem auto;
}

.play-button:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.5);
}

.play-button svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.click-prompt {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #08080a;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    transition: opacity 1s ease-out;
}

.click-prompt.hidden {
    opacity: 0;
    pointer-events: none;
}

.click-prompt h2 {
    font-size: 1.1rem;
    font-weight: 400;
    letter-spacing: 0.5em;
    text-transform: uppercase;
    color: #e5e7eb;
    margin-bottom: 2rem;
}

.click-prompt p {
    font-size: 0.7rem;
    letter-spacing: 0.25em;
    color: #9ca3af;
    animation: breathe 4s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Three clusters, one per line, captions in a right-aligned column. Twenty-four
   dots in a single row was unreadable on a phone and this is mostly why. */
.layer-indicators {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    column-gap: 0.7rem;
    row-gap: 0.5rem;
    margin: 0 auto 1.25rem;
    max-width: 290px;
}

.layer-cluster-label {
    font-size: 0.45rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: #4b5563;
    text-align: right;
    white-space: nowrap;
}

.layer-cluster-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.layer-dot {
    width: 10px;
    height: 10px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.5s;
    cursor: pointer;
}

/* A layer the current palette does not build. Visible so the row keeps its shape,
   but it is not a control. */
.layer-dot.absent {
    background: rgba(255, 255, 255, 0.04);
    cursor: default;
    opacity: 0.45;
}

.layer-dot.absent:hover {
    background: rgba(255, 255, 255, 0.04);
    transform: none;
}

.layer-dot:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.2);
}

.layer-dot.active {
    background: rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.layer-dot.muted {
    background: rgba(255, 100, 100, 0.3);
    opacity: 0.5;
}

.layer-dot.muted.active {
    background: rgba(255, 100, 100, 0.4);
    box-shadow: 0 0 8px rgba(255, 100, 100, 0.2);
}

.layer-name {
    min-height: 1.1em;
    font-size: 0.55rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #6b7280;
    margin-top: -0.75rem;
    margin-bottom: 1rem;
}

.layer-dot:focus-visible {
    outline: 1px solid rgba(255, 255, 255, 0.6);
    outline-offset: 3px;
}

.section-line {
    min-height: 1.1em;
    font-size: 0.55rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: #4b5563;
    margin-top: -0.5rem;
    margin-bottom: 1.25rem;
}

.chip-row {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.chip {
    font-family: inherit;
    font-size: 0.55rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #9ca3af;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    transition: all 0.3s;
}

.chip:hover {
    border-color: rgba(255, 255, 255, 0.35);
    color: #e5e7eb;
}

.chip.active {
    border-color: rgba(255, 255, 255, 0.5);
    color: #e5e7eb;
    background: rgba(255, 255, 255, 0.05);
}

.sleep-status {
    font-size: 0.55rem;
    letter-spacing: 0.15em;
    color: #6b7280;
    min-height: 1.1em;
}

@media (prefers-reduced-motion: reduce) {
    .click-prompt p { animation: none; }
    .visualizer { display: none; }
}

.divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
    margin: 1.5rem auto;
    max-width: 200px;
}
    

/* ---- title bar and the help button ---- */
.titlebar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
}

.titlebar h1 {
    margin-bottom: 0;
}

.help-button {
    position: absolute;
    right: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: transparent;
    color: #6b7280;
    font-family: inherit;
    font-size: 0.7rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.3s;
}

.help-button:hover {
    border-color: rgba(255, 255, 255, 0.4);
    color: #e5e7eb;
}

/* ---- help modal ---- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(4, 4, 6, 0.88);
    z-index: 200;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1.5rem 1rem;
    padding-top: max(1.5rem, calc(env(safe-area-inset-top) + 1rem));
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal {
    background: #0c0c10;
    border: 1px solid rgba(255, 255, 255, 0.08);
    max-width: 440px;
    width: 100%;
    text-align: left;
    padding: 1.5rem;
    margin: auto 0;
}

.modal:focus {
    outline: none;
}

.modal-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 0.75rem;
}

.modal-head h2 {
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: #e5e7eb;
}

.modal-close {
    background: transparent;
    border: none;
    color: #6b7280;
    font-family: inherit;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.2rem;
}

.modal-close:hover {
    color: #e5e7eb;
}

.modal-body h3 {
    font-size: 0.55rem;
    font-weight: 400;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: #9ca3af;
    margin: 1.5rem 0 0.6rem;
}

.modal-body p {
    font-size: 0.8rem;
    line-height: 1.65;
    color: #8b93a1;
    margin-bottom: 0.7rem;
}

.modal-body em {
    color: #d1d5db;
    font-style: normal;
}

.modal-body code {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 0.72rem;
    color: #d1d5db;
}

.help-button:focus-visible,
.modal-close:focus-visible,
.chip:focus-visible {
    outline: 1px solid rgba(255, 255, 255, 0.6);
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    .layer-dot, .help-button, .chip { transition: none; }
}
