/* ========================================
   COLOR TOKEN SYSTEM
   ======================================== */
:root {
    --border-subtle: rgba(255, 255, 255, 0.05);
    --border-default: rgba(255, 255, 255, 0.08);
    --border-emphasis: rgba(255, 255, 255, 0.15);
    --border-strong: rgba(255, 255, 255, 0.25);

    --bg-subtle: rgba(255, 255, 255, 0.02);
    --bg-default: rgba(255, 255, 255, 0.04);
    --bg-emphasis: rgba(255, 255, 255, 0.08);

    --text-primary: #f5f5f5;
    --text-secondary: rgba(255, 255, 255, 0.75);
    --text-muted: rgba(255, 255, 255, 0.5);
}

.homebrew-builder-page {
    padding: clamp(2rem, 5vw, 3.5rem) 0 clamp(3rem, 6vw, 4rem);
    position: relative;
    background: radial-gradient(circle at 18% 16%, rgba(255, 231, 194, 0.12), transparent 38%),
        radial-gradient(circle at 82% 12%, rgba(164, 195, 252, 0.16), transparent 32%),
        linear-gradient(140deg, #0b0b0f, #0f1018 45%, #0b0c12 70%, #090a0f);
}

.homebrew-builder-page .container {
    max-width: 1440px;
}

/* Typography Hierarchy */
.homebrew-builder-page h1 {
    font-size: 2.5rem;
    font-weight: 700;
}

.homebrew-builder-page h2 {
    font-size: 1.75rem;
    font-weight: 700;
}

.homebrew-builder-page h3 {
    font-size: 1.125rem;
    font-weight: 600;
}


.homebrew-builder-page .lead {
    font-size: 1.125rem;
    opacity: 0.85;
    line-height: 1.6;
}

.homebrew-builder-page .muted {
    color: var(--text-secondary);
}

.homebrew-builder-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 44% 48%, rgba(255, 255, 255, 0.05), transparent 55%),
        linear-gradient(125deg, rgba(255, 255, 255, 0.02), rgba(204, 180, 144, 0.06) 46%, rgba(255, 255, 255, 0.02));
    pointer-events: none;
}

.hb-grid {
    display: grid;
    grid-template-columns: 280px minmax(calc(8.5in + 1rem), 1fr) 320px;
    gap: clamp(1rem, 2vw, 1.4rem);
    align-items: start;
}

.homebrew-builder-page button,
.homebrew-builder-page .btn {
    padding: 0.25rem 0.45rem;
}

.homebrew-builder-page .btn-sm {
    padding: 0.18rem 0.3rem;
}

.hb-panel--left,
.hb-panel--right {
    position: sticky;
    top: clamp(1rem, 3vw, 1.75rem);
}

.hb-panel__toggle {
    display: none;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #f0e5d8;
    font-weight: 700;
    text-align: left;
}

.hb-panel__content {
    display: grid;
    gap: 0.5rem;
}

.hb-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.hb-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: #e8dfd2;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: none;
}

.hb-preview {
    background: none;
    border: none;
    border-radius: 18px;
    padding: clamp(0.25rem, 0.8vw, 0.45rem);
    box-shadow: none;
    position: relative;
    overflow: visible;
}

.hb-editor-bar {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(12px);
    border: none;
    border-bottom: 1px solid var(--border-default);
    border-radius: 12px 12px 0 0;
    padding: clamp(0.35rem, 0.9vw, 0.55rem);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
    margin-bottom: clamp(0.25rem, 0.8vw, 0.45rem);
    position: sticky;
    top: clamp(0.75rem, 2vw, 1rem);
    z-index: 5;
}

.hb-editor-bar__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.hb-template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin: 0.75rem 0 0;
}

.hb-template-card {
    display: grid;
    gap: 0.2rem;
    align-content: start;
    padding: 0.75rem 0.9rem;
    background: linear-gradient(140deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #f3f0ea;
    text-align: left;
    cursor: pointer;
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.hb-template-card strong {
    font-size: 1.05rem;
}

.hb-template-card__eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.78rem;
    color: #c9bba5;
}

.hb-template-card:hover,
.hb-template-card:focus-visible {
    transform: translateY(-3px) scale(1.02);
    border-color: rgba(138, 123, 255, 0.6);
    background: linear-gradient(140deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04));
    box-shadow: 0 8px 24px rgba(138, 123, 255, 0.25), 0 0 0 1px rgba(138, 123, 255, 0.3);
    outline: none;
}

.hb-template-card:active {
    transform: translateY(-1px) scale(0.99);
}

.hb-progress {
    width: 100%;
    box-sizing: border-box;
    margin-top: 0.5rem;
}

.hb-clear-button {
    color: #b3261e;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.hb-export-actions .btn-ghost,
.hb-actions-row .btn-ghost {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.35);
    color: #f6ede0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.hb-export-actions .btn-ghost:hover,
.hb-export-actions .btn-ghost:focus-visible,
.hb-actions-row .btn-ghost:hover,
.hb-actions-row .btn-ghost:focus-visible {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.5);
    color: #fffaf3;
}

.hb-clear-button:hover,
.hb-clear-button:focus-visible {
    color: #7f1b12;
}

.autosave {
    color: #8cecf7;
    font-size: 0.95rem;
    margin-top: 0.35rem;
}

.hb-autosave-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(140, 236, 247, 0.18);
    color: #def7fa;
    border: 1px solid rgba(140, 236, 247, 0.4);
    border-radius: 999px;
    padding: 0.1rem 0.6rem;
    font-size: 0.85rem;
    font-weight: 700;
}

.hb-autosave-pill.is-saving {
    background: rgba(255, 186, 107, 0.2);
    border-color: rgba(255, 186, 107, 0.55);
    color: #ffe6c4;
}

.hb-writing-stats {
    margin-top: 0.25rem;
    color: #c5d8ff;
}

.hb-theme {
    min-width: 220px;
    background: rgba(255, 255, 255, 0.04);
    padding: 0.35rem 0.5rem;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.hb-theme__description {
    margin: 0.35rem 0 0;
}

.hb-export-actions {
    background: rgba(255, 255, 255, 0.04);
    padding: 0.5rem 0.65rem;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    min-width: 280px;
}

.hb-action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 0.25rem 0 0.35rem;
}

.hb-export-toggles {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    margin: 0.35rem 0;
}

.hb-print-toggle {
    font-weight: 700;
    color: #e8e9ff;
}

.hb-print-toggle input {
    margin-right: 0.35rem;
}

.hb-checklist {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    margin: 0.4rem 0 0;
    padding: 0.35rem 0.5rem;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
}

.hb-check {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    color: #e7eaf7;
    font-weight: 700;
    font-size: 0.9rem;
}

.hb-check::before {
    content: '○';
    color: #9fb0ff;
}

.hb-check.is-done {
    background: rgba(134, 243, 186, 0.18);
    border-style: solid;
    border-color: rgba(134, 243, 186, 0.65);
    color: #e9fff2;
}

.hb-check.is-done::before {
    content: '✓';
    color: #86f3ba;
}

