/* Follow the shared shell class, including its touch-landscape breakpoint. */
.sleep-mobile { display: none; }

.als-mobile-shell .tracker-page.sleep-mobile-ready {
    display: block;
    height: auto;
    overflow: visible;
    padding: 16px 12px;
}

.als-mobile-shell .sleep-mobile-ready > .tracker-grid { display: none; }

.als-mobile-shell .sleep-mobile {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: min(100%, 720px);
    margin: 0 auto;
    color: var(--text-primary);
}

.als-mobile-shell .sleep-mobile [hidden] { display: none !important; }

.als-mobile-shell .sleep-mobile-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.als-mobile-shell .sleep-mobile h1 { margin: 0; font-size: 1.25rem; }
.als-mobile-shell .sleep-mobile h2 { margin: 0; font-size: 1rem; }

.als-mobile-shell .sleep-mobile :is(.panel-action, .period-arrow) {
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
    font-size: 0.8125rem;
    line-height: 1.4;
    white-space: normal;
}

.als-mobile-shell .sleep-mobile .period-switcher { gap: 8px; padding: 4px; margin: 0 0 16px; }
.als-mobile-shell .sleep-mobile .period-title { font-size: 0.8125rem; }
.als-mobile-shell .sleep-mobile .period-dates { font-size: 0.9375rem; line-height: 1.5; }
.als-mobile-shell .sleep-mobile .period-arrow { font-size: 1.5rem; }

.als-mobile-shell .sleep-mobile-figure { margin: 0; }
.als-mobile-shell .sleep-mobile-figure figcaption { color: var(--text-secondary); font-size: 0.8125rem; margin-bottom: 8px; }

.als-mobile-shell .sleep-mobile-chart {
    --sleep-plot-height: 224px;
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 4px;
}

.als-mobile-shell .sleep-mobile-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: var(--sleep-plot-height);
    margin-top: 32px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-align: right;
    line-height: 1;
}

.als-mobile-shell .sleep-mobile-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 3px;
    margin: 0;
    padding: 0;
    list-style: none;
    background: repeating-linear-gradient(to top, transparent 0, transparent calc(25% - 1px), var(--soft-white-line) calc(25% - 1px), var(--soft-white-line) 25%);
    background-size: 100% var(--sleep-plot-height);
    background-position: left top 32px;
    background-repeat: no-repeat;
}

.als-mobile-shell .sleep-mobile-day { min-width: 0; }
.als-mobile-shell .sleep-mobile-day-visual { display: grid; grid-template-rows: 32px var(--sleep-plot-height) 44px; }

.als-mobile-shell .sleep-mobile-value {
    align-self: center;
    text-align: center;
    font-size: 0.6875rem;
    line-height: 1.3;
    overflow-wrap: normal;
}

.als-mobile-shell .sleep-mobile-track { display: flex; align-items: flex-end; justify-content: center; }
.als-mobile-shell .sleep-mobile-fill,
.als-mobile-shell .sleep-mobile-swatch {
    background: linear-gradient(to top, var(--accent-dark), var(--accent-bright));
    border: 1px solid var(--accent-bright);
}

.als-mobile-shell .sleep-mobile-fill { display: block; width: min(72%, 38px); }
.als-mobile-shell .sleep-mobile-no-record { color: var(--text-secondary); font-size: 1rem; line-height: 1; }
.als-mobile-shell .sleep-mobile-date { display: flex; flex-direction: column; justify-content: center; gap: 3px; font-size: 0.75rem; line-height: 1.2; text-align: center; }
.als-mobile-shell .sleep-mobile-date > span:first-child { color: var(--text-secondary); }
.als-mobile-shell .sleep-mobile-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; font-size: 0.8125rem; }
.als-mobile-shell .sleep-mobile-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.als-mobile-shell .sleep-mobile-swatch { display: inline-block; width: 12px; height: 14px; }
.als-mobile-shell .sleep-mobile-missing { font-style: normal; }
.als-mobile-shell .sleep-mobile-note,
.als-mobile-shell .sleep-mobile-status { margin: 10px 0 0; color: var(--text-secondary); font-size: 0.8125rem; line-height: 1.5; }
.als-mobile-shell .sleep-mobile-status { min-height: 3em; }

