/* 壳层布局：body 沿用 base.css 的横向 flex，.workbench 顶替 #app-root 的位置。 */

/* 工作台宿主侧栏基础骨架；业务页面不加载这一层。 */
#app-header {
    display: none;
}

body[data-shell="host"] #app-header {
    display: block;
    flex: 0 0 var(--sidebar-width);
    width: var(--sidebar-width);
    min-height: 100vh;
    z-index: 50;
    transition: flex-basis 0.22s cubic-bezier(0.4, 0, 0.2, 1), width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

body[data-shell="host"] #app-header.is-sidebar-collapsed {
    flex-basis: var(--sidebar-width-collapsed);
    width: var(--sidebar-width-collapsed);
}

body[data-shell="host"] #app-header:empty {
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
}

.release-onboarding-overlay {
    display: flex;
    z-index: 1100;
}

.release-onboarding-dialog {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    width: min(840px, 94vw);
    max-height: 88vh;
    overflow-y: auto;
}

.release-onboarding-header {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: var(--space-3);
}

.release-onboarding-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}

.release-onboarding-header-main {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.release-onboarding-header h3,
.release-onboarding-header p,
.release-onboarding-step-content p {
    margin: 0;
}

.release-onboarding-steps {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.release-onboarding-step-card {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.release-onboarding-step-badge {
    flex-shrink: 0;
}

.release-onboarding-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    background: var(--tag-blue-bg);
    color: var(--tag-blue-text);
    border: 1px solid var(--tag-blue-border);
    font-weight: var(--weight-semibold);
}

.release-onboarding-step-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.release-onboarding-step-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.release-onboarding-subtext {
    color: var(--text-muted);
}

.release-onboarding-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
}

.release-onboarding-table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
}

.release-onboarding-table th,
.release-onboarding-table td {
    padding: var(--space-1) var(--space-2);
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border-color);
}

.release-onboarding-table tbody tr:last-child td {
    border-bottom: none;
}

.release-onboarding-table code {
    font-family: var(--font-mono);
    color: var(--primary);
    background: var(--bg-hover);
    padding: 1px 4px;
    border-radius: var(--radius-sm);
}

.release-onboarding-callout {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-sm);
}

.release-onboarding-callout code {
    font-family: var(--font-mono);
    font-weight: var(--weight-medium);
}

.release-onboarding-methods {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.release-onboarding-method-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.release-onboarding-method-item.is-primary {
    border-color: var(--primary-border);
    border-left: 3px solid var(--primary);
}

.release-onboarding-method-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.release-onboarding-error {
    min-height: 18px;
    color: var(--tag-red-text);
    margin: 0;
}

.release-onboarding-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    flex-wrap: wrap;
    border-top: 1px solid var(--border-color);
    padding-top: var(--space-3);
}

body[data-shell="host"] #app-header > .sidebar {
    width: 100%;
}

.sidebar {
    position: relative;
    width: var(--sidebar-width);
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    box-shadow: none;
    transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-width-collapsed);
}

.sidebar-header {
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 12px;
    border-bottom: 1px solid var(--border-color);
    flex: 0 0 auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
}

.sidebar-brand-icon {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #ffffff;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.15s ease, width 0.18s ease;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 0;
}

.sidebar-title {
    font-weight: var(--weight-semibold);
    color: var(--text-main);
    letter-spacing: -0.01em;
    line-height: 1.1;
    white-space: nowrap;
    transition: opacity 0.12s ease, width 0.18s ease;
}

