/* Breathing tab (Keystone): one featured world with a Begin that begins, the twelve worlds
   as artwork, the way into Sukha sessions, and two preferences. Each world brings its own
   accent as --world-accent (r, g, b); the chosen world wears it on its frame.
   Shell, tokens (--hub-card-r, --hub-card-fill) and shared patterns: keystone-hub.css. */
#serenity-hub-panel .breath-lib {
    --world-accent: var(--sb-mint-rgb);
    display: flex;
    flex-direction: column;
    gap: 26px;
    padding: 0;
    color: var(--sb-text);
    font-family: var(--sb-font-text);
}

#serenity-hub-panel .breath-lib__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: rgb(var(--world-accent));
    font: 600 var(--sb-fs-label) / 1.45 var(--sb-font-display);
    letter-spacing: var(--sb-track-label);
    text-transform: uppercase;
}

#serenity-hub-panel .breath-lib__eyebrow::before {
    content: '';
    flex: none;
    width: 7px;
    height: 7px;
    border-radius: 2px;
    background: currentColor;
}

/* ---- The featured world --------------------------------------------------------- */
#serenity-hub-panel .breath-lib__hero {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    min-height: 280px;
    overflow: hidden;
    border-radius: var(--hub-card-r);
    border: 1px solid var(--sb-line);
    background: var(--hub-card-fill);
}

#serenity-hub-panel .breath-lib__hero-art {
    position: relative;
    min-height: 220px;
    background-color: rgba(var(--sb-night-rgb), 0.8);
    background-position: center;
    background-size: cover;
}

/* The art fades into the panel so the words sit on night, never on the picture. */
#serenity-hub-panel .breath-lib__hero-art::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(19, 16, 44, 0) 55%, rgba(19, 16, 44, 0.96) 100%);
}

#serenity-hub-panel .breath-lib__hero-body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 14px;
    padding: 28px 30px 28px 14px;
}

/* The featured world's line is a sentence, so it reads in sentence case. */
#serenity-hub-panel .breath-lib__hero .breath-lib__eyebrow {
    align-items: baseline;
    font: 600 0.8125rem / 1.45 var(--sb-font-text);
    letter-spacing: 0.01em;
    text-transform: none;
}

#serenity-hub-panel .breath-lib__hero .breath-lib__eyebrow::before {
    position: relative;
    top: -1px;
}

#serenity-hub-panel .breath-lib__name {
    margin: 0;
    color: var(--sb-text);
    font: 700 var(--sb-fs-title) / 1.1 var(--sb-font-display);
    letter-spacing: -0.01em;
}

#serenity-hub-panel .breath-lib__description {
    margin: 0;
    max-width: 44ch;
    color: var(--sb-text-muted);
    font: 500 var(--sb-fs-body) / 1.6 var(--sb-font-text);
    text-wrap: pretty;
}

/* The shape of one breath: each phase a cell as long as it lasts. */
#serenity-hub-panel .breath-rhythm {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

#serenity-hub-panel .breath-rhythm__step {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    gap: 7px;
    min-width: 40px;
    padding-top: 13px;
    background: linear-gradient(rgba(var(--world-accent), 0.9), rgba(var(--world-accent), 0.9)) 0 0 / 100% 6px no-repeat;
    border-radius: 2px;
    color: var(--sb-text-faint);
    font: 600 0.5625rem / 1 var(--sb-font-display);
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

/* Holds and rests are quieter cells. */
#serenity-hub-panel .breath-rhythm__step[data-phase='1'],
#serenity-hub-panel .breath-rhythm__step[data-phase='3'] {
    background-image: linear-gradient(rgba(var(--world-accent), 0.3), rgba(var(--world-accent), 0.3));
}

#serenity-hub-panel .breath-rhythm__step b {
    font-weight: 600;
}

#serenity-hub-panel .breath-rhythm__step em {
    color: var(--sb-text);
    font: 600 1.125rem / 1 var(--sb-font-display);
    font-style: normal;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
    text-transform: none;
}

#serenity-hub-panel .breath-rhythm__step small {
    margin-left: 2px;
    color: var(--sb-text-faint);
    font: 600 0.6875rem / 1 var(--sb-font-display);
}

#serenity-hub-panel .breath-lib__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 18px;
    margin-top: 10px;
}