.hb-theme-recents {
    margin-top: 0.4rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.hb-theme-recent {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #e9e8ff;
    padding: 0.25rem 0.45rem;
    border-radius: 10px;
    font-size: 0.9rem;
}

.hb-theme-recent:hover,
.hb-theme-recent:focus-visible {
    border-color: rgba(138, 123, 255, 0.65);
}

.hb-inline-hint {
    color: #5b3d1c;
    background: rgba(255, 255, 255, 0.75);
    border: 1px dashed rgba(106, 73, 40, 0.32);
    border-radius: 10px;
    padding: 0.35rem 0.5rem;
    margin: 0 0 0.35rem;
}

.hb-start-modal {
    position: fixed;
    inset: 0;
    background: rgba(7, 7, 15, 0.72);
    display: grid;
    place-items: center;
    z-index: 40;
}

.hb-start-modal.is-hidden {
    display: none;
}

.hb-start-card {
    background: linear-gradient(140deg, #141724, #0e111d 48%, #1d2034);
    border: 1px solid rgba(138, 123, 255, 0.3);
    border-radius: 18px;
    padding: clamp(1.25rem, 3vw, 1.75rem);
    width: min(520px, 92vw);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4);
}

.hb-start-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.hb-theme-swatch {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
    flex-shrink: 0;
}

.hb-quick-layouts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin: 0.5rem 0;
}

.hb-quick-layouts .btn {
    border-color: rgba(0, 0, 0, 0.15);
    color: #1f140a;
    background: rgba(0, 0, 0, 0.04);
}

.hb-quick-layouts .btn:hover,
.hb-quick-layouts .btn:focus-visible {
    border-color: rgba(0, 0, 0, 0.35);
}

.hb-canvas {
    display: grid;
    place-items: start center;
    padding: clamp(0.25rem, 1vw, 0.5rem);
    width: min(100%, calc(8.5in + 6rem));
    margin: 0 auto;
    min-height: calc(11in + 3rem);
    overflow: visible;
}

.hb-page {
    --hb-paper: radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.6), transparent 34%),
        radial-gradient(circle at 78% 18%, rgba(243, 220, 186, 0.6), transparent 36%),
        linear-gradient(135deg, #f4ead3 0%, #e7d7b9 18%, #e2d0ac 50%, #f3e7cf 100%);
    --hb-paper-grain: radial-gradient(circle at 0 0, rgba(0, 0, 0, 0.08) 0.5px, transparent 0.5px);
    --hb-ink: #1e120b;
    --hb-ink-strong: #140b06;
    --hb-kicker: #8b6133;
    --hb-lede: #2a1b10;
    --hb-rule: rgba(132, 98, 58, 0.5);
    --hb-callout-bg: linear-gradient(135deg, rgba(138, 88, 41, 0.08), rgba(238, 185, 107, 0.16));
    --hb-callout-border: rgba(109, 74, 36, 0.25);
    --hb-figure-border: rgba(102, 67, 28, 0.45);
    --hb-figure-bg: linear-gradient(180deg, rgba(255, 255, 252, 0.96), rgba(242, 224, 198, 0.94));
    --hb-figure-caption: #2f1c0f;
    --hb-figure-caption-bg: rgba(250, 234, 210, 0.96);

    position: relative;
    width: 8.5in;
    max-width: 100%;
    min-height: 11in;
    height: auto;
    aspect-ratio: 8.5 / 11;
    margin: 0 auto;
    box-sizing: border-box;
    border-radius: 2px;
    padding: 0;
    background: var(--hb-paper);
    border: 1px solid rgba(73, 46, 11, 0.18);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
                0 0 0 1px rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.hb-page[data-print-safe='true'] {
    background: #ffffff;
    box-shadow: none;
    border-color: rgba(0, 0, 0, 0.08);
}

.hb-page[data-print-safe='true']::before,
.hb-page[data-print-safe='true']::after {
    display: none;
}

.hb-page::before,
.hb-page::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.hb-page::before {
    background: radial-gradient(circle at 18% 20%, rgba(255, 255, 255, 0.5), transparent 46%),
        radial-gradient(circle at 76% 12%, rgba(255, 240, 210, 0.38), transparent 40%),
        linear-gradient(175deg, rgba(255, 255, 255, 0.18), transparent 68%);
}

.hb-page::after {
    background-image: var(--hb-paper-grain);
    background-size: 7px 7px;
    opacity: 0.2;
    mix-blend-mode: multiply;
}

.hb-page-inner {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(247, 232, 211, 0.9)), var(--hb-paper);
    padding: clamp(0.75in, 8vw, 1in) clamp(0.75in, 8vw, 1in);
    border-radius: 12px;
    min-height: calc(11in - 2in);
    position: relative;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78), 0 10px 30px rgba(0, 0, 0, 0.12);
    color: var(--hb-ink);
    overflow: hidden;
    box-sizing: border-box;
}

.hb-page[data-print-safe='true'] .hb-page-inner {
    background: #ffffff;
    color: #111;
    box-shadow: none;
}

.hb-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.35rem 0.4rem;
    margin: 0.4rem 0 0.25rem 0;
    background: linear-gradient(130deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.06));
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    position: sticky;
    top: clamp(0.85rem, 2vw, 1.1rem);
    z-index: 10;
    backdrop-filter: blur(7px);
}

.hb-toolbar-group {
    display: inline-flex;
    gap: 0.25rem;
    padding-right: 0.35rem;
    margin-right: 0.35rem;
    position: relative;
}

.hb-toolbar-group:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 24px;
    background: var(--border-emphasis);
}

.hb-toolbar-group:last-child {
    padding-right: 0;
    margin-right: 0;
}

.hb-menu {
    position: relative;
}

.hb-menu__trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border-radius: 999px;
}

.hb-menu__trigger .hb-icon {
    display: inline-flex;
    width: 18px;
    justify-content: center;
}

.hb-menu__list {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    min-width: 200px;
    display: none;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.4rem;
    background: linear-gradient(150deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.08));
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 12px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.36);
    z-index: 20;
}

.hb-menu.is-open .hb-menu__list {
    display: flex;
}

.hb-menu__item {
    width: 100%;
    justify-content: flex-start;
}

.hb-editor-toolbar .btn-sm {
    padding: 0.15rem 0.4rem;
    font-size: 0.82rem;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.hb-editor-toolbar .btn-ghost:hover {
    background: rgba(0, 0, 0, 0.05);
}

.column-break {
    break-after: column;
    display: block;
    height: 1px;
    background: transparent;
    margin: 0;
}

.hb-body {
    margin: 0 auto;
    font-size: 0.85rem;
    line-height: 1.72;
    color: var(--hb-ink);
    padding: 0;
    font-family: 'Source Serif Pro', var(--font-body);
    column-gap: 0.6cm;
    column-fill: balance;
    column-rule: 1px solid var(--hb-rule);
    column-count: 2;
    overflow-wrap: break-word;
    hyphens: auto;
    width: 100%;
}

.hb-body>* {
    break-inside: avoid-column;
}

.hb-body:focus {
    outline: 2px solid rgba(138, 123, 255, 0.6);
    outline-offset: 4px;
}

.hb-body h3 {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.4px;
    margin: 0.25rem 0 0.5rem;
    color: var(--hb-ink-strong);
    text-transform: uppercase;
    border-bottom: 2px solid var(--hb-rule);
    padding-bottom: 0.2rem;
}

.hb-body .hb-kicker {
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.82rem;
    color: var(--hb-kicker);
    margin: 0 0 0.35rem;
}

.hb-lede {
    font-size: 1.14rem;
    color: var(--hb-lede);
    font-weight: 700;
}

.hb-body p {
    margin: 0 0 1rem;
    color: var(--hb-ink);
}

.hb-figure {
    float: left;
    width: var(--hb-width, 100%);
    max-width: 100%;
    margin: 0 1.25rem 1.25rem 0;
    box-sizing: border-box;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--hb-figure-border);
    background: var(--hb-figure-bg);
    box-shadow: 0 10px 18px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.78);
    shape-outside: inset(0 round 14px);
    break-inside: avoid-column;
    position: relative;
    z-index: 5;
    transition: box-shadow 200ms ease, transform 200ms ease;
}

