:root {
    --bg-color: #fdfcf8;
    /* Cream white canvas */
    --primary-color: #D8C5F3;
    /* Lilac / Dusty Rose */
    --primary-dark: #b8a0db;
    --text-color: #3d3b40;
    --text-light: #7a7680;
    --card-bg: #ffffff;
    --tape-purple: #D8C5F3;
    --tape-pink: #f3c5d8;
    --tape-green: #d8f3c5;
    --tape-gold: #f3e8c5;

    --shadow-soft: 0 10px 25px rgba(0, 0, 0, 0.05);
    --shadow-polaroid: 0 4px 12px rgba(0, 0, 0, 0.08);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "SF Pro Rounded", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: hidden;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(216, 197, 243, 0.1) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(216, 197, 243, 0.1) 0%, transparent 20%);
}

.handwritten,
.view-title,
.handwritten-note,
.logo-text {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "SF Pro Rounded", Arial, sans-serif;
    font-weight: 800;
}

.app-container {
    display: flex;
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
}

/* Sidebar Navigation */
.sidebar {
    width: 260px;
    padding: 40px 30px;
    display: flex;
    flex-direction: column;
    border-right: 2px dashed rgba(216, 197, 243, 0.5);
    position: relative;
    z-index: 10;
}

.logo {
    margin-bottom: 60px;
}

.logo-text {
    display: block;
    font-size: 2.8rem;
    color: var(--primary-dark);
    line-height: 1.2;
}

.logo-sub {
    font-size: 0.9rem;
    color: var(--text-light);
    letter-spacing: 1px;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-color);
    font-size: 1.2rem;
    font-weight: 600;
    padding: 10px 15px;
    border-radius: 8px;
    transition: all 0.3s ease;
    display: block;
    position: relative;
}

.nav-links a:hover {
    background-color: rgba(216, 197, 243, 0.2);
}

.nav-links a.active {
    background-color: var(--primary-color);
    color: #fff;
    box-shadow: 2px 4px 10px rgba(216, 197, 243, 0.4);
    transform: rotate(-2deg);
}

.nav-decor {
    margin-top: auto;
}

/* Main Content Area */
.content-area {
    flex: 1;
    padding: 50px 60px;
    position: relative;
}

.view {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.view.active-view {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.view-title {
    font-size: 3.5rem;
    color: var(--text-color);
    margin-bottom: 40px;
    position: relative;
    display: inline-block;
}

.view-title::after {
    content: '';
    position: absolute;
    bottom: 5px;
    left: 0;
    width: 100%;
    height: 12px;
    background-color: rgba(216, 197, 243, 0.4);
    z-index: -1;
    transform: rotate(-1deg);
}

/* Auth Modal Overlay */
.auth-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(253, 252, 248, 0.85); /* Cream white with opacity */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Polaroid Card Layout */
.grid-layout {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 40px;
}

.polaroid-card {
    background-color: var(--card-bg);
    padding: 15px 15px 40px 15px;
    box-shadow: var(--shadow-polaroid);
    position: relative;
    transition: transform 0.3s ease;
    max-width: 320px;
}

.polaroid-card:hover {
    transform: translateY(-5px) scale(1.02) !important;
    z-index: 5;
}

.polaroid-card.tilt-left {
    transform: rotate(-3deg);
}

.polaroid-card.tilt-right {
    transform: rotate(2deg);
}

.polaroid-card.wide-card {
    max-width: 100%;
}

.polaroid-content {
    background-color: #f9f9f9;
    border: 1px solid #eee;
    padding: 30px 20px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
}

.center-content {
    align-items: center;
    justify-content: center;
}

.polaroid-caption {
    font-family: 'Zhi Mang Xing', cursive;
    font-size: 1.5rem;
    text-align: center;
    margin-top: 15px;
    color: var(--text-color);
}

/* Washi Tape */
.washi-tape {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%) rotate(-2deg);
    width: 120px;
    height: 35px;
    background-color: var(--tape-purple);
    opacity: 0.8;
    z-index: 2;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    /* Jagged edges for tape */
    clip-path: polygon(0 5%, 5% 0, 10% 5%, 15% 0, 20% 5%, 25% 0, 30% 5%, 35% 0, 40% 5%, 45% 0, 50% 5%, 55% 0, 60% 5%, 65% 0, 70% 5%, 75% 0, 80% 5%, 85% 0, 90% 5%, 95% 0, 100% 5%, 100% 95%, 95% 100%, 90% 95%, 85% 100%, 80% 95%, 75% 100%, 70% 95%, 65% 100%, 60% 95%, 55% 100%, 50% 95%, 45% 100%, 40% 95%, 35% 100%, 30% 95%, 25% 100%, 20% 95%, 15% 100%, 10% 95%, 5% 100%, 0 95%);
}

.tape-pink {
    background-color: var(--tape-pink);
    transform: translateX(-50%) rotate(3deg);
}

.tape-green {
    background-color: var(--tape-green);
    width: 150px;
}

.tape-gold {
    background-color: var(--tape-gold);
    transform: translateX(-50%) rotate(1deg);
}

/* Status Indicators */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    font-weight: 600;
}

