/* ========================================
   Cigar Corgis Hot Box Styles
   ========================================

   Table of contents
   1. Design tokens
   2. Base elements
   3. Layout helpers
   4. Forms
   5. Buttons and actions
   6. Navigation
   7. Character pages
   8. Campaign pages
   9. Notes and Markdown
   10. Markdown example modal
   11. Images and uploads
   12. Image lightbox
   13. Responsive adjustments
   14. Flash messages
*/


/* ========================================
   1. Design tokens
   ======================================== */

:root {
    /* Surfaces */
    --color-page-bg: #101014;
    --color-surface: #191922;
    --color-surface-muted: #232330;

    /* Text */
    --color-text: #f4efe3;
    --color-text-muted: #aaa093;
    --color-heading: #f0a33a;
    --color-note-title: #ffc766;

    /* Brand */
    --color-primary: #f0a33a;
    --color-primary-hover: #d98f25;

    /* Actions */
    --color-link-button: #f0a33a;
    --color-link-button-hover: #d98f25;

    --color-edit: #4b7bec;
    --color-edit-hover: #3867d6;

    --color-danger: #b7413e;
    --color-danger-hover: #8e2e2c;

    /* Borders */
    --color-border: #3b3b4f;
    --color-border-muted: #2c2c36;

    /* Theme */
    --color-paper: #d8c59a;
    --color-paper-dark: #8a6f3f;

    --color-accent: #f0a33a;
    --color-accent-glow: rgba(240, 163, 58, .35);

    --color-shadow: rgba(0, 0, 0, .45);

    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.35);
    --shadow-image-hover: 0 6px 18px rgba(0, 0, 0, 0.25);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-xl: 12px;
    --radius-modal: 12px;

    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 20px;
    --space-2xl: 24px;
    --space-3xl: 30px;

    --container-width: 900px;
    --form-width: 500px;

    --mobile-breakpoint: 800px;
}


/* ========================================
   2. Base elements
   ======================================== */

body {
    margin: 0;
    padding: 0;
    background-color: var(--color-page-bg);
    color: var(--color-text);
    font-family: Arial, sans-serif;
}

h1 {
    margin-bottom: var(--space-3xl);
    color: var(--color-heading);
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: none;
}

ul {
    padding-left: 25px;
}

li {
    margin-bottom: var(--space-md);
}

p {
    margin-bottom: var(--space-xl);
}


/* ========================================
   3. Layout helpers
   ======================================== */

.container {
    max-width: var(--container-width);
    margin: 40px auto;
    padding: var(--space-xl);
}

.page-header {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.page-header h1 {
    margin: 0;
}

.inline-form {
    display: inline;
    margin: 0;
}


/* ========================================
   4. Forms
   ======================================== */

label {
    display: block;
    margin-bottom: var(--space-sm);
    font-weight: bold;
}

input,
select,
textarea {
    width: 100%;
    max-width: var(--form-width);
    box-sizing: border-box;
    padding: var(--space-md);
    border: 1px solid #cccccc;
    border-radius: var(--radius-sm);
    font-size: 16px;
}

textarea {
    font-size: 1rem;
}

input[type="checkbox"] {
    width: auto;
    max-width: none;
    padding: 0;
}

/* ========================================
   5. Buttons and actions
   ======================================== */

button,
.button-link,
.edit-button,
.delete-button {
    border: none;
    color: #ffffff;
    cursor: pointer;
    text-decoration: none;
}

button {
    padding: var(--space-md) var(--space-2xl);
    border-radius: var(--radius-sm);
    background-color: var(--color-primary);
    font-size: 16px;
}

button:hover {
    background-color: var(--color-primary-hover);
}

.button-link {
    display: inline-block;
    margin-top: var(--space-lg);
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-xl);
    background-color: var(--color-link-button);
    font-size: 10px;
    font-weight: bold;
}

.button-link:hover {
    background-color: var(--color-link-button-hover);
}

.edit-button,
.delete-button {
    padding: 6px 10px;
    font-size: 10px;
}

.edit-button {
    border-radius: var(--radius-md);
    background-color: var(--color-edit);
}

.edit-button:hover {
    background-color: var(--color-edit-hover);
}

.delete-button {
    border-radius: var(--radius-lg);
    background-color: var(--color-danger);
}

