/* ==========================================================================
   Dropdown menus and popovers (file, paragraph style, more tools,
   table picker, link dialog)
   ========================================================================== */

.popover {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    margin: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-pop);
    color: var(--text);
    animation: popover-in 0.12s ease-out;
}

@keyframes popover-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
}

/* --- Menus --------------------------------------------------------------- */

.menu {
    width: 240px;
    max-height: calc(100vh - 96px);
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.menu-item {
    height: 38px;
    flex: none;
    padding: 0 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-control);
    font-size: 14px;
    text-align: left;
    white-space: nowrap;
}

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

.menu-item[aria-disabled="true"] {
    opacity: 0.45;
    cursor: default;
}

.menu-item > svg {
    color: var(--muted);
}

.menu-kbd {
    margin-left: auto;
    padding-left: 12px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 400;
    letter-spacing: 0;
    color: var(--muted-2);
}

.menu-sep {
    height: 1px;
    flex: none;
    margin: 4px 8px;
    background: var(--border-soft);
}

/* Check slot used by radio / checkbox items */
.menu-check {
    width: 16px;
    height: 16px;
    flex: none;
    display: grid;
    place-items: center;
    color: var(--accent);
}

.menu-check svg {
    visibility: hidden;
}

[aria-checked="true"] > .menu-check svg {
    visibility: visible;
}

/* Compact menus: paragraph style and more tools */
.menu-styles,
.menu-compact {
    gap: 1px;
}

.menu-compact .menu-item {
    height: 34px;
}

/* Groups in the more menu; a rule separates each shown group from the
   one above it */
.menu-group {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.menu-group:not([hidden]) ~ .menu-group::before {
    content: "";
    height: 1px;
    flex: none;
    margin: 4px 8px;
    background: var(--border-soft);
}

/* Paragraph style menu: each item previews its own size */
.menu-styles .menu-item {
    gap: 8px;
    font-weight: 600;
    color: var(--text-strong);
}

.menu-styles [aria-checked="true"] {
    background: var(--hover);
}

.menu-styles .style-p {
    height: 34px;
    font-weight: 400;
    color: var(--text-control);
}

.menu-styles .style-h1 {
    height: 42px;
    font-size: 21px;
    letter-spacing: -0.02em;
}

.menu-styles .style-h2 {
    height: 40px;
    font-size: 18px;
    letter-spacing: -0.01em;
}

.menu-styles .style-h3 {
    font-size: 16px;
}

.menu-styles .style-h4 {
    height: 36px;
    font-size: 15px;
}

.menu-styles .style-h5 {
    height: 34px;
    font-size: 14px;
}

.menu-styles .style-h6 {
    height: 34px;
    font-size: 13px;
    color: var(--text-soft);
}

/* --- Dialog-style popovers ---------------------------------------------- */

.popover-dialog {
    width: 300px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.popover-table {
    width: 272px;
}

.popover-title {
    font-size: 14.5px;
    font-weight: 600;
}

.picker-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.picker-size {
    font-size: 13px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.table-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 4px;
}

.table-cell {
    height: 26px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-muted);
    transition: background-color 0.08s ease, border-color 0.08s ease;
}

.table-cell.is-on {
    border-color: var(--accent);
    background: var(--accent-tint);
}

.table-cell:hover {
    border-color: var(--text);
}

.table-cell:focus-visible {
    outline-offset: 1px;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