.pulse-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.pulse-dot.green {
    background-color: #4caf50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
}

.pulse-dot.red {
    background-color: #f44336;
    box-shadow: 0 0 8px rgba(244, 67, 54, 0.6);
}

.pulse-dot.gray {
    background-color: #9e9e9e;
}

.status-details h2 {
    font-size: 1.8rem;
    color: var(--primary-dark);
    margin-top: 5px;
    word-break: break-all;
}

/* Stats */
.stats-row {
    display: flex;
    gap: 30px;
    margin-top: 20px;
}

.stat-item {
    text-align: center;
}

.stat-val {
    display: block;
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary-dark);
    line-height: 1;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-light);
}

/* Providers List */
.providers-list {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
}

.provider-item {
    padding: 20px;
    border: 2px dashed #ddd;
    border-radius: 12px;
    min-width: 250px;
    transition: all 0.3s ease;
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.5);
}

.provider-item:hover {
    border-color: var(--primary-color);
    background-color: rgba(216, 197, 243, 0.1);
}

.provider-item.active-provider {
    border: 2px solid var(--primary-color);
    background-color: rgba(216, 197, 243, 0.2);
    position: relative;
}

.provider-item.active-provider::after {
    content: '当前使用';
    position: absolute;
    top: -12px;
    right: 10px;
    background-color: var(--primary-color);
    color: white;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
}

.provider-name {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.provider-model {
    font-size: 0.9rem;
    color: var(--text-light);
}

/* Animal Stickers */
.sticker {
    position: absolute;
    z-index: 20;
    filter: drop-shadow(2px 4px 6px rgba(0, 0, 0, 0.1));
    /* Hover animation removed as requested */
}

.bottom-left-sticker {
    bottom: 20px;
    left: 20px;
    width: 180px;
}

.bottom-right-sticker {
    bottom: 20px;
    right: 20px;
    width: 160px;
}

.top-right-sticker {
    top: 40px;
    right: 40px;
    width: 120px;
}

.penguin-sticker {
    width: 100px;
    opacity: 0.8;
    margin-bottom: 20px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        padding: 20px;
        border-right: none;
        border-bottom: 2px dashed rgba(216, 197, 243, 0.5);
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .logo {
        margin-bottom: 0;
    }

    .logo-text {
        font-size: 2rem;
    }

    .nav-links {
        flex-direction: row;
        gap: 10px;
    }

    .nav-links a {
        font-size: 1rem;
        padding: 8px 12px;
    }

    .nav-decor {
        display: none;
    }

    .content-area {
        padding: 30px 20px;
    }

    .view-title {
        font-size: 2.5rem;
    }

    .sticker {
        width: 100px;
        opacity: 0.6;
    }
}

/* Forms & Inputs */
.custom-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-color);
}

.custom-form input[type="text"],
.custom-form input[type="password"],
.custom-form input[type="number"],
.custom-form select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1.05rem;
    transition: border-color 0.3s;
}

.custom-form input:focus,
.custom-form select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-primary,
.btn-secondary {
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary {
    background-color: var(--primary-color);
    color: #fff;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-secondary {
    background-color: #eee;
    color: #333;
}

.btn-secondary:hover {
    background-color: #ddd;
}

/* Sliders */
.slider-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.slider-group label {
    font-size: 0.95rem;
    font-weight: 600;
}

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--primary-dark);
    cursor: pointer;
    margin-top: -6px;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: #ddd;
    border-radius: 2px;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.form-desc {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 15px;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    min-width: 250px;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideInRight 0.3s ease-out forwards;
    cursor: pointer;
}

.toast.success {
    background-color: #d4edda;
    color: #155724;
    border-left: 5px solid #28a745;
}

.toast.error {
    background-color: #f8d7da;
    color: #721c24;
    border-left: 5px solid #dc3545;
}

.toast.info {
    background-color: #e2e3e5;
    color: #383d41;
    border-left: 5px solid #6c757d;
}

.toast.fade-out {
    animation: fadeOutRight 0.3s ease-in forwards;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Memory Browser Styles */
.memory-stats-bar {
    display: flex;
    justify-content: space-around;
    background: #fff;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
    border: 1px dashed #ccc;
}

.memory-stats-bar span {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--primary-dark);
}

.memory-filter-bar {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.5);
    padding: 15px;
    border-radius: 12px;
}

.memory-filter-bar input,
.memory-filter-bar select {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
}

.memory-filter-bar input:focus,
.memory-filter-bar select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.memory-card-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 0.95rem;
}

.memory-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
    margin-bottom: 5px;
}

.memory-title {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--text-color);
}

.memory-tier-badge {
    background: #eee;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
}

.memory-tier-badge.t1 {
    background: var(--tape-gold);
    color: #8a6d3b;
}

.memory-tier-badge.t2 {
    background: var(--tape-purple);
    color: #5a4b7a;
}

.memory-tier-badge.t3 {
    background: var(--tape-pink);
    color: #8a4b65;
}