.delete-button:hover {
    background-color: var(--color-danger-hover);
}

.delete-image-button {
    margin: 0;
    padding: 5px 7px;
    background-color: rgba(185, 28, 28, 0.42);
    backdrop-filter: blur(3px);
    font-size: 0.75rem;
}

.delete-image-button:hover {
    background-color: rgba(153, 27, 27, 0.68);
}


/* ========================================
   6. Navigation
   ======================================== */

.menu-container {
    position: fixed;
    top: var(--space-md);
    left: var(--space-md);
    z-index: 1000;

    display: inline-block;
}

.menu-button {
    padding: 8px 12px;

    border: none;
    border-radius: var(--radius-md);

    background: var(--color-primary);
    color: var(--color-text);

    font-size: 1rem;
    cursor: pointer;
}

.menu-button:hover,
.menu-button:focus-visible {
    background: var(--color-primary-hover);
    outline: none;
}

.menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 1001;

    display: none;
    min-width: 200px;

    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);

    background: var(--color-surface);
    box-shadow: var(--shadow-card);

    overflow: visible;
}

.menu-dropdown::before {
    content: "";
    position: absolute;
    top: -8px;
    left: 0;

    width: 100%;
    height: 8px;
}

.menu-dropdown a,
.menu-dropdown form button {
    display: block;
    width: 100%;
    padding: 14px 18px;

    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--color-text);
    font: inherit;
    text-align: left;
    text-decoration: none;
}

.menu-dropdown a:first-child {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.menu-dropdown > :last-child,
.menu-dropdown > :last-child button {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.menu-dropdown a:hover,
.menu-dropdown a:focus-visible,
.menu-dropdown form button:hover,
.menu-dropdown form button:focus-visible {
    background: rgba(240, 163, 58, 0.15);
    color: var(--color-accent);
    outline: none;
}

.menu-container:hover .menu-dropdown,
.menu-container:focus-within .menu-dropdown {
    display: block;
}

.nav-link {
    text-decoration: none;
}

.auth-panel {
    max-width: var(--form-width);
    margin: 0 auto;
}

.auth-panel form {
    display: grid;
    gap: var(--space-md);
}

.auth-panel button {
    justify-self: start;
}



/* ========================================
   7. Character pages
   ======================================== */

.character-summary {
    display: flex;
    gap: var(--space-3xl);
    margin-bottom: var(--space-3xl);
    font-size: 1.2rem;
}

.character-summary strong {
    color: #1f4b7a;
}

.character-stat {
    margin-bottom: 15px;
}

.ability-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px var(--space-xl);
    max-width: var(--form-width);
}

.character-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.character-actions form {
    margin: 0;
}


/* ========================================
   8. Campaign pages
   ======================================== */

.campaign-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    align-items: start;
    gap: 84px;
}

.campaign-title,
.campaign-sidebar {
    margin-left: -24px;
}

.campaign-list-item {
    display: flex;
    align-items: center;
    gap: 40px;
    width: 275px;
    margin-bottom: var(--space-lg);
    font-size: 20px;
}

.campaign-list-item a {
    flex-grow: 1;
}

.campaign-list-item .edit-button,
.campaign-list-item .delete-button,
.campaign-list-item .inline-form button {
    display: flex;
    align-items: center;
    gap: var(--space-3xl);
    padding: var(--space-xs) var(--space-sm);
    font-size: 10px;
}

.campaign-list-item .delete-button {
    width: auto;
    border-radius: var(--radius-xl);
}

.create-campaign-section {
    margin-top: var(--space-3xl);
}

.campaign-characters-section {
    margin-bottom: var(--space-3xl);
}

.campaign-characters-section h2 {
    margin: 0;
}

.campaign-character-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-md);
    margin-top: 1rem;
}

.campaign-character-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
}

.campaign-character-card:hover {
    border-color: var(--color-primary);
}

.campaign-character-link {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--space-xs);
    min-width: 0;
    color: var(--color-text);
    text-decoration: none;
}

.campaign-character-link span {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.campaign-character-delete-form {
    flex-shrink: 0;
    margin: 0;
}

.campaign-character-association-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.campaign-character-association-actions form {
    margin: 0;
}

.campaign-character-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 4px;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-danger);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}

