/* ================================================
   E-Paper Controller — Neumorphism Theme (新拟态)
   ================================================ */

:root {
    /* Neumorphism Base Color */
    --bg-base: #e0e5ec;
    
    /* Neumorphism Shadows */
    --shadow-light: rgba(255, 255, 255, 0.9);
    --shadow-dark: rgba(163, 177, 198, 0.6);
    
    /* Extruded (凸起) */
    --neu-out: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--shadow-light);
    /* Small Extruded */
    --neu-out-sm: 4px 4px 10px var(--shadow-dark), -4px -4px 10px var(--shadow-light);
    /* Indented (凹陷) */
    --neu-in: inset 6px 6px 12px var(--shadow-dark), inset -6px -6px 12px var(--shadow-light);
    /* Clicked/Active State */
    --neu-active: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light);

    /* Text Colors */
    --text-primary: #4a5568;     /* Dark slate gray */
    --text-secondary: #718096;   /* Slate gray */
    --text-muted: #a0aec0;       /* Light gray */

    /* Accent Colors */
    --accent-blue: #4299e1;
    --accent-success: #48bb78;
    --accent-error: #f56565;

    /* Border Radius */
    --radius-sm: 10px;
    --radius-md: 20px;
    --radius-lg: 30px;

    /* Transitions */
    --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
    
    /* Font */
    --font-sans: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ================================================
   Apple iOS 26 Liquid Glass UI (液态玻璃 - 浅色)
   ================================================ */
[data-theme="glass"] {
    --bg-base: #f8fafc; /* Light bright base */
    
    /* Liquid Gloss Highlights & Refraction Shadows (Light Mode) */
    --neu-out: 
        inset 0 2px 3px rgba(255, 255, 255, 1), /* Extra glossy top edge */
        inset 0 -1px 4px rgba(0, 0, 0, 0.03), /* Very soft bottom depth */
        0 20px 40px rgba(0, 0, 0, 0.08), /* Soft airy outer shadow */
        0 0 0 1px rgba(255, 255, 255, 0.6); /* Thick liquid stroke */
        
    --neu-out-sm: 
        inset 0 1px 2px rgba(255, 255, 255, 0.9),
        inset 0 -1px 2px rgba(0, 0, 0, 0.02),
        0 8px 20px rgba(0, 0, 0, 0.05),
        0 0 0 1px rgba(255, 255, 255, 0.5);

    --neu-in: 
        inset 0 3px 8px rgba(0, 0, 0, 0.06),
        inset 0 0 0 1px rgba(255, 255, 255, 0.5),
        0 1px 1px rgba(255, 255, 255, 0.8);

    --neu-active: 
        inset 0 4px 10px rgba(0, 0, 0, 0.1),
        inset 0 0 0 1px rgba(255, 255, 255, 0.4);

    /* Text Colors */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    /* Accent Colors */
    --accent-blue: #0ea5e9;
    --accent-success: #10b981;
    --accent-error: #ef4444;
}

[data-theme="glass"] .card, 
[data-theme="glass"] .app-header, 
[data-theme="glass"] .history-panel {
    background: linear-gradient(150deg, rgba(255,255,255,0.7) 0%, rgba(255,255,255,0.3) 100%);
    backdrop-filter: blur(40px) saturate(200%);
    -webkit-backdrop-filter: blur(40px) saturate(200%);
    border: none;
    box-shadow: var(--neu-out);
}

[data-theme="glass"] textarea,
[data-theme="glass"] .chip,
[data-theme="glass"] .btn,
[data-theme="glass"] .card-icon,
[data-theme="glass"] .logo-icon,
[data-theme="glass"] .status-badge,
[data-theme="glass"] .history-toggle,
[data-theme="glass"] .history-close,
[data-theme="glass"] .history-entry {
    background: linear-gradient(150deg, rgba(255,255,255,0.6) 0%, rgba(255,255,255,0.2) 100%);
    border: none;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--neu-out-sm);
    color: var(--text-primary);
}

[data-theme="glass"] .quick-label {
    color: var(--text-muted);
}

[data-theme="glass"] textarea {
    background: rgba(0,0,0,0.02);
    box-shadow: var(--neu-in);
}

[data-theme="glass"] .btn:hover,
[data-theme="glass"] .chip:hover,
[data-theme="glass"] .history-toggle:hover {
    background: linear-gradient(150deg, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0.4) 100%);
    transform: translateY(-1px);
}

[data-theme="glass"] .btn:active,
[data-theme="glass"] .chip:active {
    box-shadow: var(--neu-active);
    transform: translateY(1px);
}

[data-theme="glass"] textarea:focus {
    background: rgba(255,255,255,0.5);
    box-shadow: var(--neu-in), 0 0 0 3px rgba(14, 165, 233, 0.3);
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

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

/* ---------- App Container ---------- */
.app-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 20px 40px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---------- Header ---------- */
.app-header {
    padding: 24px 32px;
    border-radius: var(--radius-md);
    background-color: var(--bg-base);
    box-shadow: var(--neu-out);
    margin-bottom: 36px;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo-icon {
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: var(--bg-base);
    box-shadow: var(--neu-out);
    color: var(--accent-blue);
    flex-shrink: 0;
}

.logo-icon svg {
    width: 24px;
    height: 24px;
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.02em;
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* Status Badge */
.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: 100px;
    background-color: var(--bg-base);
    box-shadow: var(--neu-in);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-success);
    transition: all 0.3s var(--ease-out);
}

.status-badge.loading {
    color: #ed8936;
}

.status-badge.error {
    color: var(--accent-error);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: currentColor;
    box-shadow: 0 0 6px currentColor;
}

/* ---------- Main Grid ---------- */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    flex: 1;
}

