:root {
    --bg: #f4f6f8;
    --surface: #fff;
    --surface-soft: #f8fafb;
    --line: #dce2e8;
    --line-strong: #c2cbd5;
    --text: #24313c;
    --muted: #6b7785;
    --accent: #176c68;
    --accent-soft: #e8f4f2;
    --danger: #b42318;
    --sidebar: 236px;
    --header: 56px;
    /* 首页 Toast 的坐标由工作区实际矩形同步，避免侧栏收起或窗口缩放后错位。 */
    --wcl-toast-top: 16px;
    --wcl-toast-left: 50%;
    --radius: 6px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: var(--bg);
}

* { box-sizing: border-box; }

html,
body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: var(--bg);
}

button,
input { font: inherit; }

.app-shell { display: flex; flex-direction: column; height: 100%; }

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header);
    padding: 0 18px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.brand-lockup { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { width: 28px; height: 28px; }
.brand-lockup strong { display: block; font-size: 15px; line-height: 1.2; }
.brand-lockup span { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.2; }
.header-meta { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 12px; }
.status-dot { color: var(--accent); white-space: nowrap; }

.app-body { display: flex; flex: 1; min-height: 0; }

.sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar);
    min-width: 0;
    border-right: 1px solid var(--line);
    background: var(--surface);
}

.sidebar-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 14px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
}

.sidebar-heading button {
    display: grid;
    place-items: center;
    width: 25px;
    height: 25px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.sidebar-heading button:hover { border-color: var(--line); background: var(--surface-soft); }
.sidebar-toggle-icon { display: block; width: 14px; height: 14px; }

.search-box {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    margin: 0 10px 10px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface-soft);
    color: var(--muted);
}

.search-box:focus-within { border-color: var(--accent); background: var(--surface); }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 12px; }
.tool-nav { overflow: auto; padding: 0 8px 12px; scrollbar-color: var(--line-strong) transparent; scrollbar-width: thin; }
.tool-group { margin-bottom: 12px; }
.tool-group h2 { margin: 0; padding: 7px 8px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

.tool-link {
    display: block;
    width: 100%;
    overflow: hidden;
    padding: 8px 9px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--text);
    font-size: 12px;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.tool-link:hover { border-color: var(--line); background: var(--surface-soft); }
.tool-link.active { border-color: #b8d8d4; background: var(--accent-soft); color: #125b57; font-weight: 700; }

.workspace { display: flex; flex: 1; flex-direction: column; min-width: 0; min-height: 0; }
.tab-bar-wrap { position: relative; display: flex; height: 34px; min-width: 0; border-bottom: 1px solid var(--line); background: var(--surface); }
.tab-bar { display: flex; flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tab-bar::-webkit-scrollbar { display: none; }

.tab {
    position: relative;
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 5px;
    width: max-content;
    min-width: 94px;
    max-width: 174px;
    height: 34px;
    padding: 0 6px 0 9px;
    border: 0;
    border-right: 1px solid var(--line);
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 11px;
    cursor: pointer;
}

.tab.active { background: var(--surface); color: var(--text); font-weight: 700; }
.tab[draggable="true"] { cursor: grab; }
.tab.dragging { opacity: .45; cursor: grabbing; }
.tab.drop-before::after,
.tab.drop-after::after { position: absolute; z-index: 1; top: 4px; bottom: 4px; width: 2px; border-radius: 2px; background: var(--accent); content: ""; }
.tab.drop-before::after { left: 0; }
.tab.drop-after::after { right: 0; }
.tab.active::before { position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent); content: ""; }
.tab[data-tab-id="home"] { width: 62px; min-width: 62px; justify-content: center; padding: 0 6px; }
.tab-label { flex: 1; overflow: hidden; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
.tab-pin { flex: 0 0 auto; color: var(--accent); font-size: 7px; }
.tab-close { flex: 0 0 17px; width: 17px; height: 17px; padding: 0; border: 0; border-radius: 3px; background: transparent; color: var(--muted); font-size: 14px; line-height: 16px; cursor: pointer; }
.tab-close:hover { background: #eef1f3; color: var(--danger); }
.tab-action { display: grid; flex: 0 0 34px; width: 34px; height: 34px; place-items: center; padding: 0; border: 0; border-left: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; }
.tab-action:hover { background: var(--surface-soft); color: var(--text); }
.tab-action-icon { display: block; width: 14px; height: 14px; }
.tab-overflow-menu,
.tab-context-menu { position: fixed; z-index: 20; min-width: 190px; padding: 4px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); box-shadow: 0 4px 14px rgb(36 49 60 / 14%); }
.tab-overflow-menu { position: absolute; top: calc(100% + 2px); right: 2px; width: 220px; }
.tab-overflow-menu[hidden],
.tab-context-menu[hidden] { display: none !important; }
.tab-overflow-list { display: flex; flex-direction: column; max-height: min(320px, 60vh); overflow-y: auto; scrollbar-color: var(--line-strong) transparent; scrollbar-width: thin; }
.tab-overflow-item,
.tab-overflow-close-all,
.tab-context-item { width: 100%; min-height: 30px; overflow: hidden; padding: 5px 8px; border: 0; border-radius: 3px; background: transparent; color: var(--text); font-size: 11px; text-align: left; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.tab-overflow-item:hover,
.tab-overflow-item.active,
.tab-overflow-close-all:hover,
.tab-context-item:not(:disabled):hover { background: var(--accent-soft); color: var(--accent); }
.tab-overflow-close-all { margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0; color: var(--danger); }
.tab-context-menu { position: fixed; width: 190px; }
.tab-context-item:disabled { color: #a6afb8; cursor: not-allowed; }
.view-stack { position: relative; flex: 1; min-height: 0; background: var(--bg); }
.tool-view { position: absolute; inset: 0; display: none; border: 0; background: var(--bg); }
.tool-view.active { display: block; }
.tool-view iframe { width: 100%; height: 100%; border: 0; }
.empty-view { display: grid; place-items: center; height: 100%; padding: 24px; color: var(--muted); text-align: center; }
.empty-view strong { display: block; margin-bottom: 6px; color: var(--text); font-size: 18px; }

/* 站点外链从旧版首页迁移到新版工作台，使用与工作区一致的克制底部栏。 */
.site-footer {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    min-height: 38px;
    padding: 7px 14px;
    border-top: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
}

.footer-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 11px; line-height: 1.35; text-decoration: none; transition: color .15s ease; }
.footer-link:hover { color: var(--accent); }
.footer-icon { width: 14px; height: 14px; flex-shrink: 0; }
.footer-divider { color: var(--line-strong); font-size: 11px; user-select: none; }

.sidebar.collapsed { width: 52px; }
.sidebar.collapsed .sidebar-heading span,
.sidebar.collapsed .search-box,
.sidebar.collapsed .tool-nav { display: none; }
.sidebar.collapsed .sidebar-heading { justify-content: center; padding: 0; }
.sidebar.collapsed .sidebar-toggle-icon { transform: rotate(180deg); }

@media (max-width: 760px) {
    :root { --sidebar: 200px; }
    .header-meta { display: none; }
    .sidebar.collapsed { width: 0; border: 0; }
    .sidebar.collapsed .sidebar-heading { display: none; }
    .site-footer { gap: 7px 12px; padding: 7px 10px; }
    .footer-divider { display: none; }
}
