* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Microsoft YaHei", Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

/* 全站统一按钮 — 所有工具操作按钮只用 .tb-btn，勿在页面 CSS 覆盖颜色 */
.tb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 9999px;
    background: #2563eb;
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease;
    white-space: nowrap;
}

.tb-btn.w-full {
    width: 100%;
}

.tb-btn-sm {
    padding: 6px 16px;
    font-size: 13px;
}

a.tb-btn {
    text-decoration: none;
    color: #fff;
}

/* 并列操作按钮间距（全站）：必须用 .action-row，禁止按钮紧贴 */
.action-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.tb-btn:hover {
    background: #2563eb;
    color: #fff;
}

.tb-btn:active {
    background: #2563eb;
    color: #fff;
}

.tb-btn:disabled,
.tb-btn.is-disabled {
    background: #93c5fd;
    color: #fff;
    cursor: not-allowed;
    opacity: 1;
}

.container {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏样式 - 白色主题 (仿 Tailwind) */
.sidebar {
    width: 256px; /* w-64 */
    background-color: #ffffff;
    color: #4b5563; /* text-gray-600 */
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); /* shadow-lg */
    border-right: 1px solid #f3f4f6; /* border-gray-100 */
    z-index: 20;
    flex-shrink: 0;
    /* 固定侧边栏关键样式 */
    position: sticky;
    top: 0;
    height: 100vh;
}

.logo {
    padding: 24px; /* p-6 */
    border-bottom: 1px solid #f3f4f6; /* border-b border-gray-100 */
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.logo-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-badge {
    width: 32px;
    height: 32px;
    background-color: #2563eb;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 700;
    font-size: 15px;
    line-height: 1;
    flex-shrink: 0;
}

/* JS生成的内联样式已经处理了 h2 和图标样式，这里只做兜底 */
.logo h2 {
    font-size: 1.25rem; /* text-xl */
    font-weight: 700; /* font-bold */
    color: #1f2937; /* text-gray-800 */
    margin: 0;
}

.menu {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0; /* py-4 */
}

.menu ul {
    list-style: none;
}

.menu li {
    padding: 12px 24px; /* px-6 py-3 */
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
    border-right: 4px solid transparent; /* border-r-4 border-transparent */
    color: #4b5563; /* text-gray-600 */
}

.menu li:hover {
    background-color: #f9fafb; /* hover:bg-gray-50 */
    color: #2563eb; /* hover:text-blue-600 */
}

.menu li.active {
    background-color: #eff6ff; /* bg-blue-50 */
    color: #2563eb; /* text-blue-600 */
    border-right: 4px solid #2563eb; /* border-r-4 border-blue-600 */
    /* 移除原来的左边框样式 */
    border-left: none;
}

.menu a {
    color: inherit; /* 继承 li 的颜色 */
    text-decoration: none;
    display: block;
    width: 100%;
    font-weight: 500; /* font-medium */
}

.menu-cost {
    margin-left: 6px;
    font-size: 12px;
    color: #94a3b8;
}

.menu-group-title {
    color: #4b5563; /* text-gray-600 */
    font-size: 1.125rem; /* text-lg */
    font-weight: 600; /* font-semibold */
    padding: 16px 24px 8px 10px; /* mb-4 mt-6 pl-2 */
    margin-top: 24px;
    margin-bottom: 16px;
    margin-left: 24px;
    border-left: 4px solid #60a5fa; /* border-l-4 border-blue-400 */
    background: none;
    pointer-events: none;
    border-bottom: none; /* 移除旧样式 */
    letter-spacing: normal;
    text-transform: none;
}

.menu-group-title:first-child {
    margin-top: 0;
}

.logo-header-link {
    display: flex;
    align-items: center;
    gap: 12px;
    color: inherit;
}

.logo-header-link,
.logo-header-link:hover,
.logo-header-link:focus,
.logo-header-link:visited,
.logo-header-link:active {
    text-decoration: none;
}

.logo-header-link h2 {
    text-decoration: none;
}

.logo-header-link:hover h2 {
    color: #2563eb;
}

/* 工具页侧栏「返回首页」按钮 */
.logo-home-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1e40af;
    text-decoration: none;
    box-sizing: border-box;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.logo-home-btn:hover,
.logo-home-btn:focus {
    background: #dbeafe;
    border-color: #93c5fd;
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.12);
}

.logo-home-btn:visited,
.logo-home-btn:active {
    color: #1e40af;
    text-decoration: none;
}