.hb-figure:hover {
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

/* Inline Image Toolbar */
.hb-image-toolbar {
    position: absolute;
    top: 8px;
    right: 8px;
    display: none;
    gap: 0.25rem;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 0.25rem;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.hb-figure:hover .hb-image-toolbar {
    display: flex;
}

.hb-image-toolbar button {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.9);
    padding: 0.35rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 150ms ease, color 150ms ease;
}

.hb-image-toolbar button:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.hb-figure img {
    display: block;
    width: 100%;
    height: auto;
}

.hb-figure figcaption {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    color: var(--hb-figure-caption);
    background: var(--hb-figure-caption-bg);
    overflow-wrap: break-word;
    width: 100%;
    box-sizing: border-box;
}

.hb-page[data-theme="parchment"] .hb-body {
    column-rule-color: rgba(132, 98, 58, 0.5);
}

.hb-page[data-theme="parchment"] .hb-figure {
    border-color: rgba(116, 80, 42, 0.5);
    box-shadow: 0 12px 22px rgba(0, 0, 0, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.88);
}

.hb-page[data-theme="parchment"] .hb-figure figcaption {
    background: rgba(250, 234, 210, 0.96);
}

.hb-figure.hb-wrap-right {
    float: right;
    margin: 0 0 1.25rem 1.25rem;
}

.hb-figure.hb-wrap-inline {
    float: none;
    display: block;
    margin: 1rem auto;
    shape-outside: auto;
    column-span: all;
}

.hb-figure[contenteditable="false"] {
    user-select: none;
    cursor: default;
}

.hb-blend-multiply img {
    mix-blend-mode: multiply;
}

.hb-blend-screen img {
    mix-blend-mode: screen;
}

.hb-blend-overlay img {
    mix-blend-mode: overlay;
}

.hb-blend-darken img {
    mix-blend-mode: darken;
}

.hb-edge-none {
    border-radius: 0;
    shape-outside: none;
}

.hb-edge-feathered {
    -webkit-mask-image: radial-gradient(ellipse at center, black 50%, transparent 98%);
    mask-image: radial-gradient(ellipse at center, black 50%, transparent 98%);
    border: none;
    box-shadow: none;
    background: transparent;
    shape-outside: margin-box;
}

.hb-drop-overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.22);
    border-radius: 12px;
    color: #f8f1e3;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.hb-drop-overlay.is-active {
    opacity: 1;
}

.hb-drop-visual {
    text-align: center;
    background: rgba(0, 0, 0, 0.45);
    padding: 1.25rem 1.5rem;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.hb-drop-icon {
    font-size: 2rem;
    margin-bottom: 0.35rem;
}


.hb-card.accent {
    background: linear-gradient(135deg, rgba(138, 123, 255, 0.08), rgba(18, 16, 40, 0.4));
    border-color: rgba(138, 123, 255, 0.2);
}

.hb-card__header {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.2rem;
}

.hb-card__header h3 {
    margin: 0.25rem 0 0;
}

.hb-drop-inline {
    border: 1.4px dashed rgba(255, 255, 255, 0.35);
    padding: 0.5rem 0.6rem;
    border-radius: 10px;
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.07);
}

.hb-drop-inline:focus-visible {
    outline: 2px solid rgba(140, 236, 247, 0.9);
    outline-offset: 3px;
    box-shadow: 0 0 0 4px rgba(140, 236, 247, 0.2);
}

.hb-image-list {
    display: grid;
    gap: 0.75rem;
}

.hb-empty {
    color: var(--muted);
    margin: 0;
}

.hb-ribbon {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    background: linear-gradient(120deg, rgba(123, 104, 238, 0.16), rgba(234, 165, 44, 0.2));
    border: 1px solid rgba(123, 104, 238, 0.35);
    border-radius: 12px;
    font-size: 0.85rem;
    color: var(--hb-ink-strong);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.hb-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.5rem 0.75rem;
}

.hb-meta-grid .form-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.22);
    padding: 0.4rem 0.6rem;
    color: #f5f5f5;
}

.hb-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 0.35rem;
}

.hb-callout {
    border-radius: 14px;
    padding: 0.85rem 1rem;
    background: var(--hb-callout-bg);
    border: 1px solid var(--hb-callout-border);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
    margin: 1.1rem 0;
}

.hb-callout__label {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--hb-kicker);
    margin: 0 0 0.35rem;
    font-size: 0.78rem;
}

.hb-callout__body {
    margin: 0;
    color: var(--hb-ink);
}

.hb-bullet {
    margin: 0.5rem 0 1.25rem 0;
    padding-left: 1.3rem;
    color: var(--hb-ink);
}

.hb-bullet li+li {
    margin-top: 0.35rem;
}

.hb-wrap-row {
    display: grid;
    gap: 0.35rem;
    align-items: center;
}

.pill-switch {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 0.35rem;
}

.pill-switch label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    font-size: 0.95rem;
}

.pill-switch input {
    accent-color: #8a7bff;
}

.hb-slider {
    display: grid;
    gap: 0.35rem;
}

