/* ============================================
   app.css —— VibeLab 子应用共用外壳
   （顶部工具栏 / 按钮 / 面板 / 表单 / Toast / 响应式）
   设计基调：白底 + 中性灰阶 + 单一蓝色主色，克制、可信
   ============================================ */

:root {
    /* —— 面 —— */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-elevated: #ffffff;
    --bg-subtle: #f1f5f9;        /* 输入框 / 分段控件底 */
    --bg-overlay: rgba(15, 23, 42, 0.04);  /* 浅色浮层 */

    /* —— 文字 —— */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;

    /* —— 强调色（保留旧变量名，便于各子应用复用）—— */
    --accent-primary: #2563eb;
    --accent-purple: #4f46e5;
    --accent-cyan: #0891b2;
    --accent-pink: #db2777;
    --accent-blue: #2563eb;
    --accent-green: #059669;
    --accent-orange: #ea580c;
    --accent-red: #dc2626;

    /* 主按钮用近同色系渐变，视觉上就是一块干净的蓝 */
    --gradient-primary: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
    --gradient-secondary: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --gradient-accent: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
    --gradient-rainbow: linear-gradient(135deg, #2563eb, #4f46e5, #0891b2, #059669);

    /* —— 边框 —— */
    --border-color: #e2e8f0;
    --border-strong: #cbd5e1;
    --border-hover: #94a3b8;

    /* —— 阴影：浅色下靠极轻的投影分层，不用发光 —— */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.07);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.1);
    --shadow-glow: 0 4px 14px rgba(37, 99, 235, 0.25);

    --font-mono: 'JetBrains Mono', Consolas, Monaco, monospace;
    --font-sans: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;

    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);

    --topbar-h: 60px;

    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ===== 背景光晕（简约版：默认不显示，保留结构便于按需开启） ===== */
.bg-effects {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0;
    animation: orbFloat 24s ease-in-out infinite;
    display: none;
}

.orb-1 {
    width: 480px;
    height: 480px;
    background: var(--accent-blue);
    top: -160px;
    left: -120px;
}

.orb-2 {
    width: 420px;
    height: 420px;
    background: var(--accent-cyan);
    bottom: -160px;
    right: -120px;
    animation-delay: -8s;
}

.orb-3 {
    width: 300px;
    height: 300px;
    background: var(--accent-purple);
    top: 45%;
    left: 55%;
    animation-delay: -16s;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(40px, -30px) scale(1.08); }
    66%      { transform: translate(-30px, 30px) scale(0.95); }
}

/* ===== 顶部工具栏 ===== */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 1.25rem;
    background: var(--bg-blur);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
}

.top-bar-left,
.top-bar-center,
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.top-bar-center {
    flex: 1;
    justify-content: center;
    min-width: 0;
}

.app-title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    white-space: nowrap;
}

.app-title .sep {
    color: var(--text-muted);
    font-weight: 400;
    margin: 0 0.25rem;
}

/* ===== 图标按钮 ===== */
.icon-btn {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.icon-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-strong);
    background: var(--bg-card-hover);
    transform: translateY(-1px);
}

.icon-btn:active {
    transform: translateY(0) scale(0.95);
}

.icon-btn.active {
    color: var(--accent-primary);
    border-color: var(--accent-line-strong);
    background: var(--accent-tint);
}

.icon-btn:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* ===== 通用按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

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

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

.btn:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--gradient-primary);
    border-color: transparent;
    color: #fff;
    font-weight: 600;
}

/* 注意：这两条规则必须重新声明 background / border-color。
   .btn:hover 的选择器权重是 (0,2,0)，高于 .btn-primary 的 (0,1,0)，
   如果这里不重申，悬停时背景会被 .btn:hover 的 --bg-card-hover 顶掉、
   边框会被换成 --border-strong —— 浅色主题下就是「浅底 + 白字」，文字直接看不见。 */