.memory-tier-badge.t4 {
    background: var(--tape-green);
    color: #3b8a4b;
}

.memory-core {
    font-style: italic;
    color: #555;
    background: rgba(0, 0, 0, 0.02);
    padding: 10px;
    border-radius: 6px;
    line-height: 1.5;
}

.memory-yanjin {
    font-family: 'Zhi Mang Xing', cursive, "PingFang SC";
    font-size: 1.2rem;
    color: var(--primary-dark);
    margin-top: 10px;
    line-height: 1.4;
}

.memory-footer {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 10px;
}

.memory-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-self: flex-start;
}

.memory-tags span {
    background: rgba(216, 197, 243, 0.2);
    color: var(--primary-dark);
    padding: 2px 6px;
    border-radius: 4px;
}

.memory-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 40px;
}

.memory-pagination button {
    padding: 8px 20px;
}

/* Request Logs Styles */
.log-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 700px;
    overflow-y: auto;
    padding: 10px;
}

.log-entry {
    background: #fff;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border-left: 4px solid var(--primary-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.2s;
    /* Notebook paper background */
    background-image: repeating-linear-gradient(transparent, transparent 31px, #f4f4f4 31px, #f4f4f4 32px);
    background-position: 0 10px;
}

.log-entry:hover {
    transform: translateX(5px);
}

.log-entry.error-log {
    border-left-color: #f44336;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-light);
}

.log-time {
    font-weight: bold;
    color: var(--primary-dark);
}

.log-route {
    font-size: 1.05rem;
    font-weight: 600;
}

.log-details {
    display: flex;
    gap: 15px;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.8);
    padding: 5px;
    border-radius: 4px;
}

.log-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: bold;
}

.log-entry.expanded {
    transform: none;
    background-image: none;
    border-left-width: 6px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.log-details-full {
    display: none;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed #ddd;
    font-size: 0.9rem;
    animation: fadeIn 0.3s;
}

.log-entry.expanded .log-details-full {
    display: block;
}

.log-section {
    margin-bottom: 15px;
}

.log-section-title {
    font-weight: bold;
    color: var(--primary-dark);
    margin-bottom: 5px;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.log-content-box {
    background: #f9f9f9;
    padding: 10px;
    border-radius: 8px;
    white-space: pre-wrap;
    font-family: 'Inter', sans-serif;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #eee;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Playground Styles */
.playground-container {
    max-width: 800px;
    margin: 0 auto;
}

.pg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 2px dashed #eee;
    margin-bottom: 15px;
}

.pg-select {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #ccc;
    background: #fdfcf8;
    font-size: 0.95rem;
    color: var(--primary-dark);
    font-weight: bold;
}

.pg-chat-area {
    height: 400px;
    overflow-y: auto;
    background: #fdfcf8;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 15px;
    border: 1px solid #eee;
}

.pg-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
}

.pg-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.pg-avatar {
    font-size: 1.5rem;
}

.pg-bubble {
    background: #fff;
    padding: 12px 16px;
    border-radius: 16px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    font-size: 0.95rem;
    line-height: 1.5;
    white-space: pre-wrap;
}

.pg-message.user .pg-bubble {
    background: var(--primary-color);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.pg-message.system .pg-bubble {
    background: #f4f4f4;
    color: #555;
    border-bottom-left-radius: 4px;
}

.pg-input-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#pg-input {
    width: 100%;
    height: 80px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid #ccc;
    resize: none;
    font-family: inherit;
    font-size: 1rem;
    background: #fdfcf8;
}

#pg-input:focus {
    outline: none;
    border-color: var(--primary-dark);
}

.pg-footer-stats {
    font-size: 0.8rem;
    color: #888;
    text-align: right;
    margin-top: -5px;
}

/* ── Toggle Switch (iOS Style) ─────────────────────────── */

.toggle-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 15px 0;
    border-bottom: 1px dashed #e0dcd5;
}

.toggle-group:last-child {
    border-bottom: none;
}

.toggle-info {
    flex: 1;
}

.toggle-label {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-color);
    cursor: pointer;
}

.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-toggle {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    border-radius: 28px;
    transition: background-color 0.3s ease;
}

.slider-toggle::before {
    content: "";
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

input:checked + .slider-toggle {
    background-color: var(--primary-dark);
}

input:checked + .slider-toggle::before {
    transform: translateX(24px);
}

/* ── Log Tabs & Filter Bar ─────────────────────────────── */

.log-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e0dcd5;
    width: fit-content;
}

.log-tab {
    padding: 8px 20px;
    border: none;
    background: var(--card-bg);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-light);
    transition: all 0.2s ease;
}

.log-tab:hover {
    background: #f5f0ea;
}

.log-tab.active {
    background: var(--primary-color);
    color: var(--text-color);
    font-weight: 600;
}

.log-filter-bar {
    display: flex;
    gap: 15px;
    align-items: flex-end;
    padding: 15px 20px;
    background: var(--card-bg);
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #e0dcd5;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 500;
}

.filter-group input,
.filter-group select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.85rem;
    background: var(--bg-color);
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--primary-dark);
}