.muted {
    color: var(--muted);
}.hb-page[data-theme="ink"] {
    --hb-paper: radial-gradient(circle at 48% 20%, rgba(55, 77, 156, 0.32), transparent 36%),
        linear-gradient(145deg, #0d1029 0%, #0b0e20 50%, #0a0c1b 100%);
    --hb-paper-grain: radial-gradient(circle at 0 0, rgba(255, 255, 255, 0.08) 0.5px, transparent 0.5px);
    --hb-ink: #f9fbff;
    --hb-ink-strong: #ffffff;
    --hb-kicker: #a3c8ff;
    --hb-lede: #e9ecff;
    --hb-rule: rgba(163, 200, 255, 0.6);
    --hb-callout-bg: linear-gradient(135deg, rgba(82, 114, 193, 0.35), rgba(35, 38, 79, 0.65));
    --hb-callout-border: rgba(163, 200, 255, 0.45);
    --hb-figure-border: rgba(163, 200, 255, 0.7);
    --hb-figure-bg: linear-gradient(180deg, rgba(22, 27, 60, 0.94), rgba(12, 15, 36, 0.94));
    --hb-figure-caption: #dce7ff;
    --hb-figure-caption-bg: rgba(10, 14, 32, 0.94);
    border-color: rgba(138, 123, 255, 0.5);
    background: radial-gradient(circle at 30% 30%, rgba(138, 123, 255, 0.18), rgba(7, 6, 18, 0.9)), #0f1024;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(163, 200, 255, 0.15);
}

.hb-page[data-theme="ink"] .hb-page-inner {
    background: linear-gradient(180deg, rgba(8, 10, 25, 0.92), rgba(8, 10, 28, 0.9));
}

.hb-page[data-theme="ink"] .hb-body {
    color: var(--hb-ink);
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
    column-rule-color: rgba(163, 200, 255, 0.6);
}

.hb-page[data-theme="ink"] .hb-figure {
    border-color: rgba(163, 200, 255, 0.7);
    box-shadow: 0 14px 24px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.hb-page[data-theme="ink"] .hb-figure figcaption {
    background: rgba(10, 14, 32, 0.94);
    color: #e8f0ff;
}

.hb-page[data-theme="grid"] {
    --hb-paper: linear-gradient(135deg, #0b111c 0%, #08101d 55%, #0a1322 100%);
    --hb-paper-grain: radial-gradient(circle at 0 0, rgba(120, 200, 255, 0.2) 0.5px, transparent 0.5px);
    --hb-ink: #e5f4ff;
    --hb-ink-strong: #ffffff;
    --hb-kicker: #7bd2ff;
    --hb-lede: #d8ecff;
    --hb-rule: rgba(110, 198, 255, 0.5);
    --hb-callout-bg: linear-gradient(135deg, rgba(32, 64, 112, 0.55), rgba(12, 26, 52, 0.8));
    --hb-callout-border: rgba(110, 198, 255, 0.45);
    --hb-figure-border: rgba(110, 198, 255, 0.55);
    --hb-figure-bg: linear-gradient(180deg, rgba(9, 15, 26, 0.95), rgba(5, 10, 22, 0.9));
    --hb-figure-caption: #d8efff;
    --hb-figure-caption-bg: rgba(5, 12, 26, 0.88);
    border-color: rgba(120, 200, 255, 0.4);
    background: #0a0b12;
    background-image:
        radial-gradient(circle at 1px 1px, rgba(120, 200, 255, 0.35) 1px, transparent 0),
        linear-gradient(transparent 24px, rgba(120, 200, 255, 0.1) 25px),
        linear-gradient(90deg, transparent 24px, rgba(120, 200, 255, 0.1) 25px);
    background-size: 50px 50px, 25px 25px, 25px 25px;
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(120, 200, 255, 0.15);
}

.hb-page[data-theme="grid"] .hb-page-inner {
    background: linear-gradient(180deg, rgba(10, 11, 18, 0.92), rgba(9, 12, 21, 0.95));
}

.hb-page[data-theme="grid"] .hb-body {
    color: var(--hb-ink);
    font-family: 'DM Sans', var(--font-body);
}

@media (max-width: 1100px) {
    .hb-grid {
        grid-template-columns: 1fr;
    }

    .hb-panel--left,
    .hb-panel--right,
    .hb-editor-bar {
        position: static;
    }

    .hb-panel__toggle {
        display: inline-flex;
    }

    .hb-panel--collapsible .hb-panel__content {
        display: none;
    }

    .hb-panel--collapsible.is-open .hb-panel__content {
        display: grid;
    }

    .hb-panel--left .hb-card,
    .hb-panel--right .hb-card {
        margin-top: 0;
    }
}

@media (max-width: 640px) {
    .hb-figure {
        width: 100%;
        float: none;
        margin: 0 0 1rem;
        shape-outside: auto;
    }

    .hb-figure.hb-wrap-right {
        float: none;
        margin: 0 0 1rem;
    }

    .hb-editor-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .hb-toolbar-group {
        border-right: none;
        padding-right: 0;
    }

    .hb-menu__list {
        position: static;
        display: flex;
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 0.25rem 0;
    }
}

/* ========================================
   HOMEBREWERY D&D 5E STYLING
   ======================================== */

/* PHB Theme Styling */
.hb-page[data-theme="phb"],
.hb-page[data-theme="dmg"],
.hb-page[data-theme="arcana"] {
    --phb-color-bg: #EEE5CE;
    --phb-color-accent: #E0E5C1;
    --phb-color-underline: #C0AD6A;
    --phb-color-rule: #9C2B1B;
    --phb-color-header: #58180D;
    --phb-color-monster-bg: #F2E5B5;
    --phb-color-caption: #766649;
    --phb-color-footnote: #C9AD6A;
}

.hb-page[data-theme="phb"] {
    --hb-paper: url('/assets/images/homebrewery/parchmentBackground.jpg'), #EEE5CE;
    --hb-paper-grain: none;
    --hb-ink: #241510;
    --hb-ink-strong: #58180D;
    border-color: rgba(192, 173, 106, 0.4);
    background: var(--hb-paper);
}

.hb-page[data-theme="phb"] .hb-page-inner {
    background: transparent;
}

.hb-page[data-theme="dmg"] {
    --hb-paper: url('/assets/images/homebrewery/parchmentBackground.jpg'), #EBCEC3;
    --phb-color-accent: #F0E0DA;
    --hb-ink: #1a0f0a;
    --hb-ink-strong: #58180D;
    border-color: rgba(192, 173, 106, 0.4);
    background: var(--hb-paper);
}

.hb-page[data-theme="dmg"] .hb-page-inner {
    background: transparent;
}

.hb-page[data-theme="arcana"] {
    --hb-paper: #FEFEFE;
    --phb-color-accent: #F5F5F5;
    --hb-ink: #000000;
    --hb-ink-strong: #000000;
    border-color: rgba(0, 0, 0, 0.2);
    background: var(--hb-paper);
}

.hb-page[data-theme="arcana"] .hb-page-inner {
    background: transparent;
}

/* Monster Statblock */
.monster {
    position: relative;
    padding: 0;
    margin-bottom: 0.8rem;
    font-family: 'Calibri', sans-serif;
    font-size: 0.9rem;
    line-height: 1.4;
}

.monster.frame {
    width: 100%;
    padding: 8px 6px;
    margin-right: 0;
    margin-left: 0;
    background-color: var(--phb-color-monster-bg);
    background-image: url('/assets/images/homebrewery/parchmentBackgroundGrayscale.jpg');
    background-blend-mode: overlay;
    border-style: solid;
    border-width: 7px 6px;
    border-image: url('/assets/images/homebrewery/monsterBorderFancy.png') 14 round;
    border-image-outset: 0 2px;
    box-shadow: 1px 4px 14px rgba(0, 0, 0, 0.3);
}

.monster h2 {
    margin: 0 0 0.25rem;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--phb-color-header);
    line-height: 1.2;
}

.monster h2+p {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    font-style: italic;
}

.monster h3 {
    margin: 0.5rem 0 0.25rem;
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--phb-color-header);
    border-bottom: 1.5px solid var(--phb-color-header);
    font-variant: small-caps;
    letter-spacing: 0.03em;
}

.monster hr {
    visibility: visible;
    height: 6px;
    margin: 0.3rem 0;
    background-image: url('/assets/images/homebrewery/redTriangle.png');
    background-size: 100% 100%;
    border: none;
}

.monster hr~dl,
.monster hr~p {
    color: var(--phb-color-header);
}

.monster hr:last-of-type~dl,
.monster hr:last-of-type~p {
    color: inherit;
}

.monster hr:last-of-type+* {
    margin-top: 0.5rem;
}

.monster dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0 0.5em;
    margin: 0.25rem 0;
    line-height: 1.4;
}

.monster dt {
    font-weight: bold;
}

.monster dt::after {
    content: '';
}

.monster dd {
    margin: 0;
}

.monster table {
    width: 100%;
    margin: 0.5rem 0;
    font-size: 0.9rem;
    border-collapse: collapse;
}