.campaign-character-delete svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.campaign-character-card:hover .campaign-character-delete,
.campaign-character-card:focus-within .campaign-character-delete {
    opacity: 1;
    pointer-events: auto;
}

.campaign-character-delete:hover,
.campaign-character-delete:focus-visible {
    background: rgba(183, 65, 62, 0.18);
    color: #f28b88;
    outline: none;
}

.empty-character-message {
    margin: 1rem 0 0;
}

.character-menu-link {
    text-decoration: none;
}

.character-attach-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.character-selection-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    max-height: 50vh;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    border: 0;
}

.character-selection-list legend {
    margin-bottom: var(--space-md);
    font-weight: bold;
}

.character-selection-list label {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    margin: 0;
    padding: var(--space-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
}

.character-selection-list label:hover {
    border-color: var(--color-accent);
    background: rgba(240, 163, 58, 0.08);
}

.character-selection-list input {
    margin-top: 0.2rem;
}

.character-selection-list small {
    display: block;
    margin-top: var(--space-xs);
    color: var(--color-text-muted);
    font-weight: normal;
}


/* =====================================================
   Campaign Resources
   ===================================================== */

.campaign-resources-section {
    position: relative;
}


/* Heading ------------------------------------------------ */

.resource-heading-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-lg);
}

.resource-heading-row h2,
.resource-heading-row h3 {
    margin: 0;
}


/* Three-dot menu container ------------------------------- */

.resource-action-menu {
    position: relative;
    flex-shrink: 0;
}


/* Three-dot trigger -------------------------------------- */

.resource-menu-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 8px;

    width: 30px;
    height: 30px;
    padding: 0;

    border: 0;
    border-radius: var(--radius-sm);

    background: transparent;
    color: var(--color-text);

    font: inherit;
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1;

    cursor: pointer;
}

.resource-menu-trigger:hover,
.resource-menu-trigger:focus-visible {
    background: rgba(240, 163, 58, 0.16);
    color: var(--color-accent);
    outline: none;
}


/* Main dropdown ------------------------------------------ */

.resource-menu-dropdown {
    position: absolute;
    top: 0;
    left: calc(100% - 2px);
    z-index: 1000;

    display: none;
    width: 198px;

    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);

    background: var(--color-surface);
    color: var(--color-text);

    overflow: visible;

    box-shadow:
        8px 6px 18px rgba(0, 0, 0, .35);
}

.resource-menu-dropdown::before {
    content: "";
    position: absolute;
    top: 0;
    right: 100%;
    width: 8px;
    height: 100%;
}

.resource-menu-panel {
    background: var(--color-surface);

    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);

    box-shadow: var(--shadow-card);
}

/* Show main menu ----------------------------------------- */

.resource-action-menu:hover>.resource-menu-dropdown,
.resource-action-menu:focus-within>.resource-menu-dropdown {
    display: block;
}


/* Main menu items ---------------------------------------- */

.resource-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);

    width: 100%;
    min-height: 38px;
    padding: 8px 12px;

    border: 0;
    border-radius: 0;

    background: transparent;
    color: var(--color-text);

    font: inherit;
    font-size: 0.95rem;
    line-height: 1.2;
    text-align: left;

    cursor: pointer;
    box-sizing: border-box;
}

.resource-menu-item:hover,
.resource-menu-item:focus-visible {
    background: rgba(240, 163, 58, 0.16);
    color: var(--color-accent);
    outline: none;
}

.resource-menu-item:disabled {
    color: var(--color-text-muted);
    cursor: not-allowed;
    opacity: 0.65;
}

.resource-menu-item:disabled:hover {
    background: transparent;
    color: var(--color-text-muted);
}

.resource-menu-danger {
    color: var(--color-danger);
}

.resource-menu-danger:hover,
.resource-menu-danger:focus-visible {
    background: rgba(183, 65, 62, 0.18);
    color: #f28b88;
}

.resource-menu-dropdown> :first-child .resource-menu-item,
.resource-menu-dropdown>.resource-menu-item:first-child,
.note-menu-dropdown> :first-child {
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
}

.resource-menu-dropdown> :last-child .resource-menu-item,
.resource-menu-dropdown>.resource-menu-item:last-child,
.note-menu-dropdown> :last-child {
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}

/* Submenu container -------------------------------------- */

