/* =============================================
   设计系统 — CSS 变量
   ============================================= */
:root {
    /* 主色调 */
    --primary:        #4f6ef7;
    --primary-dark:   #3a56d4;
    --primary-light:  #eef1fe;
    --accent:         #06c270;
    --accent-dark:    #04a85e;
    --danger:         #ff4d4f;

    /* 中性色 */
    --bg:             #f0f2f8;
    --surface:        #ffffff;
    --surface-alt:    #f7f8fc;
    --border:         #e4e8f0;
    --border-light:   #eef0f6;

    /* 文字 */
    --text-primary:   #1a1f36;
    --text-secondary: #5c6b8a;
    --text-muted:     #9ba8c0;
    --text-on-dark:   #ffffff;

    /* 侧边栏 */
    --sidebar-bg:     #1a1f36;
    --sidebar-hover:  #252c47;
    --sidebar-active: #4f6ef7;
    --sidebar-width:  230px;

    /* 圆角 */
    --radius-sm:   6px;
    --radius-md:   12px;
    --radius-lg:   18px;

    /* 阴影 */
    --shadow-sm:   0 1px 4px rgba(26,31,54,.06);
    --shadow-md:   0 4px 20px rgba(26,31,54,.08);
    --shadow-lg:   0 8px 40px rgba(26,31,54,.12);

    /* 过渡 */
    --transition:  all 0.22s ease;

    /* 字体 */
    --font-sans:  "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, sans-serif;
    --font-mono:  "JetBrains Mono", "Cascadia Code", "Fira Code", "Source Code Pro", monospace;
}

/* =============================================
   全局重置
   ============================================= */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =============================================
   侧边栏
   ============================================= */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    min-height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
}

.sidebar-logo {
    padding: 24px 20px 20px;
    text-align: center;
    color: var(--text-on-dark);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.04em;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    background: linear-gradient(180deg, rgba(79,110,247,.18) 0%, transparent 100%);
}

.sidebar-logo::before {
    content: "⚡";
    display: block;
    font-size: 28px;
    margin-bottom: 6px;
}

.sidebar-nav {
    padding: 16px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: rgba(255,255,255,0.9);
    transform: translateX(2px);
}

.nav-item.active {
    background: var(--primary);
    color: var(--text-on-dark);
    box-shadow: 0 4px 14px rgba(79,110,247,0.4);
}

.nav-item[href="#jianfan"]::before  { content: "文"; font-weight: 700; font-size: 16px; }
.nav-item[href="#pinyin"]::before   { content: "拼"; font-weight: 700; font-size: 16px; }
.nav-item[href="#case"]::before     { content: "Aa"; font-weight: 700; font-size: 13px; }
.nav-item[href="#base64"]::before   { content: "64"; font-weight: 700; font-size: 13px; }

/* =============================================
   主内容区
   ============================================= */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* =============================================
   顶部 Header
   ============================================= */
.header {
    background: linear-gradient(135deg, #1a1f36 0%, #2d3561 60%, #4f6ef7 100%);
    color: var(--text-on-dark);
    padding: 36px 48px;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 50%, rgba(79,110,247,.25) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(6,194,112,.15) 0%, transparent 40%);
    pointer-events: none;
}

.header h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 0.02em;
    position: relative;
}

.header p {
    font-size: 14px;
    color: rgba(255,255,255,0.65);
    margin-top: 6px;
    position: relative;
}

/* =============================================
   容器
   ============================================= */
.container {
    max-width: 1080px;
    margin: 32px 40px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* =============================================
   选项栏
   ============================================= */
.options {
    background: var(--surface);
    padding: 16px 20px;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.option-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.option-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.option-group select {
    padding: 7px 32px 7px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: var(--surface-alt);
    min-width: 130px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235c6b8a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: var(--transition);
}

.option-group select:hover {
    border-color: var(--primary);
}

.option-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,110,247,.15);
}

/* =============================================
   转换卡片
   ============================================= */
.converter-box {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    border: 1px solid var(--border-light);
    transition: box-shadow 0.25s ease;
}

.converter-box:hover {
    box-shadow: var(--shadow-lg);
}

/* =============================================
   文本区域
   ============================================= */
.text-areas {
    display: flex;
    min-height: 320px;
}