.monster hr+table:first-of-type {
    margin: 0;
    color: var(--phb-color-header);
    background-color: transparent;
    border: none;
}

.monster hr+table:first-of-type tr {
    background-color: transparent;
}

.monster hr+table:first-of-type td,
.monster hr+table:first-of-type th {
    padding: 2px 4px;
    text-align: center;
    font-weight: bold;
}

.monster table th {
    padding: 4px;
    font-weight: bold;
    text-align: center;
}

.monster table td {
    padding: 4px;
    text-align: center;
}

.monster p {
    margin: 0.5rem 0;
    text-indent: 0;
}

.monster p strong em,
.monster p em strong {
    font-style: italic;
    font-weight: bold;
}

.monster ul,
.monster ol {
    margin: 0.5rem 0;
    padding-left: 1.5em;
}

.monster ul+p,
.monster ol+p {
    text-indent: 0;
}

.monster:last-child {
    margin-bottom: 0;
}

/* Wide monster block spans columns */
@media (min-width: 980px) {
    .monster.wide {
        column-span: all;
        -webkit-column-span: all;
    }
}

/* Descriptive Text Box */
.descriptive {
    padding: 0.5rem 0.6rem;
    margin: 1rem 0;
    background-color: #FAF7EA;
    border-style: solid;
    border-width: 7px;
    border-image: url('/assets/images/homebrewery/descriptiveBorder.png') 12 stretch;
    border-image-outset: 4px;
    box-shadow: 0 0 6px rgba(250, 247, 234, 0.8);
    font-family: 'Calibri', sans-serif;
    font-size: 0.9rem;
}

.descriptive h5 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
    font-weight: bold;
    font-variant: small-caps;
    letter-spacing: 0.03em;
}

.descriptive p {
    margin: 0.5rem 0;
    line-height: 1.5;
}

.descriptive p:first-of-type {
    margin-top: 0;
}

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

.descriptive+* {
    margin-top: 1rem;
}

/* Note Box */
.note {
    padding: 0.4rem 0.5rem;
    margin: 1rem 0;
    background-color: var(--phb-color-accent);
    border-style: solid;
    border-width: 1px;
    border-image: url('/assets/images/homebrewery/noteBorder.png') 12 stretch;
    border-image-width: 11px;
    border-image-outset: 9px 0;
    box-shadow: 1px 4px 14px rgba(0, 0, 0, 0.15);
    font-family: 'Calibri', sans-serif;
    font-size: 0.9rem;
}

.note h5 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
    font-weight: bold;
    font-variant: small-caps;
    letter-spacing: 0.03em;
}

.note p {
    margin: 0.5rem 0;
    line-height: 1.4;
}

.note p:first-of-type {
    margin-top: 0;
}

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

.note+* {
    margin-top: 1rem;
}

/* Class Table */
.classTable {
    width: 100%;
    margin: 1.5rem 0;
    font-family: 'Calibri', sans-serif;
    font-size: 0.85rem;
    border-collapse: collapse;
}

.classTable.frame {
    width: calc(100% + 0.4cm);
    margin: 1.5rem -0.2cm;
    border: none;
    border-style: solid;
    border-image: url('/assets/images/homebrewery/frameBorder.png') 200;
    border-image-width: 47px;
    border-image-outset: 0.4cm 0.3cm;
    border-image-repeat: stretch;
    background-color: white;
}

.classTable th {
    padding: 0.4rem 0.5rem;
    font-weight: bold;
    text-align: left;
    vertical-align: bottom;
    white-space: nowrap;
}

.classTable th[colspan]:not([rowspan]) {
    white-space: nowrap;
}

.classTable tbody tr {
    background-color: white;
}

.classTable tbody tr:nth-child(odd) {
    background-color: var(--phb-color-accent);
}

.classTable tbody td {
    padding: 0.4rem 0.5rem;
    text-align: left;
}

.classTable tbody td:not(:first-child) {
    text-align: center;
}

/* Spell List */
.spellList {
    font-family: 'Calibri', sans-serif;
    font-size: 0.9rem;
    column-count: 2;
    column-gap: 1.5rem;
}

.spellList.wide {
    column-count: 4;
}

.spellList h5 {
    margin: 0.75rem 0 0.35rem;
    font-size: 1rem;
    font-weight: bold;
    break-after: avoid;
}

.spellList ul+h5 {
    margin-top: 1rem;
}

.spellList ul {
    margin: 0 0 0.5rem;
    padding-left: 1em;
    text-indent: -1em;
    list-style-type: none;
    line-height: 1.4;
}

.spellList li {
    break-inside: avoid;
}

.spellList p {
    margin: 0.5rem 0;
    line-height: 1.4;
}

/* Magic Item */
.magic-item {
    margin: 1rem 0;
}

.magic-item h4 {
    margin: 0.75rem 0 0.25rem;
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: bold;
    color: var(--phb-color-header);
}

.magic-item h4+p {
    margin: 0 0 0.5rem;
    font-style: italic;
    font-size: 0.9rem;
}

.magic-item dl {
    margin: 0.5rem 0;
}

.magic-item dd {
    margin: 0;
    text-indent: 0;
    line-height: 1.5;
}

.magic-item.frame {
    padding: 0.9rem 1rem;
    border-radius: 12px;
    border: 1px solid rgba(73, 46, 11, 0.25);
    background: linear-gradient(140deg, rgba(255, 255, 255, 0.92), rgba(240, 220, 191, 0.9));
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.spell-block {
    margin: 1rem 0;
    padding: 0.85rem 1rem;
    border-left: 4px solid var(--phb-color-header);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(233, 214, 187, 0.8));
    font-family: 'Calibri', sans-serif;
    font-size: 0.92rem;
    line-height: 1.5;
}

.spell-block.frame {
    box-shadow: 0 12px 18px rgba(0, 0, 0, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.76);
    border-radius: 10px;
    border: 1px solid rgba(73, 46, 11, 0.25);
}

.spell-block h4 {
    margin: 0 0 0.15rem;
    font-size: 1.15rem;
    font-family: var(--font-display);
    color: var(--phb-color-header);
}

.spell-block h4+p {
    margin: 0 0 0.5rem;
    font-style: italic;
    color: var(--hb-lede);
}

.spell-block dl {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 0.15rem 0.5rem;
    margin: 0 0 0.6rem;
}

.spell-block dt {
    font-weight: 700;
    color: var(--hb-ink-strong);
}

.spell-block dd {
    margin: 0;
}

.spell-block p {
    margin: 0.35rem 0;
}

.feature-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.class-feature {
    padding: 0.75rem 0.85rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(73, 46, 11, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.class-feature h5 {
    margin: 0 0 0.35rem;
    font-size: 1rem;
    color: var(--phb-color-header);
}

.class-feature p {
    margin: 0;
    line-height: 1.5;
}

.subclass-block {
    margin: 1.25rem 0;
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid rgba(73, 46, 11, 0.22);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(238, 217, 186, 0.9));
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.14);
}

.subclass-block h4 {
    margin: 0 0 0.25rem;
    font-size: 1.25rem;
    font-family: var(--font-display);
    color: var(--phb-color-header);
}

.subclass-block .muted {
    margin: 0 0 0.6rem;
    color: #5a3a1e;
}

.adventure-block {
    margin: 1.25rem 0;
    padding: 1rem 1.1rem;
    border-radius: 12px;
    border: 1px solid rgba(73, 46, 11, 0.24);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(237, 221, 195, 0.92));
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.adventure-block h3 {
    margin: 0 0 0.4rem;
    font-size: 1.35rem;
    color: var(--phb-color-header);
}

