@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@300;400;500&family=Inter:wght@400;500;600&display=swap');

:root {
    --bark: #5C3D2E;
    --bark-light: #8B6651;
    --leaf: #4A7C59;
    --leaf-light: #6B9F78;
    --soil: #2C1A0E;
    --sky: #EAE8E0;
    --paper: #F7F4EE;
    --paper-warm: #F0EBE1;
    --ink: #2C1A0E;
    --ink-light: #7A6355;

    --ribbon-blue: #5B8DB8;
    --ribbon-orange: #D4735A;
    --ribbon-pink: #D4849A;
    --ribbon-green: #5A9B72;
    --ribbon-purple: #8B6BAE;
    --ribbon-gray: #9A9490;
    --ribbon-gold: #C9962A;

    --radius-sm: 4px;
    --radius-md: 10px;
    --radius-lg: 20px;
    --shadow-soft: 0 2px 16px rgba(44, 26, 14, 0.08);
    --shadow-card: 0 4px 24px rgba(44, 26, 14, 0.12);
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: var(--paper);
    color: var(--ink);
    line-height: 1.7;
    min-height: 100vh;
}

/* ============================
   全局布局
============================ */
.pg-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.pg-topbar {
    background: var(--bark);
    color: #F7F4EE;
    padding: 14px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

.pg-topbar .logo {
    font-family: 'Noto Serif SC', serif;
    font-size: 18px;
    font-weight: 500;
    letter-spacing: 2px;
    color: #F0EBE1;
}

.pg-topbar .logo span {
    color: #D4A96A;
}

.pg-nav {
    display: flex;
    gap: 6px;
}

.pg-nav a {
    padding: 7px 18px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    color: rgba(240, 235, 225, 0.7);
    text-decoration: none;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.pg-nav a:hover { color: #F0EBE1; }

.pg-nav a.active {
    background: rgba(240, 235, 225, 0.15);
    color: #F0EBE1;
    border-color: rgba(240, 235, 225, 0.25);
}

.pg-main {
    flex: 1;
    padding: 32px;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

/* ============================
   卡片 / Section
============================ */
.pg-section {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    margin-bottom: 28px;
    overflow: hidden;
}

.pg-section-header {
    padding: 18px 24px 14px;
    border-bottom: 1px solid rgba(44,26,14,0.07);
    display: flex;
    align-items: center;
    gap: 10px;
}

.pg-section-header h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-light);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.pg-section-body {
    padding: 24px;
}

/* tree-scene / tree-svg-wrap 已废弃，改用 hero-wrap */

/* ============================
   Hero 主视觉区
============================ */
.hero-wrap {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    height: 580px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    margin-bottom: 28px;
    box-shadow: var(--shadow-card);
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
}

.hero-bg {
    display: none; /* 背景直接设在 hero-wrap 上，此 div 废弃 */
}

.hero-overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(
        180deg,
        rgba(20, 12, 6, 0.15) 0%,
        rgba(20, 12, 6, 0.05) 35%,
        rgba(20, 12, 6, 0.55) 70%,
        rgba(20, 12, 6, 0.85) 100%
    );
}

.hero-brand {
    position: relative;
    z-index: 2;
    padding: 28px 32px 0;
    display: inline-block;
}

.hero-brand-inner {
    display: inline-flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(20, 12, 6, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 10px;
    padding: 14px 20px 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.hero-logo {
    font-family: 'Noto Serif SC', serif;
    font-size: 22px;
    font-weight: 500;
    color: rgba(247, 244, 238, 0.97);
    letter-spacing: 3px;
}

.hero-slogan {
    font-family: 'Noto Serif SC', serif;
    font-size: 12px;
    color: rgba(247, 244, 238, 0.7);
    letter-spacing: 1.5px;
}

/* 底部丝带卡片区 */
.hero-cards-area {
    position: relative;
    z-index: 2;
    padding: 0 20px 24px;
}

.ribbon-cards-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 12px 0 16px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.ribbon-cards-scroll::-webkit-scrollbar { display: none; }

/* 单条丝带卡片 */
.ribbon-card {
    /* 样式由 playground/ui.html 内联 <style> 控制 */
    border-radius: 0;
}

/* 顶部丝带色条 */
.ribbon-card-knot {
    height: 4px;
    background: var(--rc, var(--ribbon-blue));
}

.ribbon-card-body {
    padding: 14px 14px 12px;
}

.ribbon-card-text {
    font-family: 'Noto Serif SC', serif;
    font-size: 13px;
    color: rgba(247, 244, 238, 0.9);
    line-height: 1.8;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 10px;
}

.ribbon-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: rgba(247, 244, 238, 0.45);
}

.ribbon-card-count {
    display: flex;
    align-items: center;
    gap: 3px;
}

/* Hero 底部操作按钮 */
.hero-action {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-tie {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 12px 28px;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: rgba(247, 244, 238, 0.95);
    color: var(--soil);
    transition: all 0.2s;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.btn-tie:hover { background: white; transform: translateY(-1px); }

.btn-witness {
    display: inline-flex;
    align-items: center;
    padding: 12px 22px;
    border-radius: 999px;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    border: 1.5px solid rgba(247,244,238,0.4);
    background: transparent;
    color: rgba(247,244,238,0.8);
    transition: all 0.2s;
}
.btn-witness:hover {
    border-color: rgba(247,244,238,0.7);
    color: rgba(247,244,238,1);
}

/* ============================
   故事详情弹窗样式
============================ */
.story-modal-demo {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.story-modal-ribbon {
    height: 5px;
    background: var(--rc, var(--ribbon-blue));
}

.story-modal-content {
    padding: 24px 24px 16px;
}

.story-modal-text {
    font-family: 'Noto Serif SC', serif;
    font-size: 15px;
    line-height: 1.95;
    color: var(--ink);
}

.story-modal-resonances {
    padding: 0 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.resonance-item {
    background: var(--paper);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 13px;
    color: var(--ink-light);
    border: 1px solid var(--color-border);
}

.story-modal-input-area {
    padding: 16px 24px;
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 10px;
    align-items: center;
}

/* 草地 */
.grass {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(180deg, transparent, #4A6741 100%);
    z-index: 1;
}

/* 树场景底部操作区 */
.tree-actions {
    position: absolute;
    bottom: 24px;
    right: 24px;
    z-index: 10;
    display: flex;
    gap: 10px;
}

/* ============================
   按钮
============================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 20px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--bark);
    color: #F7F4EE;
}
.btn-primary:hover { background: var(--soil); }

.btn-ghost {
    background: rgba(255,255,255,0.9);
    color: var(--bark);
    border: 1px solid rgba(92,61,46,0.2);
    backdrop-filter: blur(6px);
}
.btn-ghost:hover { background: white; }

.btn-outline {
    background: transparent;
    color: var(--bark);
    border: 1.5px solid var(--bark);
}
.btn-outline:hover { background: rgba(92,61,46,0.06); }

.btn-sm { padding: 7px 14px; font-size: 13px; }

.btn img { width: 16px; height: 16px; opacity: 0.85; }

/* ============================
   表单
============================ */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    margin-bottom: 7px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid #E8E2D9;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    color: var(--ink);
    background: var(--paper);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--bark-light);
    box-shadow: 0 0 0 3px rgba(92,61,46,0.08);
    background: white;
}

textarea.form-control { resize: vertical; min-height: 110px; line-height: 1.6; }

.form-hint { font-size: 12px; color: var(--ink-light); margin-top: 5px; }

/* ============================
   丝带颜色选择器
============================ */
.color-picker {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
    padding: 6px 0;
}

.color-option {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.color-option::after {
    content: attr(title);
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: var(--ink-light);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
}

.color-option:hover { transform: scale(1.15); }
.color-option:hover::after { opacity: 1; }

.color-option.selected {
    border-color: var(--ink);
    transform: scale(1.2);
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

/* ============================
   故事卡片
============================ */
.story-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.story-card {
    background: white;
    border-radius: var(--radius-md);
    padding: 22px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(0,0,0,0.04);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.story-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card);
}

/* 顶部丝带色条 */
.story-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--card-color, var(--ribbon-blue));
}

/* 左侧竖线禁止，改为顶部色条 ✓ */

.story-card-quote {
    font-family: 'Noto Serif SC', serif;
    font-size: 32px;
    color: var(--card-color, var(--ribbon-blue));
    opacity: 0.3;
    line-height: 1;
    margin-bottom: 8px;
}

.story-content {
    font-family: 'Noto Serif SC', serif;
    font-size: 14px;
    line-height: 1.9;
    color: var(--ink);
    margin-bottom: 16px;
}

.story-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--ink-light);
}

.story-footer .ribbon-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--card-color, var(--ribbon-blue));
    display: inline-block;
    margin-right: 5px;
    vertical-align: middle;
}

.story-footer .resonance-count {
    display: flex;
    align-items: center;
    gap: 4px;
}

.story-footer img { width: 13px; height: 13px; opacity: 0.5; }

/* ============================
   AI Playground 布局
============================ */
.ai-playground-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
    align-items: start;
}