.logo-home-btn .logo-badge {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.logo-home-label {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
}

.sidebar-footer-nav {
    padding: 12px 24px;
    border-top: 1px solid #f3f4f6;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-footer-nav a {
    font-size: 13px;
    font-weight: 500;
    color: #2563eb;
    text-decoration: none;
}

.sidebar-footer-nav a:hover {
    color: #1d4ed8;
}

.sidebar-footer-copy {
    padding: 12px 24px 20px;
    text-align: center;
    font-size: 12px;
    color: #9ca3af;
    border-top: 1px solid #f3f4f6;
    margin-top: auto;
}

.sidebar-footer-copy p {
    margin: 0;
}

.tool-mobile-nav-links {
    display: none;
}

/* 内容区域样式 */
.content {
    flex: 1;
    min-width: 0;
    padding: 30px;
    background-color: #fff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.page {
    display: none;
}

.page.active {
    display: block;
}

/* 首页欢迎部分 */
.welcome-section {
    text-align: center;
    padding: 40px 20px;
}

.welcome-section h1 {
    font-size: 2.5em;
    margin-bottom: 20px;
    color: #2c3e50;
}

.welcome-section p {
    font-size: 1.2em;
    margin-bottom: 40px;
    color: #7f8c8d;
}

.tools-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px;
    margin-top: 40px;
}

.tools-list .tool-card {
    width: 300px;
    padding: 25px;
    border-radius: 8px;
    background-color: #f9f9f9;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
}

.tools-list .tool-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.tools-list .tool-card h3 {
    font-size: 1.4em;
    margin-bottom: 15px;
    color: #2c3e50;
}

.tools-list .tool-card p {
    margin-bottom: 20px;
    color: #7f8c8d;
    text-align: left;
}

.tool-link {
    display: inline-block;
    padding: 10px 20px;
    background-color: #3498db;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.tool-link:hover {
    background-color: #2980b9;
}

/* 通用样式 — 无 .tb-btn 的按钮仅保留字体继承，避免覆盖统一按钮 */
button:not(.tb-btn):not(.btn-link):not(.recipe-preview-remove):not(.recipe-lightbox-close):not(.recipe-lightbox-nav):not(.tool-menu-toggle):not(.hub-search-clear) {
    font: inherit;
}

textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    color: #2c3e50;
}

.input-section, .output-section {
    margin-bottom: 20px;
}

.tool-container {
    margin-top: 20px;
}

.options-section {
    margin: 15px 0;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 4px;
    border: 1px solid #eee;
}

.checkbox-label {
    display: inline-block;
    margin-right: 20px;
    font-weight: normal;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 5px;
    vertical-align: middle;
}

#result-output {
    background-color: #f8f8f8;
}

/* 代码显示区域样式 */
.code-display {
    width: 100%;
    padding: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #f8f8f8;
    font-family: monospace;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-word;
    overflow-x: hidden;
    margin: 0;
    height: auto;
    overflow-y: visible;
}

.output-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.tb-btn.copy-btn {
    align-self: flex-start;
    margin-top: 10px;
}

/* —— 工具页（.container + .sidebar）：小屏侧栏改为抽屉 —— */
.tool-mobile-bar {
    display: none;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 80;
}

@media (max-width: 768px) {
    html,
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .sidebar-overlay.is-visible {
        display: block;
    }

    /* 手机端改为单栏：关闭时侧栏不占位，避免内容被挤偏 */
    .container {
        display: block;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .sidebar {
        display: none;
        position: fixed;
        left: 0;
        top: 0;
        width: min(280px, 86vw);
        max-width: 100%;
        height: 100vh;
        height: 100dvh;
        transform: none;
        z-index: 100;
        box-shadow: none;
    }

    .sidebar.is-open {
        display: flex;
        box-shadow: 4px 0 24px rgba(15, 23, 42, 0.12);
    }

    .tool-mobile-bar {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 0;
        margin: 0 0 14px 0;
        background: #ffffff;
        border-bottom: 1px solid #f3f4f6;
        position: sticky;
        top: 0;
        z-index: 40;
        width: 100%;
        box-sizing: border-box;
    }

    .content {
        display: block;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        margin: 0 auto;
        padding: 12px;
        box-sizing: border-box;
        box-shadow: none;
    }

    /* 全局工具卡片：手机端左右等宽贴齐内容区 */
    .tool-card {
        box-sizing: border-box;
        width: 100%;
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
    }

    .tool-menu-toggle {
        flex-shrink: 0;
        width: 40px;
        height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
        border: 1px solid #e5e7eb;
        background: #fff;
        color: #374151;
        cursor: pointer;
        font-size: 18px;
        line-height: 1;
        padding: 0;
    }

    .tool-menu-toggle:active {
        background: #f3f4f6;
    }

    .tool-mobile-title {
        flex: 1;
        min-width: 0;
        font-size: 16px;
        font-weight: 600;
        color: #111827;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .tool-mobile-home {
        flex-shrink: 0;
        font-size: 13px;
        font-weight: 500;
        color: #2563eb;
        text-decoration: none;
        white-space: nowrap;
    }

    .tool-mobile-home:hover {
        color: #1d4ed8;
    }
}

/* Desktop tool shell: sidebar already shows the current tool — hide duplicate H1.
   Keep optional .tool-header > p description. Phone uses .tool-mobile-bar title. */
@media (min-width: 769px) {
    .container > .sidebar ~ .content > .tool-header > h1 {
        display: none;
    }

    .container > .sidebar ~ .content > .tool-header:not(:has(> p)) {
        display: none;
    }
} 