.adventure-summary {
    margin: 0 0 0.6rem;
    color: var(--hb-lede);
    line-height: 1.5;
}

.adventure-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.75rem 1rem;
    margin-top: 0.5rem;
}

.adventure-grid h5 {
    margin: 0 0 0.35rem;
    font-size: 1rem;
    color: var(--phb-color-header);
}

.adventure-grid p {
    margin: 0.2rem 0;
    line-height: 1.5;
}

.adventure-grid ul {
    margin: 0;
    padding-left: 1em;
    line-height: 1.4;
}

.adventure-grid li {
    margin: 0.1rem 0;
}

/* Wide element that spans columns */
.wide {
    column-span: all;
    -webkit-column-span: all;
}

/* Additional typography for PHB themes */
.hb-page[data-theme="phb"] .hb-body h3,
.hb-page[data-theme="dmg"] .hb-body h3,
.hb-page[data-theme="arcana"] .hb-body h3 {
    color: var(--phb-color-header);
    border-bottom-color: var(--phb-color-underline);
}

.hb-page[data-theme="phb"] .hb-body h4,
.hb-page[data-theme="dmg"] .hb-body h4,
.hb-page[data-theme="arcana"] .hb-body h4 {
    color: var(--phb-color-header);
}

.hb-page[data-theme="phb"] .hb-body,
.hb-page[data-theme="dmg"] .hb-body,
.hb-page[data-theme="arcana"] .hb-body {
    color: var(--hb-ink);
}

/* Drop cap for first paragraph after h1 in PHB themes */
.hb-page[data-theme="phb"] .hb-body h3+p::first-letter,
.hb-page[data-theme="dmg"] .hb-body h3+p::first-letter {
    float: left;
    font-size: 3rem;
    line-height: 0.9;
    margin: 0.1em 0.1em 0 0;
    font-weight: bold;
    color: var(--phb-color-header);
}

/* Image List Enhancements */
.hb-card--details summary {
    list-style: none;
    cursor: pointer;
    outline: none;
}

.hb-card--details summary::-webkit-details-marker {
    display: none;
}

.hb-card--details[open] summary {
    margin-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
}

.hb-card__title-group {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex: 1;
    min-width: 0;
}

.hb-card__thumb {
    width: 42px;
    height: 42px;
    border-radius: 6px;
    background-size: cover;
    background-position: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
    background-color: rgba(0, 0, 0, 0.3);
}

.hb-card__heading-text {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #f5f5f5;
    margin: 0;
}

.hb-card__body {
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.btn-remove {
    color: rgba(255, 255, 255, 0.6);
    padding: 0.25rem;
    margin-left: auto;
}

.btn-remove:hover {
    color: #ff8888;
    background: rgba(255, 100, 100, 0.1);
    border-radius: 4px;
}

@media print {
    .hb-page {
        width: 816px;
        min-height: 1056px;
        box-shadow: none;
        border: none;
        margin: 0;
        overflow: visible;
    }

    .homebrew-builder-page {
        padding: 0;
        background: none;
    }

    .hb-editor-toolbar,
    .hb-toolbar,
    .hb-editor-bar,
    .hb-panel,
    .page-header,
    .hb-drop-overlay {
        display: none !important;
    }

    .hb-grid {
        display: block;
    }

    .hb-preview {
        border: none;
        padding: 0;
        box-shadow: none;
        background: none;
        overflow: visible;
    }
}
/* Theme Picker */
.hb-theme-picker {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-top: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
}

.hb-theme-option {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  width: 100%;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 0.65rem;
  align-items: center;
}

.hb-theme-option:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
}

.hb-theme-option.active {
  background: rgba(138, 123, 255, 0.2);
  border-color: #8a7bff;
  box-shadow: 0 0 0 1px #8a7bff;
}

.hb-theme-name {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: #f5f5f5;
}

.hb-theme-desc {
  display: block;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 0.2rem;
  line-height: 1.3;
}

/* ========================================
   UX IMPROVEMENTS - NEW COMPONENTS
   ======================================== */

/* Compact Editor Bar */
.hb-editor-bar__compact {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.hb-editor-bar__compact .hb-editor-toolbar {
  flex: 1;
  min-width: 0;
  margin: 0;
}

/* Progress Bar (replaces checklist) */
.hb-progress-bar {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.5rem;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.hb-progress-step {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.75rem;
  font-weight: 700;
  transition: all 0.2s ease;
  cursor: default;
}

.hb-progress-step.is-done {
  background: rgba(134, 243, 186, 0.25);
  border-color: rgba(134, 243, 186, 0.6);
  color: #86f3ba;
}

.hb-progress-step.is-done .hb-progress-icon::before {
  content: '\2713';
}

.hb-progress-step:not(.is-done) .hb-progress-icon {
  display: inline;
}

.hb-progress-step.is-done .hb-progress-icon {
  font-size: 0;
}

.hb-progress-step.is-done .hb-progress-icon::before {
  font-size: 0.85rem;
}

/* Minimal Card Headers */
.hb-card__header--minimal {
  margin-bottom: 0.35rem;
  padding-bottom: 0;
  border-bottom: none;
}

.hb-card__header--minimal h3 {
  font-size: 0.95rem;
  margin: 0;
}

/* Theme Hint */
.hb-theme-hint {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
  margin: 0 0 0.5rem;
  font-style: italic;
}

/* Page Actions Card */
.hb-card--subtle {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.05);
  padding: 0.75rem;
}

.hb-page-actions {
  display: flex;
  gap: 0.5rem;
}

.hb-danger-btn {
  color: rgba(255, 120, 120, 0.9);
  border-color: rgba(255, 120, 120, 0.3);
}

.hb-danger-btn:hover,
.hb-danger-btn:focus-visible {
  color: #ff8888;
  background: rgba(255, 100, 100, 0.15);
  border-color: rgba(255, 100, 100, 0.5);
}

.clear-page-animation {
  transition: transform 0.2s ease;
}

.clear-page-animation:active {
  transform: scale(0.95);
}

/* Button Icons */
.hb-btn-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.hb-export-btn .hb-btn-icon,
.hb-danger-btn .hb-btn-icon {
  margin-right: 0.35rem;
}

/* Export Card */
.hb-card--export {
  background: linear-gradient(135deg, rgba(138, 123, 255, 0.1), rgba(18, 16, 40, 0.4));
  border-color: rgba(138, 123, 255, 0.25);
}

.hb-export-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.hb-export-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

.hb-export-btn.btn-primary {
  grid-column: span 2;
}

.hb-print-toggle-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  padding: 0.35rem 0;
}

.hb-print-toggle-inline input {
  accent-color: #8a7bff;
}

.hb-print-toggle-inline:hover {
  color: rgba(255, 255, 255, 0.9);
}