.text-column {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.text-column:first-child {
    border-right: 1px solid var(--border-light);
}

.text-column .label {
    background: var(--surface-alt);
    padding: 10px 18px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border-light);
}

.text-column textarea {
    flex: 1;
    padding: 16px 18px;
    font-size: 15px;
    line-height: 1.85;
    border: none;
    resize: none;
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: var(--surface);
    transition: background 0.2s ease;
}

.text-column textarea:focus {
    outline: none;
    background: #fafbff;
}

.text-column textarea::placeholder {
    color: var(--text-muted);
}

.text-column textarea[readonly] {
    background: var(--surface-alt);
    color: var(--text-secondary);
}

/* =============================================
   提示栏
   ============================================= */
.tips {
    padding: 10px 18px;
    background: linear-gradient(90deg, #fffbeb, #fffdf5);
    border-top: 1px solid #fde68a;
    color: #92700a;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* =============================================
   工具栏
   ============================================= */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: var(--surface-alt);
    border-top: 1px solid var(--border-light);
}

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

/* =============================================
   按钮系统
   ============================================= */
.btn {
    padding: 7px 18px;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-sans);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 0.01em;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: var(--primary);
    color: var(--text-on-dark);
    box-shadow: 0 2px 8px rgba(79,110,247,.3);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 14px rgba(79,110,247,.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1.5px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-copy {
    background: var(--accent);
    color: var(--text-on-dark);
    box-shadow: 0 2px 8px rgba(6,194,112,.25);
}

.btn-copy:hover {
    background: var(--accent-dark);
    box-shadow: 0 4px 14px rgba(6,194,112,.35);
    transform: translateY(-1px);
}

/* =============================================
   字符计数 & 状态
   ============================================= */
.char-count {
    color: var(--text-muted);
    font-size: 12px;
    padding: 4px 10px;
    background: var(--border-light);
    border-radius: 20px;
}

.status {
    color: var(--accent);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.status:not(:empty) {
    opacity: 1;
}

/* =============================================
   功能介绍卡片
   ============================================= */
.feature-desc {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 20px 24px;
    border: 1px solid var(--border-light);
    border-left: 3px solid var(--primary);
}

.feature-desc h3 {
    color: var(--primary);
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.feature-desc h3::before {
    content: "ℹ";
    font-size: 14px;
}

.feature-desc p {
    color: var(--text-secondary);
    line-height: 1.85;
    font-size: 14px;
}

/* =============================================
   滚动条美化
   ============================================= */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* =============================================
   文字选中高亮
   ============================================= */
::selection {
    background: rgba(79,110,247,.2);
    color: var(--text-primary);
}

/* =============================================
   响应式 — 平板 & 移动端
   ============================================= */
@media (max-width: 900px) {
    .container {
        margin: 20px 20px;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
    }

    body {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-height: auto;
        position: sticky;
        top: 0;
        flex-direction: row;
        align-items: center;
        padding: 0 12px;
        box-shadow: 0 2px 12px rgba(0,0,0,0.2);
    }

    .sidebar-logo {
        border-bottom: none;
        padding: 12px 10px;
        font-size: 14px;
        background: none;
        white-space: nowrap;
    }

    .sidebar-logo::before {
        display: none;
    }

    .sidebar-nav {
        flex-direction: row;
        padding: 0;
        gap: 2px;
        overflow-x: auto;
    }

    .nav-item {
        padding: 10px 10px;
        font-size: 12px;
        white-space: nowrap;
        transform: none !important;
    }

    .nav-item::before {
        display: none;
    }

    .main-content {
        margin-left: 0;
    }

    .header {
        padding: 20px 20px;
    }

    .header h1 {
        font-size: 20px;
    }

    .container {
        margin: 16px 12px;
        gap: 14px;
    }

    .text-areas {
        flex-direction: column;
        min-height: auto;
    }

    .text-column:first-child {
        border-right: none;
        border-bottom: 1px solid var(--border-light);
    }

    .text-column textarea {
        min-height: 160px;
        font-size: 14px;
    }

    .toolbar {
        flex-wrap: wrap;
        gap: 8px;
    }

    .toolbar-left {
        gap: 6px;
    }

    .btn {
        padding: 6px 13px;
        font-size: 12px;
    }
}