.resource-menu-group {
    position: relative;
}


/* Resource selection submenu ----------------------------- */

.resource-submenu {
    position: absolute;
    top: -4px;
    left: calc(100% - 2px);
    z-index: 1010;

    display: none;

    width: 190px;
    max-height: 220px;
    overflow-x: visible;
    overflow-y: auto;

    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);

    background: var(--color-surface);
    color: var(--color-text);

    box-shadow: var(--shadow-card);
}

.resource-submenu::before {
    content: "";
    position: absolute;
    top: 0;
    right: 100%;
    width: 8px;
    height: 100%;
}


/* Show submenu ------------------------------------------- */

@media (min-width: 801px) {

    .resource-menu-group:hover>.resource-submenu,
    .resource-menu-group:focus-within>.resource-submenu {
        display: block;
    }
}

@media (max-width: 800px) {
    .resource-menu-group.is-open>.resource-submenu {
        display: block;
    }
}


/* Submenu items ------------------------------------------ */

.resource-submenu-item {
    display: block;

    width: 100%;
    min-height: 36px;
    padding: 8px 12px;

    border: 0;
    border-radius: 0;


    background: transparent;
    color: var(--color-text);

    font: inherit;
    font-size: 0.95rem;
    line-height: 1.2;
    text-align: left;
    text-decoration: none;

    cursor: pointer;
    box-sizing: border-box;
}