.sidebar-title-sub {
    display: block;
    margin-top: 1px;
    color: var(--text-dim);
    font-weight: var(--weight-semibold);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .brand-text,
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .sidebar-link-text {
    width: 0;
    opacity: 0;
    display: none;
    overflow: hidden;
}

.sidebar-toggle {
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 26px;
    border: 1px solid transparent;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-main);
    border-color: var(--border-color);
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 8px;
    min-height: 0;
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    width: 100%;
    height: 34px;
    min-height: 34px;
    padding: 0 8px;
    border-radius: var(--radius-sm);
    text-align: left;
    text-decoration: none;
    overflow: hidden;
    font-weight: var(--weight-medium);
    color: var(--text-main);
    border: none;
    background: transparent;
    transition: all 0.15s ease;
    position: relative;
}

.sidebar-link:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.sidebar.collapsed .sidebar-link {
    justify-content: center;
    gap: 0;
    padding: 0;
}

.sidebar-link.active {
    background: var(--bg-selected);
    color: var(--primary-light);
    font-weight: var(--weight-semibold);
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.sidebar-toggle i {
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-icon {
    width: 18px;
    height: 18px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 18px;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-muted);
    font-weight: var(--weight-semibold);
    line-height: 1;
    transition: color 0.15s ease;
}

.sidebar-icon i {
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-icon svg {
    width: 16px;
    height: 16px;
    display: block;
}

.sidebar-link:hover .sidebar-icon {
    color: var(--text-main);
}

.sidebar-link.active .sidebar-icon {
    color: var(--primary);
}

.sidebar-link-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: opacity 0.12s ease, width 0.18s ease;
}

.section-btn {
    background: transparent;
    color: var(--text-muted);
    padding: 5px 14px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: var(--weight-medium);
    transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    position: relative;
}

.section-btn:hover {
    color: var(--text-main);
    background: rgba(17, 24, 39, 0.04);
}

.section-btn.active {
    background: var(--bg-selected);
    color: var(--primary-light);
    box-shadow: none;
}

.sidebar-toggle:focus-visible,
.section-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-bg);
}

.workbench {
    flex: 1;
    min-width: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-dark);
}

/* 顶部菜单条与标签栏容器 */
.workbench-header {
    flex: 0 0 auto;
    display: flex;
    align-items: stretch;
    height: 36px;
    background: var(--bg-tabbar);
    border-bottom: 1px solid var(--border-color);
    position: relative;
    z-index: 40;
}

/* 顶部标签栏 */
.workbench-tabbar {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 36px;
    padding: 0 8px;
    overflow-x: auto;
    overflow-y: hidden;
    user-select: none;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.workbench-tabbar::-webkit-scrollbar {
    display: none;
    height: 0;
    width: 0;
}

.workbench-header-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: stretch;
    border-left: 1px solid var(--border-color);
}

.workbench-onboarding-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 36px;
    padding: 0 8px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.workbench-onboarding-button:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.workbench-onboarding-button:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.workbench-tab {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 28px;
    min-height: 28px;
    padding: 0 6px 0 10px;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 5px 5px 0 0;
    background: transparent;
    color: var(--text-muted);
    font-weight: var(--weight-medium);
    white-space: nowrap;
    position: relative;
    transition: color 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
    cursor: pointer;
    flex-shrink: 0;
}

.workbench-tab:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.7);
}

.workbench-tab.active {
    background: var(--bg-card);
    color: var(--primary);
    font-weight: var(--weight-semibold);
    border-color: var(--border-color);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.workbench-tab.active::after {
    content: '';
    position: absolute;
    top: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
    border-radius: 2px 2px 0 0;
}

.workbench-tab-pin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    margin-right: 2px;
    color: var(--text-dim);
    flex-shrink: 0;
}