/* Drop Zone Improvements */
.hb-drop-inline {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.hb-drop-icon-svg {
  width: 32px;
  height: 32px;
  color: rgba(255, 255, 255, 0.4);
  transition: color 0.2s ease;
}

.hb-drop-inline:hover .hb-drop-icon-svg,
.hb-drop-inline:focus-visible .hb-drop-icon-svg {
  color: rgba(140, 236, 247, 0.8);
}

.hb-drop-inline p {
  margin: 0;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
}

/* Toast Notifications */
.hb-toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.hb-toast {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  background: rgba(20, 20, 30, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  color: #f5f5f5;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  pointer-events: auto;
  animation: toastIn 0.25s ease-out;
}

.hb-toast.is-leaving {
  animation: toastOut 0.2s ease-in forwards;
}

.hb-toast--success {
  border-color: rgba(134, 243, 186, 0.4);
}

.hb-toast--success::before {
  content: '\2713';
  color: #86f3ba;
  font-weight: bold;
}

.hb-toast--info {
  border-color: rgba(140, 236, 247, 0.4);
}

.hb-toast--info::before {
  content: '\2139';
  color: #8cecf7;
  font-weight: bold;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }
}

/* Image List Progressive Disclosure */
.hb-image-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.hb-image-card:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.hb-image-card__header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  cursor: grab;
  user-select: none;
}

.hb-image-card__header:active {
  cursor: grabbing;
}

.hb-image-card.is-dragging {
  opacity: 0.5;
  border-color: rgba(138, 123, 255, 0.5);
}

.hb-image-card.drag-over {
  border-color: rgba(138, 123, 255, 0.8);
  background: rgba(138, 123, 255, 0.1);
}

.hb-image-card__drag-handle {
  color: rgba(255, 255, 255, 0.3);
  font-size: 1rem;
  cursor: grab;
  padding: 0.25rem;
  line-height: 1;
}

.hb-image-card__thumb {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}

.hb-image-card__info {
  flex: 1;
  min-width: 0;
}

.hb-image-card__title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f5f5f5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.hb-image-card__meta {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
  margin: 0;
}

.hb-image-card__quick-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.hb-image-card__quick-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  padding: 0.35rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: grid;
  place-items: center;
}

.hb-image-card__quick-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
}

.hb-image-card__quick-btn--remove:hover {
  background: rgba(255, 100, 100, 0.15);
  color: #ff8888;
}

.hb-image-card__quick-btn svg {
  width: 16px;
  height: 16px;
}

/* Preset Dropdown */
.hb-preset-select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: #f5f5f5;
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  cursor: pointer;
  min-width: 100px;
}

.hb-preset-select:hover {
  border-color: rgba(255, 255, 255, 0.3);
}

.hb-preset-select:focus {
  outline: none;
  border-color: rgba(138, 123, 255, 0.6);
}

/* Expandable Details */
.hb-image-card__details {
  display: none;
  padding: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
  animation: slideDown 0.2s ease-out;
}

.hb-image-card.is-expanded .hb-image-card__details {
  display: block;
}

.hb-image-card__expand-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  padding: 0.35rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hb-image-card__expand-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
}

.hb-image-card__expand-btn svg {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
}

.hb-image-card.is-expanded .hb-image-card__expand-btn svg {
  transform: rotate(180deg);
}

/* Visual Style Previews */
.hb-style-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hb-style-option:hover {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
}

.hb-style-option.is-active {
  border-color: rgba(138, 123, 255, 0.6);
  background: rgba(138, 123, 255, 0.15);
}