.btn-primary:hover {
    background: var(--gradient-primary);
    border-color: transparent;
    color: #fff;
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn-primary:active {
    background: var(--gradient-primary);
    border-color: transparent;
    transform: translateY(0) scale(0.97);
}

.btn-danger:hover {
    color: var(--accent-red);
    border-color: rgba(220, 38, 38, 0.35);
    background: rgba(220, 38, 38, 0.06);
}

.btn-sm {
    padding: 0.35rem 0.7rem;
    font-size: 0.78rem;
    border-radius: var(--radius-sm);
}

.btn-icon-only {
    padding: 0.55rem;
}

/* ===== 分段选项卡 ===== */
.seg-tabs {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow-x: auto;
    scrollbar-width: none;
}

.seg-tabs::-webkit-scrollbar {
    display: none;
}

.seg-tab {
    padding: 0.35rem 0.85rem;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.seg-tab:hover {
    color: var(--text-primary);
}

.seg-tab.active {
    background: var(--bg-card);
    color: var(--accent-primary);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

/* ===== 面板 ===== */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.panel-title {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.panel-body {
    padding: 1rem;
}

.panel-body.tight {
    padding: 0.65rem;
}

/* ===== 表单控件 ===== */
.form-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
}

.form-label .hint {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.form-value {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent-primary);
    min-width: 52px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

input[type="text"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--border-color);
    border-radius: 9px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    transition: border-color var(--transition-fast);
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-tint-strong);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                      linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
    background-position: calc(100% - 16px) calc(50% + 1px), calc(100% - 11px) calc(50% + 1px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 2rem;
}

select option {
    background: var(--bg-primary);
    color: var(--text-primary);
}

input[type="number"] {
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* 滑块 */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: var(--border-color);
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--accent-solid);
    border: 2px solid var(--bg-card);
    cursor: pointer;
    transition: transform var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

input[type="range"]::-moz-range-thumb {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--accent-solid);
    border: 2px solid var(--bg-card);
    cursor: pointer;
}

/* 复选框 */
.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.checkbox input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

/* 色板选择 */
.swatch-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.swatch {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.swatch:hover {
    transform: scale(1.12);
}

.swatch.active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-tint-strong);
}

/* ===== 标签 / 徽章 ===== */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 500;
    background: var(--accent-tint);
    color: var(--accent-primary);
    border: 1px solid var(--accent-line);
    white-space: nowrap;
}

.chip.cyan {
    background: rgba(8, 145, 178, 0.08);
    color: var(--accent-cyan);
    border-color: rgba(8, 145, 178, 0.2);
}

.chip.green {
    background: rgba(5, 150, 105, 0.08);
    color: var(--accent-green);
    border-color: rgba(5, 150, 105, 0.2);
}

/* ===== 空状态 ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 2.5rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.85rem;
}

/* ===== Toast 提示 ===== */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 999;
    pointer-events: none;
}

.toast {
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.85rem;
    box-shadow: var(--shadow-md);
    animation: toastIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast.out {
    animation: toastOut 0.25s ease forwards;
}

.toast.success {
    border-color: rgba(5, 150, 105, 0.4);
}

.toast.error {
    border-color: rgba(220, 38, 38, 0.4);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(20px) scale(0.9); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
    to { opacity: 0; transform: translateY(10px) scale(0.95); }
}

/* ===== 页面容器 ===== */
.app-main {
    position: relative;
    z-index: 1;
    padding-top: var(--topbar-h);
    min-height: 100vh;
}

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

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

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

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

::selection {
    background: var(--accent-tint-stronger);
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .top-bar {
        padding: 0 0.75rem;
        gap: 0.5rem;
    }

    .top-bar-center {
        display: none;
    }

    .app-title {
        font-size: 0.9rem;
    }
}

/* 窄屏：顶栏图标多，让标题缩成省略号、图标收紧，保证最后一个图标不被裁掉 */
@media (max-width: 520px) {
    .top-bar-left {
        min-width: 0;
        flex-shrink: 1;
    }

    .top-bar-right {
        flex-shrink: 0;
        gap: 0.35rem;
    }

    .top-bar .icon-btn {
        width: 34px;
        height: 34px;
    }

    .app-title {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ===== 顶栏博客入口 ===== */
/* 用 .top-bar 前缀提高权重，避免被上面的窄屏 .top-bar .icon-btn 规则盖掉宽度 */
.top-bar .icon-btn.blog-entry {
    width: auto;
    padding: 0 0.7rem;
    gap: 0.4rem;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.blog-entry-label {
    white-space: nowrap;
}

/* 窄屏收成纯图标，不给顶栏增加宽度压力 */
@media (max-width: 680px) {
    .top-bar .icon-btn.blog-entry {
        width: 34px;
        height: 34px;
        padding: 0;
    }

    .blog-entry-label {
        display: none;
    }
}

/* ===== 降低动效偏好 ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}
