[x-cloak] {
    display: none !important;
}

.dashboard-header {
    gap: 18px;
}

.dashboard-header h1 {
    flex: 0 0 auto;
    white-space: nowrap;
}

.dashboard-dock {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    min-width: 0;
    flex: 1 1 auto;
}

/* The dock is a vertical stack of rows the user arranges. Each .dock-row is one
   horizontal line of icons; the header grows to fit however many rows there are
   and a ResizeObserver mirrors the real height into --header-height so the page
   content stays pinned just below. flex: 0 1 auto so the rows hug their content
   and the tools (Edit / row stepper / Auto-fit) sit inline to the right. */
.dock-items {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    min-width: 0;
    max-width: 100%;
    flex: 0 1 auto;
}

.dock-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    min-width: 0;
    max-width: 100%;
}

/* Edit mode: outline each row as a drop zone and label empty rows so it is
   obvious icons can be dragged into any row, including a freshly added one. */
.dock-editing .dock-items {
    gap: 10px;
}

.dock-editing .dock-row {
    min-height: 46px;
    padding: 4px 8px;
    border: 1px dashed rgba(148, 163, 184, 0.35);
    border-radius: 10px;
    background: rgba(148, 163, 184, 0.06);
}

.dock-editing .dock-row::after {
    content: "Drop icons here";
    order: -1;
    margin-right: auto;
    align-self: center;
    color: #64748b;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
    opacity: 0.65;
    pointer-events: none;
}

.dock-editing .dock-row:not(:empty)::after {
    display: none;
}

.dock-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    flex: 0 0 auto;
    border-radius: 9px;
    touch-action: manipulation;
    user-select: none;
    transition: transform 0.16s ease, opacity 0.16s ease, filter 0.16s ease, background 0.16s ease;
}

.dock-item > a,
.dock-item > button,
.dock-item > div:not(.dock-folder-popover) {
    flex: 0 0 auto;
}

.dock-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.dock-item.dock-hidden,
.dock-item.dock-unavailable,
.dock-hidden-bin {
    display: none !important;
}

.dock-item.dock-pressing {
    transform: scale(0.96);
}

.dock-editing .dock-item:not(.dock-sort-ghost):not(.dock-sort-drag),
.dock-item.dock-wobble {
    animation: dockWobble 0.26s ease-in-out infinite alternate;
}

.dock-editing .dock-item:nth-child(2n),
.dock-item.dock-wobble:nth-child(2n) {
    animation-direction: alternate-reverse;
}

@keyframes dockWobble {
    0% {
        transform: rotate(-1.4deg) translateY(0);
    }
    100% {
        transform: rotate(1.4deg) translateY(-1px);
    }
}

.dock-remove {
    position: absolute;
    top: -7px;
    right: -7px;
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    padding: 0 !important;
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
    border-radius: 50% !important;
    background: #ef4444 !important;
    color: #fff !important;
    font-size: 14px !important;
    line-height: 16px !important;
    font-weight: 700 !important;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 20;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
}

.dock-editing .dock-remove {
    display: inline-flex;
}

.dock-remove:hover {
    background: #dc2626 !important;
    border-color: rgba(255, 255, 255, 0.7) !important;
}

.dock-sort-ghost {
    opacity: 0.45 !important;
    background: rgba(74, 158, 255, 0.14) !important;
    outline: 1px dashed rgba(74, 158, 255, 0.55);
}

.dock-sort-chosen {
    cursor: grabbing;
}

.dock-sort-drag {
    opacity: 0.92 !important;
    transform: scale(1.08) !important;
    background: rgba(20, 20, 20, 0.92) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.dock-folder-target {
    background: rgba(74, 158, 255, 0.16) !important;
    outline: 1px solid rgba(74, 158, 255, 0.65);
    transform: scale(1.06);
}

.dock-folder {
    min-width: 42px;
}

.dock-folder-button {
    width: 38px;
    height: 34px;
    padding: 0 !important;
    border: 1px solid rgba(148, 163, 184, 0.32) !important;
    border-radius: 8px !important;
    background: rgba(30, 41, 59, 0.72) !important;
    color: #e2e8f0 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.dock-folder-icon {
    display: grid;
    grid-template-columns: repeat(2, 10px);
    grid-template-rows: repeat(2, 10px);
    gap: 2px;
}

.dock-folder-mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: rgba(148, 163, 184, 0.2);
    color: #cbd5e1;
    font-size: 7px;
    line-height: 1;
    overflow: hidden;
}

.dock-folder-popover {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: min(360px, calc(100vw - 24px));
    padding: 14px;
    border: 1px solid rgba(148, 163, 184, 0.26);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.98);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(12px);
    z-index: 9998;
    display: none;
}