/* Begin is the tab's one primary action; while a practice runs it becomes a quiet Stop. */
#serenity-hub-panel .breath-lib__begin {
    min-width: 200px;
}

#serenity-hub-panel .breath-lib__begin.is-active {
    border-color: var(--sb-line-strong);
    background: rgba(var(--sb-cream-rgb), 0.04);
    color: var(--sb-text);
    box-shadow: none;
}

#serenity-hub-panel .breath-lib__cycle {
    color: var(--sb-text-faint);
    font: 500 var(--sb-fs-small) / 1.4 var(--sb-font-text);
    font-variant-numeric: tabular-nums;
}

/* ---- Fast breathing: the safety note, read once before the first strong practice ---- */
#serenity-hub-panel .breath-lib__caution {
    margin-top: 14px;
    max-width: 62ch;
    padding: 12px 14px;
    border-radius: var(--sb-r-sm);
    border: 1px solid rgba(var(--sb-warning-rgb), 0.35);
    background: rgba(var(--sb-warning-rgb), 0.06);
}

#serenity-hub-panel .breath-lib__caution p {
    display: flex;
    gap: 10px;
    margin: 0;
    color: var(--sb-text-muted);
    font: 500 var(--sb-fs-small) / 1.6 var(--sb-font-text);
}

#serenity-hub-panel .breath-lib__caution p .cs-icon {
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--sb-warning);
}

#serenity-hub-panel .breath-lib__caution .breath-note__lead {
    color: var(--sb-text);
    font-weight: 600;
}

/* The list sits under the lead's words, past its icon. */
#serenity-hub-panel .breath-lib__caution .breath-note__points {
    display: grid;
    gap: 6px;
    margin: 10px 0 0;
    padding: 0 0 0 25px;
    color: var(--sb-text-muted);
    font: 500 var(--sb-fs-small) / 1.5 var(--sb-font-text);
    list-style: disc outside;
}

#serenity-hub-panel .breath-lib__caution .breath-note__points li {
    margin: 0;
    padding-left: 2px;
}

#serenity-hub-panel .breath-lib__caution .breath-note__points li::marker {
    color: rgba(var(--sb-warning-rgb), 0.85);
}

#serenity-hub-panel .breath-lib__ack {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(var(--sb-warning-rgb), 0.22);
    color: var(--sb-text);
    font: 600 var(--sb-fs-small) / 1.35 var(--sb-font-text);
    cursor: pointer;
}

#serenity-hub-panel .breath-lib__ack[hidden] { display: none; }

#serenity-hub-panel .breath-lib__ack input {
    position: relative;
    flex: none;
    width: 22px;
    height: 22px;
    margin: 0;
    border-radius: 6px;
    border: 1.5px solid rgba(var(--sb-warning-rgb), 0.7);
    background: transparent;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

#serenity-hub-panel .breath-lib__ack input:checked {
    border-color: var(--sb-warning);
    background: var(--sb-warning);
}

#serenity-hub-panel .breath-lib__ack input:checked::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 6.5px;
    width: 5px;
    height: 10px;
    border: solid var(--sb-keystone-ink);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

#serenity-hub-panel .breath-lib__wellness {
    margin: 0;
    color: var(--sb-text-faint);
    font: 500 var(--sb-fs-small) / 1.6 var(--sb-font-text);
}

/* ---- A session owns the rhythm ------------------------------------------------------ */
#serenity-hub-panel .breath-lib__notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border-radius: var(--hub-row-r);
    border: 1px solid rgba(var(--sb-mint-rgb), 0.3);
    background: rgba(var(--sb-mint-rgb), 0.06);
}

#serenity-hub-panel .breath-lib__notice p {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    color: var(--sb-text-muted);
    font: 500 var(--sb-fs-small) / 1.5 var(--sb-font-text);
}

#serenity-hub-panel .breath-lib__notice .cs-icon {
    flex: none;
    color: var(--sb-mint);
}

/* ---- The twelve worlds -------------------------------------------------------------- */
#serenity-hub-panel .breath-lib__heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 14px;
    margin: 0 0 16px;
    color: var(--sb-text);
    font: 600 var(--sb-fs-heading) / 1.2 var(--sb-font-display);
}