.resource-submenu> :first-child,
.resource-submenu> :first-child .resource-submenu-item {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.resource-submenu> :last-child,
.resource-submenu> :last-child .resource-submenu-item {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.resource-submenu-item:hover,
.resource-submenu-item:focus-visible {
    background: rgba(240, 163, 58, 0.16);
    color: var(--color-accent);
    outline: none;
}

.resource-submenu-delete {
    color: var(--color-danger);
}

.resource-submenu-delete:hover,
.resource-submenu-delete:focus-visible {
    background: rgba(183, 65, 62, 0.18);
    color: #f28b88;
}


/* Prevent delete forms from adding spacing --------------- */

.resource-delete-form {
    margin: 0;
    padding: 0;
}


/* Resource list ------------------------------------------ */

.campaign-resource-list {
    margin-top: 1rem;
    padding: 14px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    background: var(--color-surface);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.campaign-resource-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.campaign-resource-table th,
.campaign-resource-table td {
    padding: 0.35rem 0;
    vertical-align: middle;
}

.campaign-resource-name {
    min-width: 0;
    padding-right: var(--space-md);
    overflow-wrap: anywhere;
}

.campaign-resource-shared-heading,
.campaign-resource-shared-control {
    width: 4.5rem;
    text-align: right;
}

.campaign-resource-shared-heading {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.visibility-toggle-form {
    display: flex;
    justify-content: flex-end;
    margin: 0;
}

.visibility-toggle-form input[type="checkbox"] {
    width: 1.15rem;
    height: 1.15rem;
    margin: 0;
    cursor: pointer;
    accent-color: var(--color-accent);
}

.visibility-toggle-form input[type="checkbox"]:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 3px;
}

.visibility-toggle-form input[type="checkbox"]:disabled {
    cursor: progress;
    opacity: 0.7;
}

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

.empty-resource-message {
    margin: 0;
}


/* Smaller screens ---------------------------------------- */

@media (max-width: 800px) {

    /*
       On a narrow screen, open the main menu underneath the
       dots instead of off the side of the screen.
    */
    .resource-menu-dropdown {
        top: calc(100% + 6px);
        right: 0;
        left: auto;
    }

    .resource-menu-dropdown::before {
        top: auto;
        right: 0;
        bottom: 100%;

        width: 100%;
        height: 10px;
    }

    /*
       Open the Edit/Delete resource lists to the left.
    */
    .resource-submenu {
        right: calc(100% + 8px);
        left: auto;
    }

    .resource-submenu::before {
        right: auto;
        left: 100%;
    }
}


/* Resource modal -------------------------------------------------------- */

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

.resource-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    background: rgba(0, 0, 0, 0.45);
}

.resource-modal-content {
    position: relative;
    width: min(520px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    padding: var(--space-xl);
    border-radius: var(--radius-modal);
    background: var(--color-surface);
    box-shadow: var(--shadow-modal);
}

.resource-modal-content textarea {
    min-height: 70px;
    resize: vertical;
}

.resource-modal-close,
.note-modal-close {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--color-text);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.resource-modal-close:hover,
.resource-modal-close:focus-visible,
.note-modal-close:hover,
.note-modal-close:focus-visible {
    background: var(--color-surface-muted);
    color: var(--color-text);
    outline: none;
}

.resource-link-wrapper {
    position: relative;
    display: inline-block;
}

.resource-tooltip {
    display: none;
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 12px;
    width: 280px;
    padding: 8px 10px;
    background: #222;
    color: white;
    border-radius: 6px;
    font-size: 0.9rem;
    line-height: 1.3;
    z-index: 1000;
}

.resource-link-wrapper:hover .resource-tooltip {
    display: block;
}

.resource-form {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.resource-form button {
    margin-top: 0.5rem;
    align-self: flex-start;
}


/* ========================================
   9. Notes and Markdown
   ======================================== */

.notes-column {
    min-width: 0;
}

.note-form-column textarea {
    max-width: 100%;
    height: 320px;
}

.note-card {
    margin: var(--space-md) 0;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
}

.note-card-header {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
}

.note-collapse-toggle {
    display: flex;
    flex: 1;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
    padding: 0;
    background: transparent;
    color: var(--color-text);
    font: inherit;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

.note-card-summary {
    flex: 1;
    min-width: 0;
}

.note-collapse-toggle:hover,
.note-collapse-toggle:focus-visible {
    background: transparent;
    color: var(--color-accent);
    outline: none;
}

.note-title {
    position: relative;
    min-width: 0;
    overflow: visible;
    color: var(--color-note-title);
    text-overflow: ellipsis;
}

.note-title-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    min-width: 0;
}

.note-title-row .note-title {
    flex: 0 1 auto;
}

.note-status-icons {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.85rem;
}

.favorite-star {
    color: var(--color-note-title);
}

.note-title-preview {
    position: absolute;
    top: calc(100% + 18px);
    left: 0;
    z-index: 200;
    display: none;
    width: min(380px, calc(100vw - 80px));
    max-height: 220px;
    padding: var(--space-md) var(--space-lg);
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface-muted);
    color: var(--color-text);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    font-size: 0.9rem;
    font-weight: 400;
    line-height: 1.4;
    pointer-events: none;
}

.note-title-preview p,
.note-title-preview ul,
.note-title-preview ol,
.note-title-preview blockquote {
    margin-top: 0;
    margin-bottom: var(--space-sm);
}

.note-title-preview h1,
.note-title-preview h2,
.note-title-preview h3,
.note-title-preview h4 {
    margin: 0 0 var(--space-sm);
    color: var(--color-text);
    font-size: 1rem;
}

.note-title .note-title-preview {
    color: var(--color-text);
}

.note-card.is-collapsed .note-title:hover>.note-title-preview,
.note-card.is-collapsed .note-title:focus-within>.note-title-preview {
    display: block;
}

.note-title * {
    color: inherit;
}

.note-title h1,
.note-title h2,
.note-title h3,
.note-title h4,
.note-title p {
    margin: 0;
    overflow: hidden;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-card.is-collapsed .note-title h1,
.note-card.is-collapsed .note-title h2,
.note-card.is-collapsed .note-title h3,
.note-card.is-collapsed .note-title h4,
.note-card.is-collapsed .note-title p {
    font-size: 1rem;
}

.note-collapse-indicator {
    width: 14px;
    flex-shrink: 0;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    text-align: center;
}

.note-collapse-indicator::before {
    content: "▶";
}

.note-collapse-toggle[aria-expanded="true"] .note-collapse-indicator::before {
    content: "▼";
}

.note-card-content[hidden] {
    display: none;
}

.note-card-content {
    margin-top: var(--space-sm);
    padding: 0 10px 6px 24px;
}

.note-card-menu {
    position: relative;
}

.note-card-controls,
.note-heading-controls {
    display: grid;
    grid-template-columns: 30px 4.5rem 30px;
    align-items: start;
    gap: var(--space-md);
    flex-shrink: 0;
}

.note-heading-controls {
    margin-right: 14px;
}

.note-gallery-column-spacer {
    display: block;
    width: 30px;
    height: 30px;
}

.note-shared-heading {
    align-self: center;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
}

.note-visibility-toggle {
    min-height: 30px;
    align-items: center;
    justify-content: center;
}

.note-card-gallery-trigger {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-muted);
}

.note-card-gallery-trigger svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
}

.note-card-gallery-trigger:hover,
.note-card-gallery-trigger:focus-visible {
    background: rgba(240, 163, 58, 0.16);
    color: var(--color-accent);
    outline: none;
}

.note-card-menu-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text);
    font: inherit;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1;
}