.workbench-tab-pin i {
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.workbench-tab-pin svg {
    display: block;
    width: 11px;
    height: 11px;
}

.workbench-tab-label {
    border: none;
    background: none;
    padding: 0 2px;
    font-weight: inherit;
    color: inherit;
    cursor: pointer;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.workbench-tab-label:focus-visible,
.workbench-tab-close:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.workbench-tab-close {
    border: none;
    background: none;
    width: 16px;
    height: 16px;
    margin-left: 2px;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.workbench-tab-close i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.workbench-tab-close:hover {
    background: #fee2e2;
    color: #ef4444;
}

.sidebar-leaf-row {
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
}

.sidebar-leaf-row .sidebar-leaf-main {
    flex: 1;
    width: auto;
    min-width: 0;
}

.sidebar-leaf-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.sidebar-leaf-action:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-main);
}

.sidebar-leaf-action:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.sidebar-leaf-action:disabled {
    cursor: default;
}

.sidebar-leaf-action i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.sidebar-leaf-action.is-running {
    color: var(--primary);
}

.sidebar-leaf-action.is-running i {
    animation: data-update-spin 0.9s linear infinite;
}

.sidebar.collapsed .sidebar-leaf-row {
    flex-direction: column;
    gap: 2px;
}

.sidebar.collapsed .sidebar-leaf-row .sidebar-leaf-main {
    flex: 0 0 34px;
    width: 100%;
}

@media (prefers-reduced-motion: reduce) {
    .sidebar-leaf-action.is-running i {
        animation: none;
    }
}

@keyframes data-update-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* 侧边栏底部快捷操作 */
.sidebar-utility-actions {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    width: 100%;
    box-sizing: border-box;
    padding: 8px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

/* 顶部菜单条右侧用户下拉菜单 */
.workbench-user-menu {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    position: relative;
    padding: 0 10px 0 6px;
    user-select: none;
}

.workbench-user-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-main);
    cursor: pointer;
    font-weight: var(--weight-medium);
    transition: background-color 0.12s ease, border-color 0.12s ease;
}

.workbench-user-btn:hover,
.workbench-user-btn[aria-expanded="true"] {
    background: var(--bg-hover);
    border-color: var(--border-color);
}

.workbench-user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: var(--radius-full);
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: var(--weight-semibold);
    flex-shrink: 0;
}

.workbench-user-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workbench-user-caret {
    color: var(--text-muted);
    transition: transform 0.15s ease;
}

.workbench-user-btn[aria-expanded="true"] .workbench-user-caret {
    transform: rotate(180deg);
}

.workbench-user-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 8px;
    width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 4px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.workbench-user-dropdown[hidden] {
    display: none;
}

.workbench-user-dropdown-meta {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
}

.workbench-user-dropdown-title {
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workbench-user-dropdown-sub {
    color: var(--text-muted);
    margin-top: 2px;
    font-family: var(--font-mono);
}

.workbench-user-dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

.workbench-user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 32px;
    padding: 0 10px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-main);
    cursor: pointer;
    text-align: left;
    transition: background-color 0.12s ease;
}

.workbench-user-dropdown-item:hover {
    background: var(--bg-hover);
}

.workbench-user-dropdown-item--danger {
    color: var(--tag-red-text);
}

.workbench-user-dropdown-item--danger:hover {
    background: var(--tag-red-bg);
}

.sidebar-utility-button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 32px;
    padding: 0 8px;
    box-sizing: border-box;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    box-shadow: none;
    color: var(--text-muted);
    text-align: left;
    font-weight: var(--weight-medium);
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.sidebar-utility-button:hover {
    background: var(--bg-hover);
    color: var(--text-main);
    border-color: var(--border-color);
}

.sidebar-data-update-button.active {
    background: var(--bg-selected);
    color: var(--primary);
    border-color: var(--primary-border);
    font-weight: var(--weight-semibold);
}

.sidebar-utility-button .sidebar-icon {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    display: inline-grid;
    place-items: center;
    background: transparent;
    color: currentColor;
}

