html {
    font-size: 16px;
}

img,
video,
iframe,
canvas,
svg {
    max-width: 100%;
    height: auto;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    min-height: 100dvh;
    color: #333;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

.app-container {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    overflow-x: hidden;
    /* Ensure container doesn't overflow */
}

/* 側邊欄樣式 */
.sidebar {
    width: 260px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
    padding: 30px 0;
    position: fixed;
    height: 100vh;
    height: 100dvh;
    left: 0;
    top: 0;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    padding: 0 25px 30px;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 20px;
    flex-shrink: 0;
    text-align: right;
}

.sidebar-header h2 {
    font-size: 1.5rem;
    color: #667eea;
    font-weight: bold;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 15px;
    overflow-y: auto;
    flex: 1;
    /* Custom Scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(102, 126, 234, 0.5) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background-color: rgba(102, 126, 234, 0.3);
    border-radius: 20px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background-color: rgba(102, 126, 234, 0.8);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    border: none;
    background: transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    font-size: 1rem;
    color: #555;
    font-family: inherit;
}

.nav-item:hover {
    background: #f0f0f0;
    transform: translateX(5px);
}

.nav-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.nav-section-title {
    font-size: 0.8rem;
    color: #a0aec0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 15px 20px 5px;
    font-weight: bold;
    margin-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.nav-icon {
    font-size: 1.5rem;
}

.nav-text {
    font-weight: 500;
}

/* 主內容區 */
.main-content {
    flex: 1;
    margin-left: 0;
    padding: 80px 1rem 30px 1rem;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.page {
    width: 100%;
    max-width: 800px;
    /* Or whatever max-width you prefer for content */
}

.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

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

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

.page header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
    padding: 20px;
}

.page header h1 {
    font-size: 1.8rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
}

.content-wrapper {
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 100%;
    overflow-x: auto;
}


/* 自訂轉盤樣式 */
.wheel-section {
    margin-bottom: 3rem;
}

.wheel-container {
    position: relative;
    width: 100%;
    max-width: 300px;
    aspect-ratio: 1;
    height: auto;
    margin: 0 auto 2rem;
}

#wheelCanvas {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: transform 4s cubic-bezier(0.17, 0.67, 0.12, 0.99);
}

.wheel-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.spin-button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #FF6B6B 0%, #FF8E53 100%);
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(255, 107, 107, 0.3);
}

.spin-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 15px rgba(255, 107, 107, 0.4);
}