.note-card-menu-trigger:hover,
.note-card-menu-trigger:focus-visible {
    background: rgba(240, 163, 58, 0.16);
    color: var(--color-accent);
    outline: none;
}

.note-card-menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 100;
    display: none;
    width: 190px;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
}

.note-card-menu-trigger:hover+.note-card-menu-dropdown,
.note-card-menu-dropdown:hover,
.note-card-menu:focus-within>.note-card-menu-dropdown {
    display: block;
}

.note-card-menu-dropdown form {
    margin: 0;
}

.note-card-menu-item {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border-radius: 0;
    background: transparent;
    color: var(--color-text);
    font: inherit;
    text-align: left;
}

.note-card-menu-item:hover,
.note-card-menu-item:focus-visible {
    background: rgba(240, 163, 58, 0.16);
    color: var(--color-accent);
    outline: none;
}

.note-card-menu-separator {
    border-top: 1px solid var(--color-border);
}

.note-card-menu-danger {
    color: #f28b88;
}

.note-card-menu-danger:hover,
.note-card-menu-danger:focus-visible {
    background: rgba(183, 65, 62, 0.18);
    color: #ffaaa7;
}

.note-card-image-form {
    display: none;
}

.note-meta,
.note-card small {
    display: block;
    margin-top: 3px;
    overflow-wrap: anywhere;
    color: var(--color-text-muted);
    font-size: 0.78rem;
    font-weight: 400;
}

.note-text {
    margin-top: 10px;
    line-height: 1.35;
    white-space: normal;
}

.note-text p {
    margin: 0 0 6px;
}

.note-text ul,
.note-text ol {
    margin: var(--space-xs) 0 6px var(--space-xl);
    padding-left: 18px;
}

.note-text li {
    margin-bottom: 2px;
}

.note-text h1,
.note-text h2,
.note-text h3,
.note-text h4 {
    margin: 10px 0 var(--space-xs);
    color: var(--color-text);
    line-height: 1.15;
}

.note-text h1 {
    font-size: 1.75rem;
}

.note-text h2 {
    font-size: 1.45rem;
}

.note-text h3 {
    font-size: 1.2rem;
}

.note-text h4 {
    font-size: 1.05rem;
}

.note-text blockquote {
    margin: 6px 0;
}

.note-text hr {
    margin: var(--space-sm) 0;
}

.note-search {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 10px 36px 10px 10px;
    border: 1px solid #cccccc;
    border-radius: var(--radius-md);
    font-size: 1rem;
}

.search-results-count {
    margin-bottom: var(--space-md);
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.note-title-label-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.note-title-label-row label {
    margin: 0;
}

.markdown-example-button {
    margin: 0;
    padding: 3px 8px;
    font-size: 0.75rem;
}

.note-heading-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-lg);
}

.note-heading-row h2 {
    margin: 0;
}

.note-action-menu {
    position: relative;
    flex-shrink: 0;
}

.note-menu-trigger {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 30px;
    height: 30px;
    padding: 0;

    border: 0;
    border-radius: var(--radius-sm);

    background: transparent;
    color: var(--color-text);

    font: inherit;
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1;

    cursor: pointer;
}

.note-menu-trigger:hover,
.note-menu-trigger:focus-visible {
    background: rgba(240, 163, 58, 0.16);
    color: var(--color-accent);
    outline: none;
}

.note-modal-content h2 {
    margin-top: 0;
    margin-bottom: 1.25rem;
}

.note-form {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.note-form label {
    margin-bottom: 0;
}

.note-form small {
    margin-top: -.4rem;
}

.note-menu-dropdown {
    position: absolute;
    top: 0;
    right: calc(100% + var(--space-sm));
    z-index: 1000;

    display: none;
    width: 280px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);

    background: var(--color-surface);
    color: var(--color-text);

    box-shadow: var(--shadow-card);
}