.sidebar-utility-button .sidebar-icon i {
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-utility-button .sidebar-icon svg {
    width: 16px;
    height: 16px;
    display: block;
}

.sidebar-utility-button:hover .sidebar-icon {
    color: var(--text-main);
}

/* 展开态：待办胶囊角标与状态灯 */
.sidebar-todo-badge {
    position: static;
    margin-left: auto;
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
    font-weight: var(--weight-semibold);
    padding: 0 6px;
    height: 18px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    flex-shrink: 0;
}

.sidebar-todo-badge[hidden] {
    display: none !important;
}

.sidebar-data-update-button.is-running .sidebar-icon i {
    animation: data-update-spin 0.9s linear infinite;
}

.sidebar-utility-label {
    flex: 1;
    white-space: nowrap;
    text-align: left;
}

.sidebar.collapsed .sidebar-utility-actions {
    padding: 8px 4px;
    gap: 4px;
}

.sidebar.collapsed .sidebar-utility-button {
    position: relative;
    justify-content: center;
    width: 100%;
    padding: 0;
}

.sidebar.collapsed .sidebar-utility-label {
    display: none;
}

.sidebar.collapsed .sidebar-todo-badge {
    position: absolute;
    top: 2px;
    right: 4px;
    margin-left: 0;
    padding: 0 4px;
    height: 14px;
}

/* iframe 内容区 */
.workbench-empty-state {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: var(--space-2);
    color: var(--text-muted);
    text-align: center;
}

.workbench-empty-state[hidden] {
    display: none;
}

.workbench-frames {
    flex: 1;
    min-height: 0;
    position: relative;
}

.workbench-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.workbench-frame[hidden] {
    display: none;
}

.workbench-frame.is-awaiting-page-ready {
    visibility: hidden;
    pointer-events: none;
}

.workbench-frame-status {
    position: absolute;
    top: 12px;
    left: 50%;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    max-width: calc(100% - 24px);
    padding: 7px 12px;
    transform: translateX(-50%);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-muted);
    box-shadow: var(--shadow-popover);
}

.workbench-frame-status.is-error {
    color: var(--acos-red);
}

.workbench-frame-status[hidden] {
    display: none;
}

.workbench-frame-status.is-page-loading {
    inset: 12px;
    max-width: none;
    min-height: 160px;
    transform: none;
    border-radius: var(--radius);
    background: var(--bg-card);
    box-shadow: none;
}

.workbench-impersonation-banner {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 34px;
    padding: 4px 10px;
    border-bottom: 1px solid var(--tag-yellow-border);
    background: var(--tag-yellow-bg);
    color: var(--tag-yellow-text);
}

.workbench-impersonation-banner[hidden] {
    display: none;
}

.workbench-impersonation-copy {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.workbench-impersonation-copy span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workbench-tools-status {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 34px;
    padding: 4px 10px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-hover);
    color: var(--text-muted);
}

.workbench-tools-status.is-error {
    color: var(--acos-red);
}

.workbench-tools-status[hidden] {
    display: none;
}

/* 二级菜单与 ASIN 列表 */
.sidebar-group-btn {
    position: relative;
}

.sidebar-caret {
    position: relative;
    left: 6px;
    margin-left: auto;
    width: 14px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dim);
    transition: transform 0.2s ease, color 0.15s ease;
    flex-shrink: 0;
}

.sidebar-caret i {
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-caret svg {
    width: 12px;
    height: 12px;
    display: block;
}

.sidebar-group-btn[aria-expanded="true"] .sidebar-caret {
    transform: rotate(90deg);
    color: var(--text-muted);
}

.sidebar-sublist {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 0 4px 10px;
    margin-left: 10px;
    border-left: 1px dashed var(--border-color);
    overflow: hidden;
}


.sidebar-sublink-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
}

.sidebar-sublink-row--action {
    min-width: 0;
}

.sidebar-sublink-main {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 30px;
    padding: 0 8px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    text-align: left;
    display: flex;
    align-items: center;
    font-family: inherit;
}

.sidebar-sublink-row--asin .sidebar-sublink-main {
    min-height: 38px;
    padding: 4px 8px;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 1px;
}