.dock-folder-open .dock-folder-popover {
    display: block;
}

.dock-folder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.dock-folder-title {
    min-width: 0;
    color: #f8fafc;
    font-size: 13px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dock-folder-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.dock-folder-action {
    height: 26px;
    padding: 0 8px !important;
    border-radius: 6px !important;
    border: 1px solid rgba(148, 163, 184, 0.24) !important;
    background: rgba(30, 41, 59, 0.86) !important;
    color: #cbd5e1 !important;
    font-size: 11px !important;
    cursor: pointer;
}

.dock-folder-action:hover {
    background: rgba(51, 65, 85, 0.92) !important;
    border-color: rgba(148, 163, 184, 0.44) !important;
}

.dock-folder-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
    gap: 12px;
    align-items: center;
}

.dock-folder-items .dock-item {
    min-height: 52px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(148, 163, 184, 0.1);
}

.dock-tools {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.dock-edit-toggle,
.dock-restore-button,
.dock-reset-button,
.dock-autofit-button {
    height: 30px;
    padding: 0 10px !important;
    border-radius: 999px !important;
    border: 1px solid rgba(148, 163, 184, 0.28) !important;
    background: rgba(30, 41, 59, 0.52) !important;
    color: #cbd5e1 !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    white-space: nowrap;
    cursor: pointer;
}

.dock-edit-toggle:hover,
.dock-restore-button:hover,
.dock-reset-button:hover {
    background: rgba(51, 65, 85, 0.85) !important;
    border-color: rgba(148, 163, 184, 0.48) !important;
}

/* Rows stepper (− N rows +) and Auto-fit — shown only while editing. */
.dock-rows-control {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 999px;
    background: rgba(30, 41, 59, 0.52);
}

.dock-rows-control[hidden],
.dock-autofit-button[hidden] {
    display: none !important;
}

.dock-rows-btn {
    width: 24px;
    height: 24px;
    padding: 0 !important;
    border-radius: 50% !important;
    border: 1px solid rgba(148, 163, 184, 0.3) !important;
    background: rgba(15, 23, 42, 0.6) !important;
    color: #cbd5e1 !important;
    font-size: 16px !important;
    line-height: 1 !important;
    font-weight: 700 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.dock-rows-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.dock-rows-btn:not(:disabled):hover {
    background: rgba(51, 65, 85, 0.85) !important;
    border-color: rgba(148, 163, 184, 0.48) !important;
}

.dock-rows-label {
    min-width: 48px;
    text-align: center;
    color: #cbd5e1;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.dock-autofit-button {
    border-color: rgba(96, 165, 250, 0.4) !important;
    background: rgba(37, 99, 235, 0.18) !important;
    color: #bfdbfe !important;
}

.dock-autofit-button:hover {
    background: rgba(37, 99, 235, 0.3) !important;
    border-color: rgba(96, 165, 250, 0.6) !important;
}

.dock-editing .dock-edit-toggle {
    color: #bfdbfe !important;
    border-color: rgba(96, 165, 250, 0.48) !important;
    background: rgba(37, 99, 235, 0.2) !important;
}

.dock-restore {
    position: relative;
}

.dock-restore-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 220px;
    padding: 8px;
    border: 1px solid rgba(148, 163, 184, 0.26);
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.98);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
    z-index: 9999;
}

.dock-restore-menu button {
    width: 100%;
    min-height: 30px;
    justify-content: flex-start !important;
    text-align: left;
    padding: 6px 9px !important;
    border-radius: 6px !important;
    border: 0 !important;
    background: transparent !important;
    color: #cbd5e1 !important;
    font-size: 12px !important;
}

.dock-restore-menu button:hover {
    background: rgba(148, 163, 184, 0.12) !important;
    color: #f8fafc !important;
}

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

@media (max-width: 1180px) {
    .dashboard-header {
        padding: 0 14px;
    }

    .dock-items {
        gap: 6px;
    }

    .dock-edit-toggle,
    .dock-restore-button {
        width: 30px;
        min-width: 30px;
        padding: 0 !important;
        overflow: hidden;
        color: transparent !important;
    }

    .dock-edit-toggle::before {
        content: "...";
        color: #cbd5e1;
    }

    .dock-restore-button::before {
        content: "+";
        color: #cbd5e1;
        font-size: 16px;
    }
}

@media (max-width: 860px) {
    .dashboard-header h1 {
        font-size: 16px;
    }

    .dashboard-header h1 img {
        width: 26px !important;
        height: 26px !important;
    }

    /* On phones, pack the rows from the left and let each row wrap. */
    .dock-items {
        align-items: stretch;
    }

    .dock-row {
        justify-content: flex-start;
    }
}