.note-menu-dropdown::before {
    content: "";
    position: absolute;
    top: 0;
    left: 100%;
    width: calc(var(--space-sm) + 2px);
    height: 100%;
}

.note-action-menu:hover>.note-menu-dropdown,
.note-action-menu:focus-within>.note-menu-dropdown {
    display: block;
}

.note-menu-item {
    width: 100%;
    padding: 8px 12px;

    border: 0;
    border-radius: 0;


    background: transparent;
    color: var(--color-text);

    font: inherit;
    text-align: left;
    cursor: pointer;
    box-sizing: border-box;
}

.note-menu-item:hover,
.note-menu-item:focus-visible {
    background: rgba(240, 163, 58, 0.16);
    color: var(--color-accent);
    outline: none;
}

.note-menu-item[aria-pressed="true"] {
    background: rgba(240, 163, 58, 0.16);
    color: var(--color-accent);
}

.note-search-control {
    position: relative;
}

.note-search-clear {
    position: absolute;
    top: 50%;
    right: 6px;
    width: 26px;
    height: 26px;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    color: #55555f;
    font-size: 1.25rem;
    line-height: 1;
    transform: translateY(-50%);
}

.note-search-clear:hover,
.note-search-clear:focus-visible {
    background: rgba(0, 0, 0, 0.1);
    color: #202028;
    outline: none;
}

.note-search:placeholder-shown+.note-search-clear {
    visibility: hidden;
}

.note-search::-webkit-search-cancel-button {
    appearance: none;
}

.note-menu-search {
    padding: var(--space-md);
    border-top: 1px solid var(--color-border-muted);
}

.note-menu-search label {
    margin-bottom: var(--space-sm);
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.note-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: var(--space-xl);
    background: rgba(0, 0, 0, 0.65);
}

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

.note-modal-content {
    position: relative;

    width: min(600px, 100%);
    max-height: 90vh;
    overflow-y: auto;

    padding: var(--space-2xl);

    border: 1px solid var(--color-border);
    border-radius: var(--radius-modal);

    background: var(--color-surface);
    color: var(--color-text);

    box-shadow: var(--shadow-modal);
}

/* ========================================
   10. Markdown example modal
   ======================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
}

.modal-overlay.active {
    display: flex;
}

.markdown-modal {
    display: flex;
    flex-direction: column;
    width: min(1100px, calc(100vw - 40px));
    max-height: calc(100vh - 40px);
    overflow: hidden;
    border-radius: var(--radius-modal);
    background: var(--color-surface);
    box-shadow: var(--shadow-modal);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-xl);
    padding: 18px 22px;
    border-bottom: 1px solid var(--color-border-muted);
    background: var(--color-surface-muted);
}

.modal-header h2 {
    margin: 0 0 var(--space-xs);
    color: var(--color-heading);
}

.modal-header p {
    margin: 0;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.modal-close {
    padding: 0 var(--space-sm);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--color-text);
    font-size: 30px;
    line-height: 1;
}

.modal-close:hover {
    background: var(--color-border-muted);
    color: #111111;
}

.markdown-example-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    min-height: 0;
    overflow: hidden;
}

.markdown-example-panel {
    max-height: calc(100vh - 140px);
    overflow: auto;
    padding: 18px 22px;
}

.markdown-example-panel:first-child {
    border-right: 1px solid var(--color-border-muted);
    background: #0f172a;
    color: #e5e7eb;
}

.markdown-example-panel h3 {
    margin-top: 0;
    text-align: center;
}

.markdown-example-panel pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.markdown-example-panel code {
    font-family: Consolas, Monaco, monospace;
    font-size: 0.9rem;
    line-height: 1.45;
}

.markdown-preview-example h1,
.markdown-preview-example h2,
.markdown-preview-example h3,
.markdown-preview-example p,
.markdown-preview-example li {
    margin-top: 0;
    margin-bottom: var(--space-sm);
}

.markdown-preview-example table {
    width: 100%;
    margin: 10px 0 14px;
    border-collapse: collapse;
}

.markdown-preview-example th,
.markdown-preview-example td {
    padding: var(--space-sm);
    border: 1px solid #d1d5db;
    text-align: left;
}

.markdown-preview-example blockquote {
    margin: var(--space-md) 0;
    padding-left: 14px;
    border-left: 4px solid #94a3b8;
    color: #475569;
}

/* ========================================
   11. Images and uploads
   ======================================== */