#serenity-hub-panel .breath-lib__heading small {
    color: var(--sb-text-faint);
    font: 500 var(--sb-fs-small) / 1.4 var(--sb-font-text);
}

#serenity-hub-panel .breath-lib__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 16px 14px;
}

#serenity-hub-panel .breath-world {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin: 0;
    padding: 0;
    overflow: visible;
    border-radius: var(--hub-card-r);
    border: 1px solid var(--sb-line);
    background: var(--hub-card-fill);
    color: inherit;
    text-align: left;
    cursor: pointer;
    transition:
        border-color var(--sb-dur-2) var(--sb-ease-lock),
        background var(--sb-dur-2) var(--sb-ease-lock);
}

#serenity-hub-panel .breath-world__art {
    display: block;
    aspect-ratio: 16 / 10;
    border-radius: calc(var(--hub-card-r) - 1px) calc(var(--hub-card-r) - 1px) 0 0;
    background-color: rgba(var(--sb-night-rgb), 0.8);
    background-position: center;
    background-size: cover;
}

#serenity-hub-panel .breath-world__name {
    padding: 12px 14px 0;
    color: var(--sb-text);
    font: 600 0.8125rem / 1.25 var(--sb-font-display);
}

#serenity-hub-panel .breath-world__meta {
    padding: 7px 14px 14px;
    color: var(--sb-text-faint);
    font: 500 0.75rem / 1.3 var(--sb-font-text);
    font-variant-numeric: tabular-nums;
}

#serenity-hub-panel .breath-world:hover:not(:disabled) {
    border-color: var(--sb-line-strong);
    background:
        linear-gradient(180deg, rgba(var(--sb-cream-rgb), 0.06), rgba(var(--sb-cream-rgb), 0.02)),
        rgba(9, 8, 24, 0.32);
}

/* The chosen world: its own light on the frame. */
#serenity-hub-panel .breath-world[aria-pressed='true'] {
    border-color: rgba(var(--world-accent), 0.55);
    background:
        linear-gradient(180deg, rgba(var(--world-accent), 0.1), rgba(var(--world-accent), 0.02)),
        rgba(9, 8, 24, 0.32);
    box-shadow: none;
}

#serenity-hub-panel .breath-world:disabled {
    opacity: 0.5;
    cursor: default;
}

/* A world not found yet: shown, as a promise of where it is found. The same language as a
   locked theme: the art drained of colour, a lock on its corner, the place instead of the rhythm. */
#serenity-hub-panel .breath-world.is-locked .breath-world__art { filter: saturate(0.22) brightness(0.72); }
#serenity-hub-panel .breath-world.is-locked .breath-world__name { color: var(--sb-text-muted); }
#serenity-hub-panel .breath-world.is-locked .breath-world__meta { color: var(--sb-text-faint); font-style: italic; }
#serenity-hub-panel .breath-world__lock {
    position: absolute;
    top: 10px;
    right: 10px;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border: 1px solid var(--sb-line-strong);
    border-radius: 8px;
    background: var(--hub-sheet);
    color: var(--sb-text);
}
#serenity-hub-panel .breath-world__lock svg { width: 14px; height: 14px; }
/* Just found: the world's own light on its frame, and a word that it is new. */
#serenity-hub-panel .breath-world.is-new { border-color: rgba(var(--world-accent), 0.6); }
#serenity-hub-panel .breath-world__new {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(var(--world-accent), 0.9);
    color: #120f1f;
    font: 700 0.62rem / 1.4 var(--sb-font-display);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    box-shadow: 0 0 16px rgba(var(--world-accent), 0.45);
}

#serenity-hub-panel .breath-lib__found-note {
    max-width: 62ch;
    margin: 14px 0 0;
    color: var(--sb-text-faint);
    font: 500 var(--sb-fs-small) / 1.55 var(--sb-font-text);
}

/* The hero previews a world not found yet: its picture behind glass, the way to it below. */
#serenity-hub-panel .breath-lib__hero-seal {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 1;
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--sb-line-strong);
    border-radius: 999px;
    background: rgba(13, 11, 30, 0.78);
    color: var(--sb-text);
    font: 600 0.72rem / 1.2 var(--sb-font-display);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
    transform: translate(-50%, -50%);
}
#serenity-hub-panel .breath-lib__hero-seal svg { width: 15px; height: 15px; }
#serenity-hub-panel .breath-lib__hero.is-locked .breath-lib__hero-seal { display: inline-flex; }
#serenity-hub-panel .breath-lib__hero.is-locked .breath-lib__hero-art { filter: saturate(0.3) brightness(0.75); }
#serenity-hub-panel .breath-lib__hero.is-locked .breath-lib__begin:disabled {
    opacity: 1;
    border-color: var(--sb-line-strong);
    background: transparent;
    color: var(--sb-text-muted);
    cursor: default;
}
#serenity-hub-panel .breath-lib__hero.is-locked .breath-lib__cycle { max-width: 34ch; line-height: 1.45; }

#serenity-hub-panel .breath-world:focus-visible,
#serenity-hub-panel .breath-lib button:focus-visible {
    outline: 2px solid rgba(var(--sb-cream-rgb), 0.82);
    outline-offset: 3px;
}

/* ---- The way into Sukha sessions ---------------------------------------------------- */
#serenity-hub-panel .breath-lib__sukha {
    --world-accent: var(--sb-mint-rgb);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 24px 26px;
    border-radius: var(--hub-card-r);
    border: 1px solid rgba(var(--sb-mint-rgb), 0.22);
    background:
        radial-gradient(70% 140% at 0% 0%, rgba(var(--sb-mint-rgb), 0.1), transparent 70%),
        var(--hub-card-fill);
}

#serenity-hub-panel .breath-lib__sukha h3 {
    margin: 12px 0 8px;
    color: var(--sb-text);
    font: 700 1.375rem / 1.15 var(--sb-font-display);
}

#serenity-hub-panel .breath-lib__sukha p {
    max-width: 52ch;
    margin: 0;
    color: var(--sb-text-muted);
    font: 500 var(--sb-fs-small) / 1.6 var(--sb-font-text);
}

#serenity-hub-panel .breath-open-sessions {
    flex: none;
}

/* ---- Preferences ------------------------------------------------------------------- */
#serenity-hub-panel .breath-lib__settings {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 28px;
    padding: 22px 0 0;
    border-top: 1px solid var(--sb-line);
}

#serenity-hub-panel .breath-lib__switch {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    cursor: pointer;
}

#serenity-hub-panel .breath-lib__switch b {
    display: block;
    color: var(--sb-text);
    font: 600 var(--sb-fs-body) / 1.3 var(--sb-font-text);
}

#serenity-hub-panel .breath-lib__switch small {
    display: block;
    margin-top: 4px;
    color: var(--sb-text-faint);
    font: 500 0.75rem / 1.5 var(--sb-font-text);
}

#serenity-hub-panel .breath-lib__keys {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 18px;
    margin: 2px 0 0;
}

#serenity-hub-panel .breath-lib__keys .sb-hints {
    gap: 8px 18px;
}

@media (max-width: 700px) {
    #serenity-hub-panel .breath-lib { gap: 20px; }
    #serenity-hub-panel .breath-lib__hero { grid-template-columns: minmax(0, 1fr); }
    #serenity-hub-panel .breath-lib__hero-art { min-height: 160px; }

    #serenity-hub-panel .breath-lib__hero-art::after {
        background: linear-gradient(180deg, rgba(19, 16, 44, 0) 50%, rgba(19, 16, 44, 0.96) 100%);
    }

    #serenity-hub-panel .breath-lib__hero-body { padding: 4px 18px 20px; }
    #serenity-hub-panel .breath-rhythm__step { min-width: 46px; letter-spacing: 0.1em; }
    #serenity-hub-panel .breath-lib__begin { flex: 1 1 auto; }
    #serenity-hub-panel .breath-lib__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
    #serenity-hub-panel .breath-lib__sukha { flex-direction: column; align-items: stretch; gap: 16px; padding: 18px; }
    #serenity-hub-panel .breath-lib__settings { grid-template-columns: minmax(0, 1fr); }
    #serenity-hub-panel .breath-lib__notice { flex-direction: column; align-items: flex-start; }
}

@media (hover: none) and (pointer: coarse) {
    #serenity-hub-panel .breath-lib__keys { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    #serenity-hub-panel .breath-world {
        transition-duration: 1ms !important;
    }
}