.sidebar-sublink-main:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.sidebar-sublink-main:hover .sidebar-sublink-title {
    color: var(--text-main);
}

.sidebar-sublink-main.active {
    background: var(--bg-selected);
    color: var(--primary-light);
    font-weight: var(--weight-semibold);
}

.sidebar-sublink-main.active::before {
    content: '';
    position: absolute;
    left: -11px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 14px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.sidebar-sublink-main.active .sidebar-sublink-title {
    color: var(--primary-light);
    font-weight: var(--weight-semibold);
}

.sidebar-sublink-main.active .sidebar-sublink-meta {
    color: var(--primary);
    opacity: 0.85;
}

.sidebar-sublink-row--action .sidebar-sublink-title {
    color: var(--text-muted);
}

.sidebar-sublink-title {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: var(--weight-medium);
    color: var(--text-muted);
    line-height: 1.3;
}

.sidebar-sublink-meta {
    display: block;
    overflow: hidden;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-weight: var(--weight-regular);
    letter-spacing: 0.2px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 折叠时只保留一级图标与悬停浮动抽屉 (Flyout) */
.sidebar.collapsed {
    overflow: visible;
}

.sidebar.collapsed .sidebar-brand {
    display: none;
}

.sidebar.collapsed .sidebar-nav {
    overflow: visible;
}

.sidebar.collapsed .sidebar-group {
    position: relative;
}

.sidebar.collapsed .sidebar-caret {
    display: none;
}

.sidebar.collapsed .sidebar-sublist {
    display: none;
}

.sidebar.collapsed .sidebar-group:hover .sidebar-sublist {
    display: flex;
    flex-direction: column;
    gap: 3px;
    position: absolute;
    left: calc(100% + 4px);
    top: -4px;
    min-width: 220px;
    max-width: 280px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.18), 0 8px 10px -6px rgba(15, 23, 42, 0.1);
    padding: 6px;
    z-index: 1000;
    animation: flyoutSlideIn 0.12s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes flyoutSlideIn {
    from {
        opacity: 0;
        transform: translateX(-4px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.sidebar.collapsed .sidebar-group:hover .sidebar-sublist::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -8px;
    width: 8px;
}

.sidebar.collapsed .sidebar-group:hover .sidebar-sublist .sidebar-sublink-row {
    padding: 4px 6px;
    border-radius: var(--radius-xs);
    background: transparent;
    border-left: none;
}

.sidebar.collapsed .sidebar-group:hover .sidebar-sublist .sidebar-sublink-row:hover {
    background: var(--bg-hover);
}

.sidebar.collapsed .sidebar-group:hover .sidebar-sublist .sidebar-sublink-title {
    color: var(--text-main);
}

.sidebar.collapsed .sidebar-group:hover .sidebar-sublist .sidebar-sublink-meta {
    color: var(--text-muted);
}

.sidebar.collapsed .sidebar-group:hover .sidebar-sublist .sidebar-sublink-row.active {
    background: var(--tag-blue-bg);
}

.sidebar.collapsed .sidebar-group:hover .sidebar-sublist .sidebar-sublink-row.active .sidebar-sublink-title {
    color: var(--primary);
}

/* 顶部标签栏右键上下文菜单 (Tab Context Menu) */
.workbench-context-menu {
    position: fixed;
    z-index: 9999;
    min-width: 145px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.18), 0 8px 10px -6px rgba(15, 23, 42, 0.1);
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    user-select: none;
    animation: contextMenuFadeIn 0.12s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes contextMenuFadeIn {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.workbench-context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 10px;
    border: none;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-main);
    text-align: left;
    cursor: pointer;
    line-height: 1;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.workbench-context-menu-item i {
    color: var(--text-muted);
}

.workbench-context-menu-item:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--primary);
}

.workbench-context-menu-item:hover:not(:disabled) i {
    color: var(--primary);
}

.workbench-context-menu-item:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.workbench-context-menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 2px 4px;
}