.spin-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.pointer {
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-top: 40px solid #FF6B6B;
    z-index: 20;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.result-section {
    text-align: center;
    min-height: 60px;
}

.result-display {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2d3748;
    padding: 1rem;
    border-radius: 10px;
    background: #f7fafc;
    display: inline-block;
    min-width: 300px;
    transition: all 0.3s ease;
}

.result-display.highlight {
    background: #FF6B6B;
    color: white;
    transform: scale(1.05);
    box-shadow: 0 10px 20px rgba(255, 107, 107, 0.3);
}

/* 選項管理 */
.wheel-management {
    background: #f8fafc;
    padding: 2rem;
    border-radius: 15px;
    border: 1px solid #e2e8f0;
}

.wheel-management h2 {
    margin-bottom: 1.5rem;
    color: #4a5568;
    font-size: 1.2rem;
}

.add-item {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.item-input {
    flex: 1;
    padding: 0.8rem 1.2rem;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.item-input:focus {
    outline: none;
    border-color: #667eea;
}

.add-btn {
    background: #48bb78;
    color: white;
    padding: 0 2rem;
}

.add-btn:hover {
    background: #38a169;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.3);
}

.item-list-container {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #edf2f7;
}

.list-header h3 {
    font-size: 1rem;
    color: #718096;
}

.item-count {
    background: #edf2f7;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.8rem;
    color: #4a5568;
    font-weight: bold;
}

.item-list {
    list-style: none;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem;
    border-bottom: 1px solid #f7fafc;
    transition: background-color 0.2s;
}

.item-row:last-child {
    border-bottom: none;
}

.item-row:hover {
    background-color: #f7fafc;
}

.item-row .name {
    font-weight: 500;
    color: #2d3748;
}

.list-actions {
    text-align: right;
    padding-top: 1rem;
    border-top: 1px solid #edf2f7;
}

.text-btn.danger {
    color: #e53e3e;
}

.text-btn.danger:hover {
    color: #c53030;
    background: #fff5f5;
}

.delete-btn:hover {
    background: #ff5252;
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(255, 107, 107, 0.4);
}

.restaurant-list h3 {
    margin-bottom: 15px;
    color: #555;
    font-size: 1.3rem;
}

.restaurant-items {
    list-style: none;
}

.restaurant-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border-radius: 10px;
    transition: all 0.3s ease;
    border-left: 4px solid #667eea;
}

.restaurant-item:hover {
    background: #e9ecef;
    transform: translateX(5px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.restaurant-item .name {
    font-size: 1.1rem;
    color: #333;
    font-weight: 500;
}

.empty-message {
    text-align: center;
    padding: 30px;
    color: #999;
    font-style: italic;
}

/* 工具推薦頁面樣式 */
.tools-section {
    padding: 20px 0;
}

.tool-categories {
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.tool-category h2 {
    font-size: 1.8rem;
    color: #333;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 3px solid #667eea;
}

.tools-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.tool-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 15px;
    padding: 25px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    text-align: center;
}

.tool-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.2);
    border-color: #667eea;
    background: white;
}

.tool-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.tool-card h3 {
    font-size: 1.3rem;
    color: #333;
    margin-bottom: 10px;
}

.tool-card p {
    color: #666;
    font-size: 0.95rem;
    margin-bottom: 15px;
    line-height: 1.5;
}

.tool-link {
    display: inline-block;
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.tool-link:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

@media (max-width: 1024px) {
    .sidebar {
        width: 200px;
    }
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: flex;
    /* Hidden on desktop */
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1002;
    background: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #667eea;
    transition: all 0.3s ease;
}

.mobile-menu-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

@media (min-width: 1025px) {
    .mobile-menu-btn {
        display: none;
    }

    .sidebar {
        width: 250px;
        transform: none;
        z-index: 100;
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
    }

    .sidebar-overlay {
        display: none !important;
    }

    .main-content {
        margin-left: 250px;
        padding: 30px;
        display: block;
        /* Reset flex display from mobile */
    }

    .page {
        max-width: none;
        /* Allow full width on desktop if desired, or keep a max-width */
    }

    .content-wrapper {
        padding: 40px;
    }

    .wheel-container {
        width: 400px;
        height: 400px;
        max-width: none;
        aspect-ratio: auto;
    }

    .wheel-center {
        width: 80px;
        height: 80px;
    }

    .spin-button {
        width: 60px;
        height: 60px;
    }

    .page header h1 {
        font-size: 2.5rem;
    }

    .tools-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }

    .language-switch {
        top: 20px;
        right: 20px;
    }

    .lang-btn {
        padding: 8px 20px;
        width: auto;
        height: auto;
        border-radius: 20px;
        justify-content: flex-start;
    }

    .lang-btn span {
        display: inline;
    }

    .upload-area {
        padding: 60px 20px;
    }

    .upload-area h3 {
        font-size: 1.5rem;
    }

    .controls-panel {
        padding: 30px;
    }

    .playback-controls {
        flex-direction: row;
    }

    .edit-tools {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

/* MP3 編輯器樣式 */
.mp3-editor-container {
    width: 100%;
}

.upload-area {
    border: 3px dashed #cbd5e0;
    border-radius: 20px;
    padding: 30px 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #667eea;
    background: #eef2ff;
    transform: scale(1.01);
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.upload-area h3 {
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 10px;
}

.upload-area p {
    color: #666;
}

.editor-interface {
    animation: fadeIn 0.5s ease;
}

.file-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: #f1f3f5;
    border-radius: 10px;
}

.file-info span {
    font-weight: 500;
    color: #333;
}

.text-btn {
    background: none;
    border: none;
    color: #ff6b6b;
    cursor: pointer;
    font-weight: bold;
    padding: 5px 10px;
}

.text-btn:hover {
    text-decoration: underline;
}

.waveform-container {
    background: #1a202c;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 30px;
    position: relative;
}

#waveform {
    width: 100%;
    height: 128px;
}

#wave-timeline {
    height: 20px;
    margin-top: 5px;
}

.controls-panel {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.playback-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.control-btn:hover {
    transform: scale(1.1);
    background: #667eea;
    color: white;
}

.control-btn.big {
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

#timeDisplay {
    font-family: monospace;
    font-size: 1.2rem;
    color: #555;
}

.edit-tools {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
}

.tool-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #4a5568;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-group input {
    width: 100px;
    padding: 8px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: #cbd5e0;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

/* 語言切換按鈕樣式 */
.language-switch {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 1000;
    display: flex;
    gap: 8px;
    align-items: center;
}

.lang-btn {
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #667eea;
    border-radius: 50%;
    padding: 0;
    width: 50px;
    height: 50px;
    min-width: 50px;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 800;
    color: #667eea;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 0;
}

.lang-btn span {
    display: inline-block;
    line-height: 1;
}



.lang-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.lang-icon {
    font-size: 1.1rem;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
}

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

.process-btn {
    width: 100%;
    padding: 15px;
    font-size: 1.2rem;
    margin-top: 10px;
}

.process-status {
    margin-top: 20px;
    text-align: center;
    padding: 20px;
    background: #ebf8ff;
    border-radius: 10px;
    color: #2b6cb0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #ebf8ff;
    border-top: 3px solid #3182ce;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* New Tools Styles */

/* PDF Tools */
.file-list {
    margin: 20px 0;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid #e9ecef;
}

/* Image Tools */
.preview-area {
    text-align: center;
    margin-top: 20px;
}

.image-controls {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e9ecef;
}

.control-row {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

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

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

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.small-input {
    width: 80px;
    padding: 5px;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
}

.small-select {
    padding: 5px;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    background: white;
}

/* Mindmap Tools */
.full-height {
    height: calc(100vh - 200px);
    padding: 0;
    overflow: hidden;
}

.split-view {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 500px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.editor-pane {
    width: 100%;
    height: 300px;
    border-right: none;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    background: #fff;
    position: relative;
}

.editor-pane:last-child {
    border-right: none;
}

.editor-pane label {
    display: block;
    padding: 10px 15px;
    background: #f7fafc;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.85rem;
    font-weight: bold;
    color: #4a5568;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.preview-pane {
    flex: 1;
    background: #f8fafc;
}

.code-editor.full {
    flex: 1;
    width: 100%;
    border: none;
    border-radius: 0;
    resize: none;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 14px;
    padding: 15px;
    line-height: 1.6;
    background: #fff;
    color: #2d3748;
}

.code-editor.full:focus {
    outline: none;
    background: #fff;
}

#mmSvg {
    width: 100%;
    height: 100%;
}

/* Hardware Tools */
.control-bar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.terminal-window {
    background: #1a202c;
    color: #48bb78;
    font-family: 'Courier New', Courier, monospace;
    padding: 15px;
    height: 200px;
    overflow-y: auto;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 14px;
}

.terminal-window p {
    margin: 5px 0;
    word-break: break-all;
}

.terminal-window .error {
    color: #fc8181;
}

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

.input-bar input {
    flex: 1;
    padding: 10px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
}

/* AI Lab */
.predictions-list {
    margin-top: 20px;
}

.prediction-item {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
    padding: 10px;
    background: #f7fafc;
    border-radius: 8px;
}

.prediction-item.danger {
    background: #fff5f5;
    border-left: 4px solid #fc8181;
}

.prediction-item.success {
    background: #f0fff4;
    border-left: 4px solid #48bb78;
}

.class-name {
    font-weight: bold;
    width: 120px;
}

.confidence-bar-bg {
    flex: 1;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.confidence-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}

.probability {
    font-family: monospace;
    font-weight: bold;
    color: #4a5568;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    color: white;
    background: #a0aec0;
}

.badge.success {
    background: #48bb78;
}

.badge.warning {
    background: #ed8936;
}

.badge.danger {
    background: #f56565;
}

/* Fortune Tools */
.almanac-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 30px;
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease;
}

.almanac-card:hover {
    transform: translateY(-2px);
}


.lunar-date-row {
    margin-bottom: 20px;
}

.lunar-year {
    font-size: 1.2rem;
    color: #718096;
}

.lunar-day {
    font-size: 3rem;
    font-weight: bold;
    color: #2d3748;
    margin: 10px 0;
}

.solar-term {
    font-size: 1.1rem;
    color: #38a169;
    margin-bottom: 20px;
}

.yi-ji-row {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.yi-box,
.ji-box {
    flex: 1;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    text-align: left;
}

.circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.circle.yi {
    background: #48bb78;
}

.circle.ji {
    background: #f56565;
}

.activities {
    font-size: 1rem;
    line-height: 1.5;
    color: #4a5568;
}

.extra-info {
    border-top: 1px solid #e2e8f0;
    padding-top: 15px;
    font-size: 0.9rem;
    color: #718096;
}

/* BaZi Chart */
.bazi-chart {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
}

.bazi-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    color: #4a5568;
    font-weight: bold;
}

.four-pillars {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-around;
    margin-bottom: 20px;
    background: #f7fafc;
    padding: 15px;
    border-radius: 8px;
}

.pillar {
    text-align: center;
    width: 45%;
    margin-bottom: 10px;
}

.pillar-title {
    font-size: 0.9rem;
    color: #718096;
    margin-bottom: 10px;
}

.gan {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2d3748;
}

.zhi {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2d3748;
    margin: 5px 0;
}

.cang-gan {
    font-size: 0.8rem;
    color: #a0aec0;
}

.yun-info {
    text-align: center;
    color: #4a5568;
    font-weight: bold;
}

/* Diff Tools */
.diff-result {
    margin-top: 20px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.upload-area.small {
    padding: 20px;
    min-height: 150px;
}

.file-name {
    display: block;
    margin-top: 10px;
    font-weight: bold;
    color: #4a5568;
    word-break: break-all;
}

/* Override Diff2Html styles if needed */
.d2h-file-header {
    display: none;
}

/* Engineering Tools */
.calc-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 25px;
}

.calc-card {
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.calc-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.calc-card h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.2rem;
    color: #2d3748;
    border-bottom: 2px solid #edf2f7;
    padding-bottom: 15px;
    font-weight: 700;
}

.result-box {
    margin-top: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #ebf8ff 0%, #e6fffa 100%);
    border-radius: 8px;
    font-weight: bold;
    color: #2c5282;
    text-align: center;
    border: 1px solid #bee3f8;
}

.small-input {
    width: 100px;
    padding: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    transition: border-color 0.2s;
}

.small-input:focus {
    border-color: #667eea;
    outline: none;
}

/* Data Tools */
.tool-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 10px;
}

.tab-btn {
    flex: 1 1 auto;
    padding: 8px 10px;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    color: #718096;
    border-radius: 8px;
    transition: all 0.2s ease;
    margin-right: 5px;
}

.tab-btn:hover {
    background: #edf2f7;
    color: #4a5568;
}

.tab-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(102, 126, 234, 0.4);
}

.code-editor {
    width: 100%;
    min-height: 200px;
    padding: 15px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-family: monospace;
    font-size: 14px;
    resize: vertical;
    margin-bottom: 15px;
    background: #f8fafc;
}

.code-editor:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* OCR Tools */
.progress-bar {
    width: 100%;
    height: 5px;
    background: #e2e8f0;
    border-radius: 3px;
    margin: 20px 0;
    overflow: hidden;
}

/* Wheel Memory Module */
.saved-sets-module {
    background: #f7fafc;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #edf2f7;
}

.saved-sets-module h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: #4a5568;
}

.saved-sets-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sets-select {
    width: 100%;
    padding: 8px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    background: white;
    font-size: 0.95rem;
}

.set-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.set-name-input {
    flex: 1;
    padding: 8px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 0.9rem;
}

.action-btn.small {
    padding: 8px 12px;
    font-size: 0.9rem;
}

.action-btn.danger {
    background: linear-gradient(135deg, #fc8181 0%, #f56565 100%);
}

.action-btn.danger:hover {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
}

.set-preview {
    margin-top: 10px;
    padding: 10px;
    background: #edf2f7;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #4a5568;
}

.preview-label {
    font-weight: bold;
    margin-right: 5px;
    color: #2d3748;
}

.preview-content {
    font-style: italic;
}

/* Outline Editor */
.outline-editor {
    width: 100%;
    height: 600px;
    padding: 20px;
    background: #fff;
    overflow-y: auto;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.outline-editor ul {
    list-style: none;
    padding-left: 20px;
    margin: 0;
}

.outline-editor li {
    position: relative;
    padding: 5px 0 5px 10px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.outline-editor li::before {
    content: "•";
    color: #cbd5e0;
    position: absolute;
    left: -5px;
    font-weight: bold;
    font-size: 1.2em;
    line-height: 1;
    top: 5px;
}

.outline-editor li:focus {
    outline: none;
    background: #ebf8ff;
}

.outline-editor li:hover {
    background: #f7fafc;
}

.outline-editor li:hover::before {
    color: #667eea;
}

.outline-editor div {
    outline: none;
}

.outline-editor li.dragging {
    opacity: 0.5;
    background: #e2e8f0;
}


@media (min-width: 1025px) {
    .split-view {
        flex-direction: row;
        height: 100%;
    }

    .editor-pane {
        width: 50%;
        height: auto;
        border-right: 1px solid #e2e8f0;
        border-bottom: none;
    }

    .tool-tabs {
        flex-wrap: nowrap;
        gap: 10px;
    }

    .tab-btn {
        flex: 0 1 auto;
        padding: 10px 20px;
    }

    .control-bar {
        flex-direction: row;
        align-items: center;
    }

    .input-bar {
        flex-direction: row;
    }

    .terminal-window {
        height: 300px;
    }

    .yi-ji-row {
        flex-direction: row;
        gap: 20px;
    }

    .four-pillars {
        flex-wrap: nowrap;
        gap: 0;
    }

    .pillar {
        width: auto;
        margin-bottom: 0;
    }

    .calc-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
}

.action-btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ==================== Bookkeeping Tool ==================== */
.bookkeeping-container {
    max-width: 900px;
    margin: 0 auto;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* Summary Cards */
.bk-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.summary-card {
    background: white;
    border-radius: 20px;
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.5);
    position: relative;
    overflow: hidden;
}

.summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
}

.summary-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

.summary-card.income {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
}

.summary-card.expense {
    background: linear-gradient(135deg, #f56565 0%, #c53030 100%);
    color: white;
}

.summary-card.balance {
    background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
    color: white;
}

.card-icon {
    font-size: 2.5rem;
    background: rgba(255, 255, 255, 0.2);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.card-info {
    flex: 1;
}

.summary-card h3 {
    font-size: 0.9rem;
    margin-bottom: 5px;
    opacity: 0.9;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: white;
    /* Override default */
}

.summary-card span {
    font-size: 1.8rem;
    font-weight: 700;
    display: block;
    line-height: 1.2;
}

/* Form Card */
.bk-form-card {
    background: white;
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
    border: 1px solid #edf2f7;
}

.bk-form-card h3 {
    margin-bottom: 25px;
    color: #2d3748;
    font-size: 1.4rem;
    font-weight: 600;
    position: relative;
    padding-left: 15px;
}

.bk-form-card h3::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 20px;
    background: #667eea;
    border-radius: 2px;
}

.bk-form-row {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 180px;
}

.input-group.flex-grow {
    flex: 2;
    min-width: 300px;
}

.input-group label {
    font-size: 0.9rem;
    color: #718096;
    font-weight: 600;
    margin-left: 5px;
}

.item-input {
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #f8fafc;
    color: #4a5568;
}

.item-input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.bk-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 25px;
}

.bk-actions .add-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 30px;
    border-radius: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
}

.bk-actions .add-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* List Section */
.bk-list-section {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
    border: 1px solid #edf2f7;
}

.bk-list-section h3 {
    margin-bottom: 25px;
    color: #2d3748;
    font-size: 1.4rem;
    font-weight: 600;
}

.bk-list-header {
    display: grid;
    grid-template-columns: 120px 140px 1fr 120px 50px;
    padding: 15px 20px;
    background: #f7fafc;
    border-radius: 12px;
    font-weight: 600;
    color: #718096;
    margin-bottom: 15px;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.bk-list {
    list-style: none;
    max-height: 600px;
    overflow-y: auto;
    padding-right: 5px;
}

/* Custom Scrollbar for list */
.bk-list::-webkit-scrollbar {
    width: 6px;
}

.bk-list::-webkit-scrollbar-track {
    background: transparent;
}

.bk-list::-webkit-scrollbar-thumb {
    background-color: #cbd5e0;
    border-radius: 20px;
}

.bk-item {
    display: grid;
    grid-template-columns: 120px 140px 1fr 120px 50px;
    padding: 20px;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    transition: all 0.2s ease;
    border-radius: 12px;
    margin-bottom: 5px;
}

.bk-item:hover {
    background: #f8fafc;
    transform: translateX(5px);
}

.bk-item:last-child {
    border-bottom: none;
}

.bk-date {
    color: #718096;
    font-size: 0.9rem;
    font-weight: 500;
}

.bk-cat {
    background: #ebf8ff;
    color: #3182ce;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-block;
    text-align: center;
    width: fit-content;
    box-shadow: 0 2px 5px rgba(49, 130, 206, 0.1);
}

.bk-desc {
    color: #2d3748;
    font-weight: 500;
}

.bk-amt {
    font-weight: 700;
    text-align: right;
    font-size: 1.1rem;
}

.bk-item.income .bk-amt {
    color: #48bb78;
}

.bk-item.expense .bk-amt {
    color: #f56565;
}

.bk-item .action-btn {
    opacity: 0.5;
    transition: opacity 0.2s;
}

.bk-item:hover .action-btn {
    opacity: 1;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .bk-list-header {
        display: none;
    }

    .bk-item {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "cat date"
            "desc amt"
            "action action";
        gap: 10px;
        padding: 20px;
        border: 1px solid #edf2f7;
        margin-bottom: 15px;
        background: white;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
    }

    .bk-date {
        grid-area: date;
        justify-self: end;
        font-size: 0.85rem;
    }

    .bk-cat {
        grid-area: cat;
        justify-self: start;
    }

    .bk-desc {
        grid-area: desc;
        font-size: 1.1rem;
        margin-top: 5px;
    }

    .bk-amt {
        grid-area: amt;
        font-size: 1.3rem;
        align-self: center;
    }

    .bk-item .action-btn {
        grid-area: action;
        width: 100%;
        margin-top: 10px;
        background: #fff5f5;
        color: #e53e3e;
        border: 1px solid #fed7d7;
    }

    .bk-summary {
        grid-template-columns: 1fr;
    }
}