.hb-style-preview {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: linear-gradient(135deg, #8a7bff 50%, #e8dfd2 50%);
  flex-shrink: 0;
}

.hb-style-preview--multiply {
  background: linear-gradient(135deg, #5a4db3 50%, #c9bba5 50%);
}

.hb-style-preview--screen {
  background: linear-gradient(135deg, #c4bcff 50%, #f5f0e8 50%);
}

.hb-style-preview--overlay {
  background: linear-gradient(135deg, #7a6be6 50%, #ddd2c0 50%);
}

.hb-style-preview--darken {
  background: linear-gradient(135deg, #6b5cb3 50%, #b8a890 50%);
}

.hb-style-preview--rounded {
  border-radius: 8px;
  background: #8a7bff;
}

.hb-style-preview--feathered {
  background: radial-gradient(circle, #8a7bff 40%, transparent 70%);
}

.hb-style-preview--none {
  border-radius: 0;
  background: #8a7bff;
}

.hb-style-name {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.8);
}

.hb-style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.hb-detail-section {
  margin-bottom: 0.75rem;
}

.hb-detail-section:last-child {
  margin-bottom: 0;
}

.hb-detail-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
}

/* Width Slider Compact */
.hb-width-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hb-width-control input[type="range"] {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  cursor: pointer;
}

.hb-width-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: #8a7bff;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.hb-width-control input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.hb-width-value {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
  min-width: 36px;
  text-align: right;
}

/* Detail Inputs */
.hb-detail-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  color: #f5f5f5;
  transition: border-color 0.15s ease;
}

.hb-detail-input:focus {
  outline: none;
  border-color: rgba(138, 123, 255, 0.6);
}

.hb-detail-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

/* Empty State */
.hb-empty-state {
  text-align: center;
  padding: 1rem;
  color: rgba(255, 255, 255, 0.5);
}

.hb-empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 0.5rem;
  opacity: 0.4;
}

.hb-empty-state p {
  margin: 0;
  font-size: 0.85rem;
}

.hb-empty-hint {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 0.35rem;
  font-style: italic;
}

.hb-empty-upload {
  margin-top: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.hb-empty-upload .hb-btn-icon {
  width: 16px;
  height: 16px;
}

/* ========================================
   UX IMPROVEMENTS V2 - COMPREHENSIVE UPDATE
   ======================================== */

/* Status Pills (replacing progress bar) */
.hb-status-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.hb-status-pills {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.hb-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  transition: all 0.2s ease;
}

.hb-status-pill .hb-status-check {
  width: 12px;
  height: 12px;
  opacity: 0;
  color: #86f3ba;
  transition: opacity 0.2s ease;
}

.hb-status-pill.is-done {
  background: rgba(134, 243, 186, 0.15);
  border-color: rgba(134, 243, 186, 0.4);
  color: #86f3ba;
}

.hb-status-pill.is-done .hb-status-check {
  opacity: 1;
}

/* Panel Toggle Improvements */
.hb-panel__toggle {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #f0e5d8;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

.hb-panel__toggle:hover {
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
  border-color: rgba(255, 255, 255, 0.15);
}

.hb-panel__toggle:focus-visible {
  outline: 2px solid rgba(138, 123, 255, 0.6);
  outline-offset: 2px;
}

.hb-panel__toggle-icon {
  width: 18px;
  height: 18px;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.hb-panel__toggle:focus {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.hb-panel--collapsible.is-open .hb-panel__toggle-icon {
  transform: rotate(180deg);
}

/* Toolbar Button Improvements */
.hb-toolbar-btn {
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  transition: all 0.15s ease;
}

.hb-toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.hb-toolbar-btn:focus-visible {
  outline: 2px solid rgba(138, 123, 255, 0.6);
  outline-offset: 2px;
}

.hb-toolbar-btn .hb-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.hb-toolbar-btn .hb-icon svg {
  width: 18px;
  height: 18px;
}

/* Menu Trigger with Chevron */
.hb-menu__trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
}

.hb-menu__trigger .hb-icon {
  display: flex;
}

.hb-menu__trigger .hb-icon svg {
  width: 16px;
  height: 16px;
}

.hb-menu__trigger .hb-btn-label {
  font-size: 0.82rem;
}

.hb-menu__chevron {
  display: flex;
  margin-left: 0.15rem;
  transition: transform 0.2s ease;
}

.hb-menu__chevron svg {
  width: 14px;
  height: 14px;
  opacity: 0.6;
}

.hb-menu.is-open .hb-menu__chevron {
  transform: rotate(180deg);
}

/* Export Stack Layout */
.hb-export-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.hb-export-btn--primary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  font-weight: 600;
}

.hb-export-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.hb-export-btn--secondary {
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  justify-content: center;
}

/* Print Toggle Split Button */
.hb-print-toggle-split {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  padding: 0.2rem 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
}

.hb-print-toggle-split input {
  accent-color: #8a7bff;
  margin: 0;
}

.hb-print-toggle-split:hover {
  background: rgba(0, 0, 0, 0.3);
}

.hb-print-toggle-label {
  color: rgba(255, 255, 255, 0.85);
}

/* Modal Dialog Styles */
.hb-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 1000;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.hb-modal {
  background: linear-gradient(145deg, #1a1d2e, #12141f);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 1.5rem;
  width: min(400px, 90vw);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
  animation: modalSlideIn 0.25s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.hb-modal__title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: #f5f5f5;
}

.hb-modal__message {
  margin: 0 0 1.25rem;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.5;
}

.hb-modal__actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.hb-modal__btn {
  padding: 0.5rem 1rem;
  font-weight: 600;
  border-radius: 8px;
  transition: all 0.15s ease;
}

.hb-modal__btn:focus-visible {
  outline: 2px solid rgba(138, 123, 255, 0.6);
  outline-offset: 2px;
}

.hb-modal__btn--default {
  background: linear-gradient(135deg, #8a7bff, #6b5ce7);
  border: none;
  color: white;
}

.hb-modal__btn--default:hover {
  background: linear-gradient(135deg, #9d90ff, #7d6ef0);
}

.hb-modal__btn--danger {
  background: linear-gradient(135deg, #e53935, #c62828);
  border: none;
  color: white;
}

.hb-modal__btn--danger:hover {
  background: linear-gradient(135deg, #ef5350, #e53935);
}

/* Toast Notifications - Top Center */
.hb-toast-container--top {
  position: fixed;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  bottom: auto;
  right: auto;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  align-items: center;
}

.hb-toast-container--top .hb-toast {
  animation: toastInTop 0.25s ease-out;
}

.hb-toast-container--top .hb-toast.is-leaving {
  animation: toastOutTop 0.2s ease-in forwards;
}

@keyframes toastInTop {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toastOutTop {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }
}

/* Theme Picker Selection Feedback */
.hb-theme-option.active {
  background: rgba(138, 123, 255, 0.2);
  border-color: #8a7bff;
  box-shadow: 0 0 0 2px rgba(138, 123, 255, 0.3);
  position: relative;
}

.hb-theme-option.active::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 18px;
  height: 18px;
  background: #8a7bff;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.hb-theme-option.active::before {
  content: '✓';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 18px;
  height: 18px;
  color: white;
  font-size: 11px;
  font-weight: bold;
  z-index: 1;
  display: grid;
  place-items: center;
}

/* Drop Zone Improvements */
.hb-drop-inline--passive {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.2);
  background: transparent;
  padding: 0.65rem;
  transition: all 0.2s ease;
}

.hb-drop-inline--passive:hover,
.hb-drop-inline--passive.is-drag-over {
  border-color: rgba(140, 236, 247, 0.5);
  background: rgba(140, 236, 247, 0.05);
}

.hb-drop-inline--passive .hb-drop-icon-svg {
  width: 24px;
  height: 24px;
}

.hb-drop-inline--passive p {
  font-size: 0.8rem;
}

/* Canvas Drop Overlay - Primary */
.hb-drop-overlay {
  background: rgba(138, 123, 255, 0.15);
  border: 3px dashed rgba(138, 123, 255, 0.6);
}

.hb-drop-overlay.is-active {
  opacity: 1;
  pointer-events: auto;
}

/* Focus States - Global */
.btn:focus-visible,
button:focus-visible {
  outline: 2px solid rgba(138, 123, 255, 0.6);
  outline-offset: 2px;
}

.hb-theme-option:focus-visible {
  outline: 2px solid rgba(138, 123, 255, 0.6);
  outline-offset: 2px;
}

.hb-image-card:focus-within {
  border-color: rgba(138, 123, 255, 0.4);
}

.hb-detail-input:focus-visible,
.hb-preset-select:focus-visible {
  outline: 2px solid rgba(138, 123, 255, 0.6);
  outline-offset: 2px;
  border-color: transparent;
}

/* Writing Stats Improvements */
.hb-writing-stats {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.6);
  margin: 0.25rem 0 0.5rem;
}

/* Upload Button Style */
.hb-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

/* Zoom Controls */
.hb-canvas {
  overflow: visible;
  min-height: calc(11in + 3rem);
}

.hb-page {
  transition: transform 0.2s ease;
}

/* Mobile Improvements */
@media (max-width: 1100px) {
  .hb-panel__toggle {
    display: flex;
  }

  .hb-status-bar {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
  }

  .hb-status-pills {
    order: 1;
  }

  .hb-autosave-pill {
    order: 2;
  }

  .hb-editor-bar__compact {
    flex-direction: column;
    gap: 0.75rem;
  }

  .hb-editor-toolbar {
    order: 2;
    width: 100%;
    justify-content: center;
  }

  .hb-export-stack {
    gap: 0.75rem;
  }
}

@media (max-width: 640px) {
  .hb-toolbar-group {
    width: 100%;
    justify-content: center;
    padding-right: 0;
    margin-right: 0;
    border-right: none;
  }

  .hb-toolbar-group::after {
    display: none;
  }

  .hb-menu__list {
    position: fixed;
    left: 1rem;
    right: 1rem;
    top: auto;
    bottom: 1rem;
    max-height: 60vh;
    overflow-y: auto;
    width: auto;
    border-radius: 16px;
    background: rgba(20, 20, 30, 0.98);
  }

  .hb-status-pills {
    gap: 0.25rem;
  }

  .hb-status-pill {
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
  }

  .hb-status-pill .hb-status-check {
    width: 10px;
    height: 10px;
  }

  .hb-modal {
    margin: 1rem;
    width: calc(100vw - 2rem);
  }

  .hb-body {
    column-count: 1;
  }

  .hb-figure {
    width: 100% !important;
    float: none !important;
    margin: 1rem 0 !important;
  }
}

/* Keyboard Shortcut Hints in Tooltips */
[title*="Ctrl"] {
  cursor: pointer;
}

/* Accessible Button Label Class */
.hb-btn-label {
  font-size: 0.82rem;
}

/* Image Card Simplification - Collapsed by Default */
.hb-image-card__details {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.2s ease;
  padding: 0 0.75rem;
}

.hb-image-card.is-expanded .hb-image-card__details {
  max-height: 800px;
  opacity: 1;
  padding: 0.75rem;
}

/* Improved Menu Item Styling */
.hb-menu__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.hb-menu__item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.hb-menu__item:focus-visible {
  outline: 2px solid rgba(138, 123, 255, 0.6);
  outline-offset: -2px;
}

/* Smooth scrollbar for panels */
.hb-panel__content {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.hb-panel__content::-webkit-scrollbar {
  width: 6px;
}

.hb-panel__content::-webkit-scrollbar-track {
  background: transparent;
}

.hb-panel__content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.hb-panel__content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}
