/* ============ 全局样式与变量 ============ */
:root {
    --primary: #6C5CE7;
    --primary-dark: #5A4BD1;
    --primary-light: #EDEAFF;
    --bg: #F5F6FA;
    --card-bg: #FFFFFF;
    --text: #1E293B;
    --text-secondary: #64748B;
    --border: #E2E8F0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.1), 0 4px 12px rgba(0, 0, 0, 0.05);
    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 20px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden; /* 禁止页面滚动条 */
}

/* 顶部彩色条 */
.top-bar {
    height: 4px;
    background: linear-gradient(90deg, #6C5CE7, #A29BFE, #FD79A8, #FDCB6E, #00CEC9);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

/* 首页按钮 */
.home-btn {
    position: fixed;
    top: 16px;
    left: 20px;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 30px;
    padding: 8px 16px;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.home-btn:hover {
    background: var(--primary);
    color: #FFF;
    border-color: var(--primary);
    box-shadow: 0 8px 20px rgba(108, 92, 231, 0.3);
    transform: translateY(-2px);
}

/* 主容器：使用flex列布局，高度撑满视口 */
.container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px 20px 0;
}

/* 头部 */
.header {
    text-align: center;
    padding: 30px 20px 15px;
    flex-shrink: 0;
}

.header-icon {
    color: var(--primary);
    display: inline-block;
    margin-bottom: 6px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.title {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #1E293B 0%, #6C5CE7 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 2px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 400;
}

/* 两栏主体：等宽，高度自适应剩余空间 */
.main-content {
    flex: 1;
    display: flex;
    gap: 16px;
    margin-top: 10px;
    min-height: 0; /* 允许flex收缩 */
}

/* 左侧工具卡片 */
.tool-card {
    flex: 1;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* 颜色预览区 */
.color-preview {
    width: 100%;
    height: 130px;
    border-radius: var(--radius);
    background-color: #ff0000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.25s ease;
    box-shadow: inset 0 1px 4px rgba(0,0,0,0.06);
    margin-bottom: 16px;
    flex-shrink: 0;
}

.color-preview-text {
    font-family: 'SF Mono', 'Menlo', 'Consolas', 'Monaco', monospace;
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.25);
    transition: color 0.25s ease;
    user-select: all;
}

/* 控制区 */
.controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.control-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.control-label {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 55px;
}

.color-picker {
    width: 38px;
    height: 38px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
    padding: 2px;
    transition: var(--transition);
}

.color-picker:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.08);
}

.picker-hint {
    font-size: 0.85rem;
    color: #94A3B8;
    font-style: italic;
    white-space: nowrap;
}

.text-input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
}

.color-text-input {
    flex: 1;
    padding: 9px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    font-size: 0.85rem;
    color: var(--text);
    background: #FAFBFC;
    transition: var(--transition);
    outline: none;
}

.color-text-input:focus {
    border-color: var(--primary);
    background: #FFF;
    box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.06);
}

.color-text-input.error {
    border-color: #EF4444;
    background: #FFF5F5;
}

.random-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--card-bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748B;
    transition: var(--transition);
    flex-shrink: 0;
}

.random-btn:hover {
    background: #F8FAFC;
    border-color: #CBD5E1;
    color: var(--primary);
    transform: rotate(25deg);
}

/* 颜色代码展示区 */
.color-codes {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.code-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #F8FAFC;
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    border: 1px solid #F1F5F9;
    transition: var(--transition);
    flex-wrap: wrap;
    gap: 4px;
}

.code-row:hover {
    background: #F1F5F9;
    border-color: #E2E8F0;
}

.code-header {
    display: flex;
    flex-direction: column;
    min-width: 55px;
}

.code-format {
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text);
}

.code-desc {
    font-size: 0.65rem;
    color: #94A3B8;
    font-weight: 400;
}

.code-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: flex-end;
}

.code-value {
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    font-size: 0.8rem;
    color: var(--text);
    background: #FFF;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid #E2E8F0;
    user-select: all;
    word-break: break-all;
}

.copy-btn {
    background: none;
    border: 1.5px solid #E2E8F0;
    border-radius: 6px;
    padding: 5px 7px;
    cursor: pointer;
    color: #64748B;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.copy-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #FFF;
    box-shadow: 0 4px 10px rgba(108, 92, 231, 0.25);
}

.copy-btn.copied {
    background: #10B981;
    border-color: #10B981;
    color: #FFF;
}

/* 右侧常用颜色面板：等宽，内部滚动并隐藏滚动条 */
.common-colors-section {
    flex: 1;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 16px 14px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.common-colors-section::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.section-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
    text-align: center;
    flex-shrink: 0;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}

.color-swatch {
    aspect-ratio: 1;
    border-radius: 4px;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: var(--transition);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 1px;
    overflow: hidden;
}

.color-swatch:hover {
    transform: scale(1.12);
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    z-index: 2;
}

.color-swatch-name {
    font-size: 0.99rem;
    font-weight: 600;
    color: #FFF;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    padding: 0 1px;
}

/* 页脚 */
.footer {
    text-align: center;
    padding: 10px 0 8px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    line-height: 1.6;
    flex-shrink: 0;
}

.footer code {
    background: #F1F5F9;
    padding: 1px 5px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
    font-size: 0.7rem;
    color: #E11D48;
}

.copyright {
    margin-top: 1px;
}

.copyright a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.copyright a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Toast 提示 */
.toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-120px);
    background: #1E293B;
    color: #FFF;
    padding: 10px 24px;
    border-radius: 30px;
    font-weight: 600;
    font-size: 0.9rem;
    z-index: 1000;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
    white-space: nowrap;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

/* 响应式：平板及手机端恢复单列，取消固定高度，允许页面滚动 */
@media (max-width: 850px) {
    body {
        overflow: auto;
    }

    .container {
        height: auto;
        padding: 16px 12px 20px;
    }

    .main-content {
        flex-direction: column;
        height: auto;
    }

    .tool-card {
        flex: 0 0 auto;
        width: 100%;
    }

   .format-hint {
    text-align: center;
    margin-top: 0;
    margin-bottom: 20px;   /* 与下方颜色预览区保持 10px 距离 */
    color: #64748B;
    font-size: 0.8rem;
}
    .common-colors-section {
        flex: 0 0 auto;
        width: 100%;
        overflow-y: visible;
        max-height: none;
    }

    .color-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 500px) {
    .color-preview {
        height: 100px;
    }
    .color-preview-text {
        font-size: 1.3rem;
    }
    .code-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .code-content {
        width: 100%;
        justify-content: space-between;
    }
    .picker-hint {
        white-space: normal;
    }
    .color-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 3px;
    }
    .color-swatch-name {
        font-size: 0.38rem;
    }
}