.prompt-panel .pg-section {
    position: sticky;
    top: 80px;
}

/* Provider 切换 */
.provider-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    background: var(--paper);
    padding: 5px;
    border-radius: var(--radius-md);
}

.provider-tab {
    flex: 1;
    padding: 8px 12px;
    border-radius: 7px;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-light);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.provider-tab.active {
    background: white;
    color: var(--ink);
    box-shadow: var(--shadow-soft);
}

/* 对话框 */
.chat-container {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    height: 600px;
}

.chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-light);
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--paper);
}

.message { max-width: 82%; }

.message-user { margin-left: auto; }

.message-user .bubble {
    background: var(--bark);
    color: #F7F4EE;
    padding: 12px 16px;
    border-radius: 18px 18px 4px 18px;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.message-ai { margin-right: auto; }

.message-ai .bubble {
    background: white;
    border: 1px solid rgba(0,0,0,0.08);
    padding: 14px 18px;
    border-radius: 4px 18px 18px 18px;
    font-family: 'Noto Serif SC', serif;
    font-size: 14px;
    line-height: 1.9;
    color: var(--ink);
    white-space: pre-wrap;
    box-shadow: var(--shadow-soft);
}

.message-label {
    font-size: 11px;
    color: var(--ink-light);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-input-area {
    padding: 16px 20px;
    border-top: 1px solid rgba(0,0,0,0.06);
    background: white;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.chat-input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input-row .form-control {
    flex: 1;
    background: var(--paper);
    border-color: #E8E2D9;
    border-radius: 12px;
    resize: none;
    max-height: 100px;
    overflow-y: auto;
}

/* 预设 Prompt 按钮组 */
.preset-btns {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.preset-btn {
    padding: 5px 12px;
    border-radius: 999px;
    border: 1.5px solid #E8E2D9;
    background: white;
    font-size: 12px;
    color: var(--ink-light);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.preset-btn:hover, .preset-btn.active {
    border-color: var(--bark-light);
    color: var(--bark);
    background: rgba(92,61,46,0.05);
}

/* ============================
   见证码展示
============================ */
.witness-code {
    font-family: 'Courier New', monospace;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 8px;
    color: var(--bark);
    text-align: center;
    background: var(--paper-warm);
    padding: 20px;
    border-radius: var(--radius-md);
    border: 2px dashed #D4C4B0;
    margin: 16px 0;
}

/* ============================
   响应状态
============================ */
.typing-dots::after {
    content: '●●●';
    animation: blink 1.2s infinite;
    color: var(--ink-light);
    font-size: 12px;
    letter-spacing: 3px;
}

@keyframes blink {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}