@media (max-width: 768px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
}

/* ---------- Cards ---------- */
.card {
    position: relative;
    border-radius: var(--radius-lg);
    background-color: var(--bg-base);
    padding: 36px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--neu-out);
}

/* Card Header */
.card-header {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 28px;
}

.card-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: var(--bg-base);
    box-shadow: var(--neu-out-sm);
    color: var(--text-primary);
    flex-shrink: 0;
}

.card-icon svg {
    width: 22px;
    height: 22px;
}

.card-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.card-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ---------- Textarea ---------- */
.textarea-wrapper {
    position: relative;
    margin-bottom: 28px;
}

textarea {
    width: 100%;
    padding: 20px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-base);
    border: none;
    border-radius: var(--radius-md);
    resize: vertical;
    min-height: 140px;
    box-shadow: var(--neu-in);
    outline: none;
    transition: all 0.3s var(--ease-out);
}

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

textarea:focus {
    box-shadow: inset 8px 8px 16px var(--shadow-dark), inset -8px -8px 16px var(--shadow-light);
}

.char-count {
    position: absolute;
    bottom: 16px;
    right: 20px;
    font-size: 0.75rem;
    color: var(--text-muted);
    pointer-events: none;
    font-weight: 600;
}

/* ---------- Quick Messages ---------- */
.quick-messages {
    margin-bottom: 32px;
}

.quick-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-weight: 600;
}

.quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.chip {
    padding: 10px 20px;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: var(--font-sans);
    border: none;
    border-radius: 100px;
    background-color: var(--bg-base);
    color: var(--text-secondary);
    box-shadow: var(--neu-out-sm);
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
}

.chip:hover {
    color: var(--accent-blue);
}

.chip:active {
    box-shadow: var(--neu-active);
    color: var(--text-primary);
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 32px;
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-md);
    background-color: var(--bg-base);
    color: var(--accent-blue);
    box-shadow: var(--neu-out);
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
    margin-top: auto;
}

.btn-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.btn:hover {
    color: #2b6cb0;
}

.btn:active {
    box-shadow: var(--neu-active);
}

/* Loading state */
.btn.loading {
    pointer-events: none;
    box-shadow: var(--neu-in);
    color: var(--text-muted);
}

.btn.loading .btn-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------- Card Toast ---------- */
.card-toast {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 14px 24px;
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 600;
    background-color: var(--bg-base);
    box-shadow: var(--neu-out);
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s var(--ease-out);
    z-index: 10;
    white-space: nowrap;
}

.card-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.card-toast.success {
    color: var(--accent-success);
}

.card-toast.error {
    color: var(--accent-error);
}

/* ---------- Footer ---------- */
.app-footer {
    text-align: center;
    padding: 48px 0 16px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* ---------- History Panel ---------- */
.history-toggle {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: var(--bg-base);
    box-shadow: var(--neu-out);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    color: var(--text-secondary);
    transition: all 0.2s var(--ease-out);
    border: none;
}

.history-toggle:hover {
    color: var(--accent-blue);
}

.history-toggle:active {
    box-shadow: var(--neu-active);
}

.history-toggle svg {
    width: 24px;
    height: 24px;
}

.history-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 360px;
    height: 100vh;
    background-color: var(--bg-base);
    z-index: 200;
    transform: translateX(100%);
    transition: transform 0.4s var(--ease-out);
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 30px rgba(163, 177, 198, 0.3);
}

.history-panel.open {
    transform: translateX(0);
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 32px 28px;
    box-shadow: 0 4px 10px rgba(163, 177, 198, 0.15);
}

.history-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.history-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--bg-base);
    box-shadow: var(--neu-out-sm);
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.history-close:active {
    box-shadow: var(--neu-active);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.history-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 40px 0;
}

.history-entry {
    padding: 20px;
    border-radius: var(--radius-md);
    background-color: var(--bg-base);
    box-shadow: var(--neu-out-sm);
    margin-bottom: 20px;
}

.history-entry .he-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 600;
}

.history-entry .he-action {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.history-entry .he-detail {
    font-size: 0.85rem;
    color: var(--text-secondary);
    word-break: break-all;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-base);
}

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

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
    .app-container {
        padding: 20px 16px 40px;
    }

    .app-header {
        padding: 24px;
        margin-bottom: 24px;
    }

    .card {
        padding: 24px;
    }

    .history-panel {
        width: 100%;
    }
}

/* ---------- Theme Toggle ---------- */
.theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--bg-base);
    box-shadow: var(--neu-out-sm);
    border: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
}
.theme-toggle:hover {
    color: var(--accent-blue);
}
.theme-toggle:active {
    box-shadow: var(--neu-active);
}
.theme-toggle svg {
    width: 18px;
    height: 18px;
}

/* ---------- Apple iOS 26 Liquid Glass Background (Light Mode) ---------- */
.glass-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    display: none;
    background-color: #f8fafc;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(186, 230, 253, 0.8), transparent 45%),
        radial-gradient(circle at 90% 80%, rgba(233, 213, 255, 0.8), transparent 45%),
        radial-gradient(circle at 50% 50%, rgba(167, 243, 208, 0.5), transparent 60%);
    filter: blur(60px);
    animation: liquidBreath 18s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
}
[data-theme="glass"] .glass-bg {
    display: block;
}

@keyframes liquidBreath {
    0% { transform: scale(1) rotate(0deg); }
    100% { transform: scale(1.15) rotate(4deg); }
}
