/* ============================================
   tooleasy Tool Suite - Modern Stylesheet
   ============================================ */

/* --- CSS Variables (Light Theme) --- */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --primary-bg: rgba(99, 102, 241, 0.08);
    --primary-bg-hover: rgba(99, 102, 241, 0.15);

    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-alt: #f1f5f9;
    --bg-input: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-topbar: rgba(255, 255, 255, 0.85);

    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-on-primary: #ffffff;

    --border-color: #e2e8f0;
    --border-color-light: #f1f5f9;

    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.1);

    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.04);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;

    --sidebar-width: 280px;
    --topbar-height: 60px;
    --font-mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', 'Cascadia Code', Consolas, 'Liberation Mono', Menlo, monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;

    --transition-fast: 0.15s ease;
    --transition: 0.25s ease;
}

/* --- Dark Theme --- */
[data-theme="dark"] {
    --primary: #818cf8;
    --primary-dark: #6366f1;
    --primary-light: #a5b4fc;
    --primary-bg: rgba(129, 140, 248, 0.1);
    --primary-bg-hover: rgba(129, 140, 248, 0.2);

    --bg-body: #0f172a;
    --bg-surface: #1e293b;
    --bg-surface-alt: #334155;
    --bg-input: #1e293b;
    --bg-sidebar: #1e293b;
    --bg-topbar: rgba(30, 41, 59, 0.85);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-on-primary: #ffffff;

    --border-color: #334155;
    --border-color-light: #1e293b;

    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.3), 0 4px 6px -4px rgba(0,0,0,0.2);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.4), 0 8px 10px -6px rgba(0,0,0,0.2);
}

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Topbar --- */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-topbar);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    gap: 12px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

.logo {
    display: flex;
    align-items: baseline;
    gap: 4px;
    color: var(--text-primary) !important;
    user-select: none;
}

.logo-icon { font-size: 1.5rem; }
.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.logo-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.topbar-center {
    flex: 1;
    max-width: 500px;
    display: flex;
    justify-content: center;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-box .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

#searchInput {
    width: 100%;
    height: 38px;
    padding: 0 12px 0 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all var(--transition-fast);
    outline: none;
}

#searchInput:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 300px;
    overflow-y: auto;
    display: none;
    z-index: 200;
}

.search-results.show { display: block; }

.search-result-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: background var(--transition-fast);
    border-bottom: 1px solid var(--border-color-light);
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--primary-bg); }