.als-mobile-shell .sleep-mobile-sections { display: grid; gap: 8px; }
.als-mobile-shell .sleep-mobile-section { min-width: 0; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); }
.als-mobile-shell .sleep-mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-height: 56px;
    padding: 14px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.als-mobile-shell .sleep-mobile-toggle::after { content: "+"; color: var(--accent-bright); font-size: 1.25rem; }
.als-mobile-shell .sleep-mobile-toggle[aria-expanded="true"]::after { content: "−"; }
.als-mobile-shell .sleep-mobile-toggle:hover { background: var(--panel-hover); }
.als-mobile-shell .sleep-mobile-section-content { padding: 0 14px 14px; }
.als-mobile-shell .sleep-mobile-section-content > .sleep-mobile-note { margin-top: 0; }
.als-mobile-shell .sleep-mobile-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.als-mobile-shell .sleep-mobile-metrics:empty { display: none; }
.als-mobile-shell .sleep-mobile-metrics > div { display: flex; flex-direction: column; gap: 8px; padding: 12px; background: var(--background-secondary); border: 1px solid var(--soft-white-line); }
.als-mobile-shell .sleep-mobile-metrics span { color: var(--text-secondary); font-size: 0.8125rem; }
.als-mobile-shell .sleep-mobile-metrics strong { font-size: 1.0625rem; }

.als-mobile-shell .sleep-mobile .system-panel { padding: 14px; overflow: visible; }
.als-mobile-shell .sleep-mobile .panel-heading { flex-wrap: wrap; gap: 8px; }
.als-mobile-shell .sleep-mobile .panel-label { font-size: 0.875rem; }
.als-mobile-shell .sleep-mobile .sleep-log { overflow: visible; }
.als-mobile-shell .sleep-mobile .log-row { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 6px 10px; min-height: 64px; padding: 10px; }
.als-mobile-shell .sleep-mobile .log-row > span { grid-row: 1 / 3; font-size: 0.75rem; }
.als-mobile-shell .sleep-mobile .log-row > strong { font-size: 0.9375rem; }
.als-mobile-shell .sleep-mobile .log-row > small { grid-column: 2; grid-row: 2; font-size: 0.75rem; white-space: normal; }
.als-mobile-shell .sleep-mobile .log-row > b { grid-column: 3; grid-row: 1 / 3; max-width: 80px; font-size: 0.75rem; overflow-wrap: anywhere; white-space: normal; }
.als-mobile-shell .sleep-mobile .goal-metric-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.als-mobile-shell .sleep-mobile .goal-metric > span { font-size: 0.8125rem; }
.als-mobile-shell .sleep-mobile .goal-metric > strong { font-size: 1rem; }
.als-mobile-shell .sleep-mobile :focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 3px; }

/* Touch sizing and viewport bounds for the original Sleep editors. */
.als-mobile-shell #sleepModal { padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.als-mobile-shell #sleepModal .home-modal-card {
    width: min(620px, 100%);
    max-height: calc(100svh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px);
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px);
    padding: 16px;
    border-radius: 12px;
}
.als-mobile-shell #sleepModal :is(button, input, select) { min-width: 44px; min-height: 44px; }
.als-mobile-shell #sleepModal :is(input, textarea, select) { font-size: 1rem; }
.als-mobile-shell #sleepModal :is(.home-form-field, button) { font-size: 0.875rem; }
.als-mobile-shell #sleepModal .home-modal-actions { flex-wrap: wrap; }
.als-mobile-shell #sleepModal :focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }
