.dream-book {
    --dream-sticky-top: calc(var(--wp-admin--admin-bar--height, 0px) + 64px);
    --dream-toolbar-h: 112px;
    --dream-gutter: 16px;
    background: transparent !important;
    border: 0 !important;
    padding: 0 !important;
}

.dream-book [hidden] {
    display: none !important;
}

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

.dream-book a,
.dream-book button {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.dream-book a:focus-visible,
.dream-book button:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Hero */
.dream-hero {
    margin-bottom: 18px;
}

.dream-book .dream-title {
    margin: 0 0 10px;
    text-wrap: balance;
}

.dream-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--muted-foreground);
    font-variant-numeric: tabular-nums;
}

.dream-intro {
    position: relative;
    font-size: 15.5px;
    line-height: 1.7;
    color: var(--text-body);
}

.dream-intro p {
    margin: 0 0 12px;
}

.dream-intro p:last-child {
    margin-bottom: 0;
}

.dream-intro-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 40px;
    margin-top: 2px;
    padding: 0;
    border: 0;
    background: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--link);
    cursor: pointer;
}

.dream-intro-toggle .mp-icon {
    transition: transform 0.2s ease;
}

.dream-intro-toggle[aria-expanded="true"] .mp-icon {
    transform: rotate(180deg);
}

/* Toolbar: search + alphabet */
.dream-toolbar {
    position: sticky;
    top: var(--dream-sticky-top);
    z-index: 20;
    margin: 0 0 20px;
    padding: 8px 0 0;
    background: var(--background);
}

.dream-toolbar::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 12px;
    background: linear-gradient(rgba(9, 9, 11, 0.07), transparent);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.dream-toolbar.is-stuck {
    box-shadow: 0 1px 0 var(--border);
}

.dream-toolbar.is-stuck::after {
    opacity: 1;
}

html.dream-toolbar-stuck .site-header::after {
    opacity: 0;
}

html.dark .dream-toolbar::after {
    background: linear-gradient(rgba(0, 0, 0, 0.45), transparent);
}

.dream-search {
    position: relative;
    display: flex;
    align-items: center;
    margin: 0;
}

.dream-search-icon {
    position: absolute;
    left: 14px;
    color: var(--muted-foreground);
    pointer-events: none;
}

.dream-book input.dream-search-input {
    width: 100%;
    height: 46px;
    margin: 0;
    padding: 0 46px 0 42px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--muted);
    box-shadow: none;
    font-family: var(--font-sans);
    font-size: 16px;
    font-style: normal;
    color: var(--foreground);
    -webkit-appearance: none;
    appearance: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.dream-book input.dream-search-input::placeholder {
    color: var(--muted-foreground);
    opacity: 1;
}

.dream-book input.dream-search-input:focus {
    outline: none;
    background: var(--background);
    border-color: #a1a1aa;
    box-shadow: 0 0 0 3px rgba(161, 161, 170, 0.25);
}

.dream-book input.dream-search-input::-webkit-search-cancel-button,
.dream-book input.dream-search-input::-webkit-search-decoration {
    -webkit-appearance: none;
}

.dream-search:focus-within .dream-search-icon {
    color: var(--foreground);
}

.dream-search-clear {
    position: absolute;
    right: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted-foreground);
    cursor: pointer;
}

.dream-search-clear:hover,
.dream-search-clear:active {
    background: var(--border);
    color: var(--foreground);
}

.dream-letters {
    position: relative;
    display: flex;
    gap: 6px;
    margin: 0 calc(var(--dream-gutter) * -1);
    padding: 8px var(--dream-gutter);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scroll-padding-inline: var(--dream-gutter);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.dream-letters::-webkit-scrollbar {
    display: none;
}

.dream-letter {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    scroll-snap-align: start;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    color: var(--foreground) !important;
    text-decoration: none !important;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

a.dream-letter:hover {
    background: var(--muted);
}

a.dream-letter:active {
    transform: scale(0.96);
}

.dream-letter.is-active {
    background: var(--foreground);
    border-color: var(--foreground);
    color: var(--background) !important;
}

a.dream-letter.is-active:hover {
    background: var(--foreground);
}

.dream-letter.is-empty {
    border-color: transparent;
    color: var(--muted-foreground) !important;
    opacity: 0.45;
    pointer-events: none;
}

.dream-status {
    margin: -8px 0 12px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--muted-foreground);
}

.dream-status:empty {
    display: none;
}

/* Shortcut blocks */
.dream-block {
    margin: 0 0 26px;
}

.dream-book .dream-label {
    margin: 0 0 10px;
    padding: 0;
    border: 0;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted-foreground);
}

.dream-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.dream-chip {
    display: inline-flex;
    align-items: center;
    height: 36px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--background);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    color: var(--foreground) !important;
    text-decoration: none !important;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.dream-chip:hover {
    background: var(--muted);
    border-color: var(--muted-foreground);
}

/* Catalog */
.dream-book .dream-catalog-title {
    margin: 0 0 16px;
    padding: 18px 0 0;
    border-top: 1px solid var(--border);
    font-family: var(--font-sans);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--foreground);
}

.dream-book.is-searching .dream-catalog-title {
    display: none;
}

.dream-groups {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    align-items: start;
    gap: 14px;
}

.dream-group {
    scroll-margin-top: calc(var(--dream-sticky-top) + var(--dream-toolbar-h));
    padding: 12px 6px 6px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--card);
}

.dream-book .dream-group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 4px;
    padding: 0 10px 8px;
    border-bottom: 1px solid var(--border);
    font-family: var(--font-sans);
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--foreground);
}

.dream-group-count {
    min-width: 26px;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--muted);
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    color: var(--muted-foreground);
    font-variant-numeric: tabular-nums;
}

.dream-book .dream-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.dream-book .dream-item {
    position: relative;
    margin: 0;
    padding: 0;
    list-style: none;
}

.dream-link {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--foreground) !important;
    text-decoration: none !important;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.dream-link:hover {
    background: var(--muted);
    color: var(--primary) !important;
}

.dream-link-name {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}

.dream-link-name mark {
    padding: 0 1px;
    border-radius: 3px;
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
}

.dream-link-chevron {
    color: var(--muted-foreground);
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.dream-link:hover .dream-link-chevron {
    opacity: 1;
    transform: translateX(2px);
}

.dream-badge {
    flex-shrink: 0;
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--primary-light);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--primary);
}

.dream-empty {
    padding: 40px 16px;
    text-align: center;
    color: var(--muted-foreground);
}

.dream-empty-icon {
    margin-bottom: 10px;
    opacity: 0.6;
}

.dream-empty-title {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 600;
    color: var(--foreground);
    overflow-wrap: anywhere;
}

.dream-empty-text {
    margin: 0 0 18px;
    font-size: 14px;
}

.dream-empty-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.dream-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--background);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    color: var(--foreground) !important;
    text-decoration: none !important;
    cursor: pointer;
}

.dream-btn:hover {
    background: var(--muted);
}

.dream-btn--primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff !important;
}

.dream-btn--primary:hover {
    border-color: var(--primary-hover);
    background: var(--primary-hover);
}

.dream-top {
    position: fixed;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    z-index: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--foreground);
    color: var(--background);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
}

.dream-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition-delay: 0s;
}

/* Phones: native grouped-list layout */
@media (max-width: 767px) {
    .dream-book {
        --dream-sticky-top: 54px;
    }

    .dream-hero {
        margin-bottom: 10px;
    }

    .dream-intro.is-collapsed {
        max-height: calc(1.7em * 4);
        overflow: hidden;
    }

    .dream-intro.is-collapsed.is-clamped {
        -webkit-mask-image: linear-gradient(#000 55%, transparent);
        mask-image: linear-gradient(#000 55%, transparent);
    }

    .dream-toolbar {
        margin: 0 calc(var(--dream-gutter) * -1) 16px;
        padding: 8px var(--dream-gutter) 0;
    }

    .dream-toolbar.is-stuck {
        padding-top: 10px;
    }

    .dream-letter {
        min-width: 42px;
        height: 40px;
    }

    .dream-chips {
        flex-wrap: nowrap;
        margin: 0 calc(var(--dream-gutter) * -1);
        padding: 0 var(--dream-gutter) 2px;
        overflow-x: auto;
        scroll-snap-type: x proximity;
        scroll-padding-inline: var(--dream-gutter);
        scrollbar-width: none;
    }

    .dream-chips::-webkit-scrollbar {
        display: none;
    }

    .dream-chip {
        height: 40px;
        scroll-snap-align: start;
    }

    .dream-book .dream-catalog-title {
        font-size: 19px;
        padding-top: 16px;
    }

    .dream-groups {
        display: block;
    }

    .dream-group {
        padding: 0;
        border: 0;
        border-radius: 0;
        background: none;
    }

    .dream-group + .dream-group {
        margin-top: 8px;
    }

    .dream-book .dream-group-title {
        position: sticky;
        top: calc(var(--dream-sticky-top) + var(--dream-toolbar-h));
        z-index: 5;
        margin: 0 calc(var(--dream-gutter) * -1);
        padding: 10px var(--dream-gutter) 8px;
        border: 0;
        background: var(--background);
        font-size: 17px;
    }

    .dream-book .dream-list {
        overflow: hidden;
        border: 1px solid var(--border);
        border-radius: 14px;
        background: var(--card);
    }

    .dream-book .dream-item + .dream-item::before {
        content: "";
        position: absolute;
        top: 0;
        left: 16px;
        right: 0;
        height: 1px;
        background: var(--border);
    }

    .dream-link {
        min-height: 52px;
        padding: 8px 12px 8px 16px;
        border-radius: 0;
        font-size: 16px;
    }

    .dream-link:hover {
        background: none;
        color: var(--foreground) !important;
    }

    .dream-link:active {
        background: var(--muted);
    }

    .dream-link-chevron,
    .dream-link:hover .dream-link-chevron {
        opacity: 1;
        transform: none;
    }

    .dream-empty-actions .dream-btn {
        flex: 1 1 140px;
    }
}

@media (max-width: 360px) {
    .dream-book {
        --dream-gutter: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dream-book *,
    .dream-top {
        transition: none !important;
    }
}