.search-result-item .result-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
}
.search-result-item .result-category {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.search-result-item .result-highlight {
    color: var(--primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle, .github-link {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.theme-toggle:hover, .github-link:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* --- Layout --- */
.layout {
    display: flex;
    padding-top: var(--topbar-height);
    height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    height: calc(100vh - var(--topbar-height));
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: var(--topbar-height);
    overflow-y: auto;
    transition: transform var(--transition);
    z-index: 90;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
}

.sidebar-category { margin-bottom: 4px; }

.sidebar-category-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.sidebar-category-header:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

.sidebar-category-header .cat-icon { font-size: 1rem; }
.sidebar-category-header .cat-name { flex: 1; }
.sidebar-category-header .cat-arrow {
    transition: transform var(--transition-fast);
    font-size: 0.7rem;
}
.sidebar-category.expanded .cat-arrow,
.sidebar-category:hover .cat-arrow { transform: rotate(90deg); }

.sidebar-category-items {
    overflow: hidden;
    max-height: 0;
    transition: max-height var(--transition);
}

/* 桌面端悬浮展开 + 已展开状态保持 */
.sidebar-category.expanded .sidebar-category-items {
    max-height: 500px;
}

/* 移动端保留悬浮内联展开；桌面端使用右侧 mega-menu */
@media (max-width: 767px) {
    .sidebar-category:hover .sidebar-category-items {
        max-height: 500px;
    }
}

.sidebar-tool-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px 7px 36px;
    font-size: 0.825rem;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.sidebar-tool-link:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

.sidebar-tool-link.active {
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 600;
}

.sidebar-tool-link .tool-icon { font-size: 0.875rem; opacity: 0.7; }
.sidebar-tool-link.active .tool-icon { opacity: 1; }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 85;
}

.sidebar-overlay.show { display: block; }

/* --- Mega Menu (桌面端悬浮多列面板) --- */
.sidebar-mega-menu {
    position: fixed;
    display: none;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
    padding: 16px 18px;
    z-index: 200;
    width: 560px;
    max-width: calc(100vw - 16px);
}
.sidebar-mega-menu.show { display: block; }

.sidebar-mega-menu .mega-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}
.sidebar-mega-menu .mega-count {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--primary-bg);
    padding: 2px 8px;
    border-radius: 10px;
}
.sidebar-mega-menu .mega-grid {
    display: grid;
    grid-template-columns: repeat(var(--mega-cols, 3), 1fr);
    gap: 4px 12px;
}
.sidebar-mega-menu .mega-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-mega-menu .mega-link:hover {
    background: var(--primary-bg);
    color: var(--primary);
}
.sidebar-mega-menu .mega-link-icon { font-size: 0.9rem; opacity: 0.8; flex-shrink: 0; }
.sidebar-mega-menu .mega-link-name { overflow: hidden; text-overflow: ellipsis; }

/* 移动端不显示 mega-menu */
@media (max-width: 767px) {
    .sidebar-mega-menu.show { display: none; }
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    height: calc(100vh - var(--topbar-height));
    overflow-y: auto;
    transition: margin var(--transition);
    display: flex;
    flex-direction: column;
}

.tool-container {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
}

/* --- ICP 备案页脚 --- */
.site-footer {
    text-align: center;
    padding: 16px 24px;
    font-size: 13px;
    color: var(--text-secondary, #888);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.site-footer a {
    color: var(--text-secondary, #888);
    text-decoration: none;
    transition: color 0.2s;
}

.site-footer a:hover {
    color: var(--primary, #4f6ef7);
    text-decoration: underline;
}

/* 公安备案图标 */
.beian-icon {
    height: 16px;
    width: auto;
    vertical-align: -3px;
    margin-right: 4px;
    display: inline-block;
}

/* 备案号分隔符 */
.footer-sep {
    color: var(--text-muted, #999);
    margin: 0 8px;
}

/* --- 关于页 --- */
.topbar-about {
    color: var(--text-color, #333);
    text-decoration: none;
    font-size: 14px;
    padding: 4px 12px;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
}

.topbar-about:hover {
    background: var(--hover-bg, #f0f0f5);
    color: var(--primary, #4f6ef7);
}

.about-hero {
    margin-bottom: 32px;
    padding: 32px;
    background: linear-gradient(135deg, rgba(79,110,247,0.08), rgba(79,110,247,0.02));
    border-radius: var(--radius, 12px);
    border: 1px solid var(--border-color);
}

.about-hero h1 {
    margin: 0 0 12px;
    font-size: 26px;
}

.about-hero p {
    margin: 0 0 16px;
    color: var(--text-secondary, #666);
    line-height: 1.7;
}

.about-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
}

.about-meta span {
    font-size: 13px;
    color: var(--text-secondary, #888);
}

.about-section {
    margin-bottom: 32px;
}

.about-section h2 {
    font-size: 18px;
    margin: 0 0 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.about-section h2 small {
    font-size: 13px;
    font-weight: normal;
    color: var(--text-secondary, #888);
}

.about-tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 10px;
}

.about-tool-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    background: var(--bg-surface, #fff);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.about-tool-item:hover {
    border-color: var(--primary, #4f6ef7);
    box-shadow: 0 4px 12px rgba(79,110,247,0.12);
    transform: translateY(-1px);
}

.about-tool-name {
    font-weight: 600;
    font-size: 14px;
}

.about-tool-desc {
    font-size: 12px;
    color: var(--text-secondary, #888);
    line-height: 1.5;
}

/* --- Home / Dashboard --- */
.home-hero {
    text-align: center;
    padding: 60px 20px 40px;
}

.home-hero h1 {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.home-hero p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

.home-features {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 40px;
}

.feature-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    color: inherit;
    display: block;
}

.feature-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.feature-card .card-icon {
    font-size: 2rem;
    margin-bottom: 12px;
}

.feature-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.feature-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.feature-card .card-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
}

.feature-card .card-tool-tag {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 20px;
    background: var(--primary-bg);
    color: var(--primary);
}

/* --- Tool Layout --- */
.tool-header {
    margin-bottom: 20px;
}

.tool-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.tool-header .tool-desc {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 4px;
}

.tool-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.tool-options {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
    align-items: center;
}

.tool-options .option-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tool-options label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.tool-options select,
.tool-options input[type="text"],
.tool-options input[type="number"] {
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.8rem;
    outline: none;
    transition: border-color var(--transition-fast);
}

.tool-options select:focus,
.tool-options input:focus {
    border-color: var(--primary);
}

.tool-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.825rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--text-on-primary);
}
.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-surface-alt);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background: var(--primary-bg);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover { box-shadow: var(--shadow-md); }

.btn-danger {
    background: var(--error);
    color: #fff;
}
.btn-danger:hover { box-shadow: var(--shadow-md); }

/* Copy Result Button - prominent secondary action */
.btn-copy-result {
    background: var(--primary-bg);
    color: var(--primary);
    border: 1px dashed var(--primary);
    margin-left: auto;
}
.btn-copy-result:hover:not(:disabled) {
    background: var(--primary);
    color: var(--text-on-primary);
    border-style: solid;
    box-shadow: var(--shadow-md);
}
.btn-copy-result:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-style: dashed;
    border-color: var(--border-color);
    background: var(--bg-surface-alt);
    color: var(--text-muted);
}

.btn-sm { height: 30px; padding: 0 12px; font-size: 0.75rem; }

.btn svg { width: 14px; height: 14px; }

/* --- Editor Layout --- */
.editor-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.editor-row.single { grid-template-columns: 1fr; }

.editor-col {
    display: flex;
    flex-direction: column;
}

.editor-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.editor-label .label-actions {
    display: flex;
    gap: 4px;
}

.editor-wrap {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color var(--transition-fast);
}

.editor-wrap:focus-within { border-color: var(--primary); }

.editor-wrap .CodeMirror {
    height: 350px;
    font-size: 13px;
    font-family: var(--font-mono);
}

.editor-wrap textarea {
    width: 100%;
    height: 350px;
    border: none;
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 13px;
    background: var(--bg-input);
    color: var(--text-primary);
    resize: vertical;
    outline: none;
    line-height: 1.6;
}

/* --- Output Display --- */
.output-box {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    background: var(--bg-input);
    overflow: auto;
    max-height: 400px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-all;
}

.output-box.error {
    border-color: var(--error);
    background: var(--error-bg);
    color: var(--error);
}

.output-box.success {
    border-color: var(--success);
    background: var(--success-bg);
}

/* --- Tree View --- */
.tree-view {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    background: var(--bg-input);
    max-height: 500px;
    overflow: auto;
    font-family: var(--font-mono);
    font-size: 13px;
}

.tree-node { margin-left: 20px; }

.tree-toggle {
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.tree-toggle::before {
    content: '▶';
    font-size: 0.65rem;
    transition: transform var(--transition-fast);
    display: inline-block;
    width: 12px;
}

.tree-toggle.open::before { transform: rotate(90deg); }

.tree-key { color: var(--info); font-weight: 600; }
.tree-string { color: var(--success); }
.tree-number { color: var(--warning); }
.tree-boolean { color: var(--primary); }
.tree-null { color: var(--text-muted); }
.tree-bracket { color: var(--text-secondary); }

.tree-children { display: none; }
.tree-children.open { display: block; }

/* --- Info Table --- */
.info-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.825rem;
}

.info-table th,
.info-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.info-table th {
    background: var(--bg-surface-alt);
    font-weight: 600;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
}

.info-table tr:hover td { background: var(--primary-bg); }

.info-table .badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-primary { background: var(--primary-bg); color: var(--primary); }

/* --- Toast --- */
.toast-container {
    position: fixed;
    top: calc(var(--topbar-height) + 16px);
    right: 16px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    min-width: 280px;
    max-width: 400px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.825rem;
    pointer-events: auto;
    animation: toast-in 0.3s ease;
}

.toast.success { border-color: var(--success); }
.toast.success .toast-icon { color: var(--success); }
.toast.error { border-color: var(--error); }
.toast.error .toast-icon { color: var(--error); }
.toast.info { border-color: var(--info); }
.toast.info .toast-icon { color: var(--info); }

.toast-icon { font-size: 1.1rem; }
.toast-msg { flex: 1; color: var(--text-primary); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast.removing { animation: toast-out 0.3s ease forwards; }
@keyframes toast-out {
    to { opacity: 0; transform: translateX(40px); }
}

/* --- Checkbox & Radio --- */
.checkbox-group, .radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.checkbox-item, .radio-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    transition: all var(--transition-fast);
}

.checkbox-item:hover, .radio-item:hover {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.checkbox-item input, .radio-item input { accent-color: var(--primary); }

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .editor-row { grid-template-columns: 1fr; }
    .topbar-center { display: none; }
    .logo-sub { display: none; }
    .tool-container { padding: 16px; }
    .home-hero h1 { font-size: 1.75rem; }
    .home-hero { padding: 30px 10px; }
}

@media (max-width: 480px) {
    .logo-text { font-size: 1rem; }
    .tool-actions .btn { width: 100%; justify-content: center; }
}

/* --- CodeMirror Theme Overrides --- */
.CodeMirror {
    background: var(--bg-input) !important;
    color: var(--text-primary) !important;
}

.CodeMirror-gutters {
    background: var(--bg-surface) !important;
    border-right: 1px solid var(--border-color) !important;
}

.CodeMirror-linenumber { color: var(--text-muted) !important; }
.CodeMirror-cursor { border-left-color: var(--primary) !important; }
.CodeMirror-activeline-background { background: var(--primary-bg) !important; }

[data-theme="dark"] .CodeMirror {
    background: #1a2744 !important;
}

/* --- Misc --- */
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-muted); }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }

.divider {
    height: 1px;
    background: var(--border-color);
    margin: 16px 0;
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--primary-bg);
    color: var(--primary);
}

/* --- 工具页 SEO 区块（面包屑 / 正文 / 相关工具 / FAQ） --- */
.tool-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 14px;
}

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

.tool-breadcrumb a:hover { text-decoration: underline; }

.tool-breadcrumb .crumb-sep {
    color: var(--text-muted);
}

.tool-seo {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tool-article,
.related-tools,
.tool-faq {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px 22px;
    line-height: 1.7;
}

.tool-article h2,
.related-tools h2,
.tool-faq h2 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin: 18px 0 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color-light);
}

.tool-article h2:first-child { margin-top: 0; }

.tool-article p,
.tool-article li {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.tool-article ul,
.tool-article ol {
    padding-left: 20px;
    margin: 8px 0;
}

.tool-article code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1px 5px;
    color: var(--text-primary);
}

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

.tool-article a:hover { text-decoration: underline; }

.tool-article blockquote {
    margin: 10px 0;
    padding: 8px 14px;
    border-left: 3px solid var(--primary);
    background: var(--primary-bg);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.related-tools-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.related-tool-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--primary-bg);
    color: var(--primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    text-decoration: none;
    transition: background var(--transition-fast);
}

.related-tool-link:hover {
    background: var(--primary-bg-hover);
}

.related-tool-icon { font-size: 1rem; }

.faq-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color-light);
}

.faq-item:last-child { border-bottom: none; }

.faq-item h3 {
    font-size: 0.98rem;
    color: var(--text-primary);
    margin: 0 0 6px;
}

.faq-item p {
    font-size: 0.92rem;
    color: var(--text-secondary);
    margin: 0;
}