.note-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
    margin: var(--space-md) 0;
}

.note-image-wrapper {
    position: relative;
}

.note-image-wrapper>form {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 2;
    margin: 0;
}

.note-image-link {
    display: block;
}

.note-image {
    display: block;
    width: 100%;
    height: 180px;
    object-fit: cover;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.note-image:hover {
    transform: scale(1.03);
    box-shadow: var(--shadow-image-hover);
}

.drop-zone {
    display: block;
    padding: 15px;
    border: 2px dashed #aaaaaa;
    border-radius: var(--radius-lg);
    background: #f8f8f8;
}

.drop-zone.drag-over {
    border-color: #0d6efd;
    background: #eef4ff;
}

.drop-zone-text {
    display: block;
    margin-bottom: 10px;
    color: var(--color-text-muted);
}


/* ========================================
   12. Image lightbox
   ======================================== */

.image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    background: rgba(0, 0, 0, 0.85);
}

.image-lightbox.active {
    display: flex;
}

.image-lightbox img {
    max-width: 95%;
    max-height: 95%;
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.lightbox-close,
.lightbox-nav {
    z-index: 10000;
    border: none;
    background: rgba(0, 0, 0, 0.45);
    color: #ffffff;
    cursor: pointer;
}

.lightbox-close {
    position: absolute;
    top: var(--space-2xl);
    right: 32px;
    padding: 6px 14px;
    border-radius: var(--radius-md);
    font-size: 2rem;
}

.lightbox-close:hover,
.lightbox-nav:hover {
    background: rgba(0, 0, 0, 0.75);
}

.lightbox-navigation {
    position: absolute;
    bottom: var(--space-2xl);
    left: 50%;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 10px var(--space-lg);
    border-radius: var(--radius-lg);
    background: rgba(0, 0, 0, 0.45);
    transform: translateX(-50%);
}

.lightbox-nav {
    position: static;
    padding: var(--space-xs) 10px;
    border-radius: var(--radius-md);
    font-size: 1.8rem;
}

#lightbox-counter {
    min-width: 110px;
    color: #ffffff;
    text-align: center;
    font-size: 1rem;
}


/* ========================================
   13. Responsive adjustments
   ======================================== */

@media (max-width: 900px) {
    .container {
        margin: var(--space-3xl) auto;
    }

    .campaign-layout {
        grid-template-columns: 1fr;
        gap: var(--space-3xl);
    }

    .campaign-title,
    .campaign-sidebar {
        margin-left: 0;
    }
}

@media (max-width: 800px) {
    .markdown-example-grid {
        grid-template-columns: 1fr;
    }

    .markdown-example-panel:first-child {
        border-right: none;
        border-bottom: 1px solid var(--color-border-muted);
    }
}

@media (max-width: 600px) {

    .note-card-header {
        gap: var(--space-xs);
    }

    .note-card-controls,
    .note-heading-controls {
        gap: var(--space-xs);
    }

    .note-title-row {
        align-items: flex-start;
    }

    .note-title h1,
    .note-title h2,
    .note-title h3,
    .note-title h4,
    .note-title p {
        overflow-wrap: anywhere;
        white-space: normal;
    }

    .character-summary,
    .character-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .ability-grid {
        grid-template-columns: 1fr;
    }

    .campaign-list-item {
        width: 100%;
        gap: var(--space-md);
    }
}

/* ========================================
   14. Flash messages
   ======================================== */

.resource-modal-flashes,
.page-flashes {
    margin-bottom: 1rem;
}

.flash-message {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.flash-error {
    background: #ffe0e0;
    color: #7d1d1d;
}
.button-link {
    background: none;
    border: 0;
    color: var(--color-link, #5b4bdb);
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.note-text-readonly {
    font: inherit;
    margin: 0;
    overflow-wrap: anywhere;
    white-space: normal;
}

.archived-content-list {
    display: grid;
    gap: 0.75rem;
    list-style: none;
    padding: 0;
}

.archived-content-list li {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
