/* docs2/css/* Subheader Hierarchy Fix */
.section-subheader {
    font-size: 15px;
    font-weight: 700;
    color: #444444;
    /* Deep Gray */
    margin-top: 24px;
    margin-bottom: 8px;
    display: block;
    width: 100%;
}

/* Themed Hint Banner */
.hint-banner {
    padding: 10px 14px;
    background: rgba(var(--accent-rgb), 0.04);
    border: 1px solid rgba(var(--accent-rgb), 0.1);
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--accent-color);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.hint-banner:hover {
    background: rgba(var(--accent-rgb), 0.07);
    transform: translateX(2px);
}

/* Tab-Specific Color Themes */
.card-theme-blue {
    --accent-color: var(--theme-blue);
    --accent-rgb: 74, 144, 226;
    --accent-tint: rgba(var(--accent-rgb), 0.08);
}

.card-theme-indigo {
    --accent-color: var(--theme-indigo);
    --accent-rgb: 92, 107, 192;
    --accent-tint: rgba(var(--accent-rgb), 0.08);
}

.card-theme-teal {
    --accent-color: var(--theme-teal);
    --accent-rgb: 38, 166, 154;
    --accent-tint: rgba(var(--accent-rgb), 0.08);
}

.card-theme-slate {
    --accent-color: var(--theme-slate);
    --accent-rgb: 120, 144, 156;
    --accent-tint: rgba(var(--accent-rgb), 0.08);
}

.card-theme-green {
    --accent-color: var(--theme-green);
    --accent-rgb: 67, 160, 71;
    --accent-tint: rgba(var(--accent-rgb), 0.08);
}

.card-theme-orange {
    --accent-color: var(--theme-orange);
    --accent-rgb: 255, 152, 0;
    --accent-tint: rgba(var(--accent-rgb), 0.08);
}

.card-theme-amber {
    --accent-color: var(--theme-amber);
    --accent-rgb: 211, 84, 0;
    --accent-tint: rgba(var(--accent-rgb), 0.08);
}

.card-theme-purple {
    --accent-color: var(--theme-purple);
    --accent-rgb: 142, 68, 173;
    --accent-tint: rgba(var(--accent-rgb), 0.08);
}

.card-theme-lavender {
    --accent-color: var(--theme-lavender);
    --accent-rgb: 171, 71, 188;
    --accent-tint: rgba(var(--accent-rgb), 0.08);
}

.card-theme-wine {
    --accent-color: var(--theme-wine);
    --accent-rgb: 194, 24, 91;
    --accent-tint: rgba(var(--accent-rgb), 0.08);
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;900&display=swap');

:root {
    --ios-blue: #007AFF;
    --ios-green: #34C759;
    --ios-gray: #8E8E93;
    --ios-light: #F2F2F7;
    --ios-dark: #1C1C1E;
    --sidebar-bg: #FFFFFF;
    --preview-bg: #E6E7EA;
    --topbar-bg: #1A202C;
    --tab-inactive: #2D3748;
    --tab-active: #1A202C;

    /* Theme Colors - Hybrid System */
    --theme-blue: #4A90E2;
    --theme-indigo: #5C6BC0;
    --theme-teal: #26A69A;
    --theme-slate: #78909C;
    --theme-green: #43A047;
    --theme-orange: #FF9800;
    --theme-amber: #D35400;
    --theme-purple: #8E44AD;
    --theme-lavender: #AB47BC;
    --theme-wine: #C2185B;

    /* Global Header Accent */
    --accent-color: var(--theme-blue);
    --accent-rgb: 74, 144, 226;
    --accent-tint: rgba(var(--accent-rgb), 0.05);
    
    /* Safe Area Insets - 為不支援 env() 的瀏覽器提供回退值 */
    --safe-area-inset-top: env(safe-area-inset-top, 0px);
    --safe-area-inset-right: env(safe-area-inset-right, 0px);
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-inset-left: env(safe-area-inset-left, 0px);
}

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

html {
    /* 確保 HTML 元素支援安全區域 */
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    height: 100vh;
    /* 使用 dvh (dynamic viewport height) 在支援的瀏覽器上，否則回退到 vh */
    height: 100dvh;
    overflow: hidden;
    background-color: #F8F9FA;
    /* 確保 body 不會被瀏海遮擋 */
    position: relative;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

/* Top Navigation Bar */
.top-bar {
    min-height: 54px;
    background-color: var(--topbar-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    /* 安全區域支援：避免被 iPhone 瀏海遮擋 */
    padding-top: var(--safe-area-inset-top);
    padding-left: max(24px, var(--safe-area-inset-left));
    padding-right: max(24px, var(--safe-area-inset-right));
    z-index: 50;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    /* 確保內容不會溢出 */
    box-sizing: border-box;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-r {
    width: 24px;
    height: 24px;
    background-color: #6B8FBF;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 700;
}

.brand-title {
    color: #B0B0B0;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Toolbar Grid */
.toolbar-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 10px;
    background: #F8FAFC;
    padding: 16px;
    border-radius: 12px;
    border: 2px dashed #CBD5E0;
}

.toolbar-slot {
    aspect-ratio: 1;
    background: #FFFFFF;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: all 0.2s;
}

.toolbar-slot:hover {
    border-color: #3182CE;
    transform: translateY(-2px);
}

.slot-number {
    position: absolute;
    top: -6px;
    left: -6px;
    width: 20px;
    height: 20px;
    background: #2D3748;
    color: white;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.tool-icon-preview {
    font-size: 24px;
    color: #2D3748;
}

.tool-list-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tool-list-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.tool-item-btn {
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 4px;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.tool-item-btn:hover {
    background: #EBF8FF;
    border-color: #bee3f8;
}

.tool-label-small {
    font-size: 11px;
    color: #4A5568;
    white-space: nowrap;
}

.section-label {
    font-size: 12px;
    font-weight: 700;
    color: #718096;
    margin-top: 8px;
}

/* Modal/Dropdown Placeholder */
.tool-selector-indicator {
    border: 2px solid #3182CE;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.5);
}

.action-section {
    display: flex;
    align-items: center;
    gap: 24px;
}

.skin-style-hint {
    color: #A0AEC0;
    font-size: 11px;
}

.skin-style-hint span {
    color: white;
}

.btn-export {
    background-color: var(--ios-blue);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-export:hover {
    background-color: #0062CC;
    transform: translateY(-1px);
}

.btn-import {
    background-color: var(--ios-green);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-import:hover {
    background-color: #28a745;
    transform: translateY(-1px);
}

/* Main Layout */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    width: 100%;
}

/* Left Preview Column */
.preview-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Prevent shrinking below content */
    background-color: #E6E7EA;
    position: relative;
    border-right: 1px solid #D1D5DB;
    overflow: hidden;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: center;
    /* Center the capsule */
    background: transparent;
    /* Transparent header */
    padding: 0 16px;
    height: 60px;
    /* Unified height */
    box-sizing: border-box;
    flex-shrink: 1;
    min-width: 0;
    border-bottom: none;
    /* Removed border for floating look */
    z-index: 100;
}

.controls-pill {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 4px 4px;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.4);
    height: 42px;
    width: auto;
}

.pill-side {
    display: flex;
    align-items: center;
    height: 100%;
}

.pill-side.left:empty {
    display: none;
}

.pill-side.right {
    justify-content: flex-end;
}

.pill-center {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.pill-group {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow: hidden;
}

@media (max-width: 768px) {
    .pill-group {
        gap: 2px;
    }
}

.pill-divider {
    width: 1px;
    height: 20px;
    background: #E2E8F0;
    margin: 0 8px;
}

/* Pill Button Styles */
.pill-btn-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 16px;
    color: #4A5568;
}

.pill-btn-circle:hover {
    background: rgba(0, 0, 0, 0.05);
}

.btn-shift.active {
    background: #3182CE;
    /* iOS Blue */
    color: #FFFFFF;
    box-shadow: 0 2px 4px rgba(49, 130, 206, 0.3);
}

.btn-menu.active,
.btn-theme:active {
    background: rgba(0, 0, 0, 0.1);
}

/* Mini Segmented for Pill */
.mini-segmented.no-bg {
    background: transparent;
    padding: 2px;
}

.mini-btn-pill {
    padding: 6px 8px;
    border-radius: 20px;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    color: #718096;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .mini-btn-pill {
        padding: 6px 6px;
        font-size: 12px;
    }
}

.mini-btn-pill:hover {
    color: #2D3748;
}

.mini-btn-pill.active {
    background: #EDF2F7;
    color: #2B6CB0;
}

/* Reset All Button specifically in the pill */
.pill-btn-circle.btn-reset-all {
    background: #E53E3E;
    color: #FFFFFF;
    font-size: 22px;
    /* Amplified for clarity */
    box-shadow: 0 2px 4px rgba(229, 62, 62, 0.3);
    transition: all 0.2s;
}

.pill-btn-circle.btn-reset-all:hover {
    background: #C53030;
}

.pill-btn-circle.btn-reset-all:active {
    transform: scale(0.9) rotate(-45deg);
}

/* Transitions */
.pill-fade-enter-active,
.pill-fade-leave-active {
    transition: all 0.3s ease;
    max-width: 200px;
    opacity: 1;
}

.pill-fade-enter-from,
.pill-fade-leave-to {
    max-width: 0;
    opacity: 0;
    margin-right: 0;
    transform: translateX(-10px);
}

.preview-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

/* Right Settings Column */
.settings-area {
    width: 50%;
    /* 左右 1:1 */
    background-color: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    flex-shrink: 0;
    /* 安全區域支援：避免被底部 Home Indicator 遮擋 */
    padding-bottom: var(--safe-area-inset-bottom);
    box-sizing: border-box;
}

/* Tabs */
.tabs-header {
    display: flex;
    background-color: #FFFFFF;
    padding: 8px;
    height: 60px;
    /* Unified height */
    box-sizing: border-box;
    flex-shrink: 0;
    border-bottom: 1px solid #E2E8F0;
}

.tab-btn {
    flex: 1;
    padding: 10px 0;
    background: transparent;
    border: none;
    color: #718096;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 8px;
}

.tab-btn.active {
    background-color: #1A202C;
    color: #FFFFFF;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.tab-btn:not(.active):hover {
    color: #1A202C;
    background-color: #F7FAFC;
}

/* Settings Content & Components */
.settings-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background-color: #F7FAFC;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Card Style */
.settings-card {
    background: #FFFFFF;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: #2D3748;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--accent-tint);
    border-radius: 24px;
    /* Pill shape for title background too */
    /* Removed negative margins and full width to prevent swallowing buttons */
}

.card-title::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 18px;
    background-color: var(--accent-color);
    border-radius: 3px;
}

.btn-reset-small {
    padding: 6px 16px;
    font-size: 11px;
    font-weight: 600;
    background: var(--accent-tint);
    border: 1px solid rgba(var(--accent-rgb), 0.2);
    border-radius: 20px;
    /* Pill Shape */
    color: var(--accent-color);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    box-shadow: 4px 4px 15px rgba(var(--accent-rgb), 0.05);
}

.btn-reset-small:hover:not(:disabled),
.card-theme-blue .btn-reset-small:hover:not(:disabled),
.card-theme-indigo .btn-reset-small:hover:not(:disabled),
.card-theme-teal .btn-reset-small:hover:not(:disabled),
.card-theme-slate .btn-reset-small:hover:not(:disabled),
.card-theme-green .btn-reset-small:hover:not(:disabled),
.card-theme-orange .btn-reset-small:hover:not(:disabled),
.card-theme-amber .btn-reset-small:hover:not(:disabled),
.card-theme-purple .btn-reset-small:hover:not(:disabled),
.card-theme-lavender .btn-reset-small:hover:not(:disabled),
.card-theme-wine .btn-reset-small:hover:not(:disabled) {
    background: var(--accent-color);
    color: #FFFFFF;
    border-color: var(--accent-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.3);
}

.btn-reset-small:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
    box-shadow: none;
}

.btn-clear-red {
    padding: 6px 16px;
    font-size: 11px;
    font-weight: 600;
    background: #FFF5F5;
    border: 1px solid #FED7D7;
    border-radius: 20px;
    color: #E53E3E;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    box-shadow: 4px 4px 15px rgba(229, 62, 62, 0.05);
}

.btn-clear-red:hover {
    background: #E53E3E;
    color: #FFFFFF;
    border-color: #E53E3E;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(229, 62, 62, 0.3);
}

.btn-apply-blue {
    padding: 6px 16px;
    font-size: 11px;
    font-weight: 600;
    background: #EBF8FF;
    border: 1px solid #BEE3F8;
    border-radius: 20px;
    color: #3182CE;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    box-shadow: 4px 4px 15px rgba(49, 130, 206, 0.05);
}

.btn-apply-blue:hover {
    background: #3182CE;
    color: #FFFFFF;
    border-color: #3182CE;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(49, 130, 206, 0.3);
}

/* Segmented Control */
.segmented-control {
    display: flex;
    background: #EDF2F7;
    padding: 4px;
    border-radius: 8px;
    width: 100%;
}

.segment-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 0;
    font-size: 15px;
    font-weight: 400;
    color: #718096;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.segment-btn.active {
    background: #FFFFFF;
    color: #2B6CB0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Range & Color Inputs */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-label {
    font-size: 15px;
    font-weight: 400;
    color: #4A5568;
    display: flex;
    justify-content: space-between;
}

.input-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #F8FAFC;
    padding: 12px;
    border-radius: 8px;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    background: transparent;
    padding: 0;
}

.settings-grid .input-row {
    margin: 0;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

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

.slider-round {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #CBD5E0;
    transition: .4s;
    border-radius: 24px;
}

.slider-round:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

input:checked+.slider-round {
    background-color: #3182CE;
}

input:focus+.slider-round {
    box-shadow: 0 0 1px #3182CE;
}

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

.custom-range {
    flex: 1;
    accent-color: #2B6CB0;
}

.value-badge {
    min-width: 40px;
    text-align: center;
    background: #E2E8F0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    color: #2D3748;
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-input-hex {
    width: 80px;
    padding: 4px 8px;
    border: 1px solid #E2E8F0;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}

/* Dark Mode Overrides for Headers */
[data-theme="dark"] .preview-header {
    background-color: transparent;
}

[data-theme="dark"] .controls-pill {
    background: rgba(45, 55, 72, 0.85);
    /* Darker blue-gray glass */
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .pill-btn-circle {
    color: #CBD5E0;
}

[data-theme="dark"] .pill-btn-circle:hover {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .mini-btn-pill.active {
    background: rgba(255, 255, 255, 0.1);
    color: #63B3ED;
}

[data-theme="dark"] .pill-divider {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .tabs-header {
    background-color: #1C1C1E;
    border-color: #3A3A3C;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 12px;
    border-right: 1px solid #E2E8F0;
}

.control-group:last-child {
    border-right: none;
    padding-right: 0;
}

.mini-segmented {
    display: flex;
    background: #EDF2F7;
    padding: 2px;
    border-radius: 20px;
}

.mini-btn {
    border: none;
    background: transparent;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    color: #718096;
    cursor: pointer;
    border-radius: 18px;
}

.mini-btn.active {
    background: #FFFFFF;
    color: #2D3748;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-icon-circle {
    width: 32px;
    height: 32px;
    border: none;
    background: #FFFFFF;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    font-size: 16px;
    transition: all 0.2s;
}

.btn-icon-circle:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.btn-icon-circle.active {
    background: #3182CE;
    color: white;
}

/* Responsive Keyboard Container */
.keyboard-viewport {
    width: 100%;
    /* Max width is controlled by parent or screen */
    /* Remove fixed padding that caused shift */
    position: relative;
    transform-origin: center;
    transition: all 0.3s;
    /* Ensure no clipping */
    overflow: visible;
    margin: 40px auto;
    /* Use margin to center and give space for shadow */
}

/* Keyboard Internal Layout (Final Spec 1125px) */
.kb-container {
    width: 1125px;
    height: auto;
    display: flex;
    flex-direction: column;
    overflow: visible;

    /* REMOVED fixed background-color to allow transparency settings */
    /* background-color: #ECECEC; */

    border-radius: 30px;
    /* Enhanced Drop Shadow */
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    /* No bottom margin needed if viewport handles spacing */
}

.kb-toolbar {
    width: 1125px;
    height: 119px;
    /* Calculated: 124px / 1.04 */
    display: flex;
    align-items: center;
    padding: 0;
    gap: 0;
    /* Ensure toolbar rounding matches top container if needed, 
       but container has overflow:visible now, so might need masking or separate radius */
    border-top-left-radius: 30px;
    border-top-right-radius: 30px;
}

.tool-btn-preview {
    width: 112.5px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tool-icon-img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    display: none;
    /* Hide original img if used */
}

.tool-mask-icon {
    display: block;
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}

.kb-keys-area {
    width: 1125px;
    height: auto;
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    /* Increased side padding */
    box-sizing: border-box;
    /* Ensure padding fits in 1125px */
    border-bottom-left-radius: 30px;
    border-bottom-right-radius: 30px;
}

/* Add top border radius when kb-keys-area contains symbolic keyboard to prevent corners showing when background color changes */
.kb-keys-area:has(.symbolic-kb) {
    border-top-left-radius: 30px;
    border-top-right-radius: 30px;
}

.kb-row {
    display: flex;
    justify-content: flex-start;
    width: 100%;
    /* Fill the padded area */
    height: auto;
}

/* Base Key Style */
.kb-key {
    background: #FFFFFF;
    border-radius: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: var(--key-shadow, 0 2px 0 rgba(0, 0, 0, 0.25));
    border: var(--key-border-width, 0) solid var(--key-border-color, transparent);
    box-sizing: border-box;

    /* Dimensions from Final Spec */
    height: 146.15px;
    margin: 5.77px;

    /* Font Styling from Visual Ref */
    font-weight: 500;
    /* Adjusted from 600 for better balance */
}

/* Width Utility Classes (calc(% - gap)) */
/* Gap to subtract = 11.54px */

.w-10 {
    width: calc(10% - 11.54px);
}

.w-14 {
    width: calc(14% - 11.54px);
}

.w-15 {
    width: calc(15% - 11.54px);
}

.w-16 {
    width: calc(16% - 11.54px);
}

.w-40 {
    width: calc(40% - 11.54px);
}

.w-48 {
    width: calc(48% - 11.54px);
}

/* Special Indent for Row 2 (A-L) */
.indent-row-2 {
    /* 5% indent + standard margin */
    margin-left: calc(5% + 5.77px);
}

.key-main-text {
    font-weight: 500;
}

/* Global Key Press Highlight Action */
.kb-key:active {
    background-color: var(--key-active-bg) !important;
    box-shadow: var(--key-shadow-active, 0 1px 0 rgba(0, 0, 0, 0.25)) !important;
    transform: scale(0.98) translateY(1px);
    /* Minimal haptic feedback */
    transition: background-color 0.05s, transform 0.05s, box-shadow 0.05s;
}

.key-swipe-hint {
    display: none;
}

/* === Swipe Hint Positioning === */
.kb-key {
    position: relative;
}

.swipe-hint {
    position: absolute;
    line-height: 1;
    pointer-events: none;
    font-weight: 400;
    z-index: 1;
}

/* Row 1-2-3: Top-Left for up, Bottom-Right for down */
.swipe-up-left {
    top: calc(8px - var(--key-border-width, 0px));
    left: calc(18px - var(--key-border-width, 0px));
}

.swipe-down-right {
    bottom: calc(8px - var(--key-border-width, 0px));
    right: calc(18px - var(--key-border-width, 0px));
}

/* Row 3 (Z-M): Bottom-Center for down-swipe */
.swipe-down-center {
    bottom: calc(6px - var(--key-border-width, 0px));
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
}

/* Z key icon: mask-based for theme-adaptive color */
.swipe-icon-mask {
    display: inline-block;
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}


/* === Key Press Bubble Popup === */
.kb-keys-area {
    position: relative;
}

.key-bubble {
    position: absolute;
    transform: translate(-50%, -100%);
    background-size: 100% 100%;
    background-repeat: no-repeat;
    z-index: 100;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bubble-text {
    font-weight: 500;
    line-height: 1;
    /* Shift text up to center in rectangular area above pointer (~20% of height) */
    transform: translateY(-18%);
}

/* === Long-press Bubble (CSS-based) === */
.long-press-bubble {
    position: absolute;
    z-index: 101;
    pointer-events: none;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    border-radius: 25px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
    padding: 5px;
    gap: 2px;
    white-space: nowrap;
}

.long-press-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 18px;
    border-radius: 20px;
    white-space: nowrap;
}

.long-press-cell-selected {
    background-color: #3578F5;
}

/* Compact mode for comma/period (5 items) */
.long-press-compact .long-press-cell {
    padding: 8px 10px;
}



/* Shift/Delete & Functional Keys - Mapped to Utility Classes in HTML now */
/* Keeping specific identifying classes for content/color logic, but sizes handled by w-XX */

/* 26 鍵 Row 2 第一位 (A鍵) 縮排 */


/* 修正工具列文字 (英/简) */
.tool-btn-preview {
    font-size: 16px;
    font-weight: 500;
}

.key-small {
    width: 154px;
    height: 130px;
}

/* 123/Globe/Enter */

.row-2 {
    padding-left: 50px;
    padding-right: 50px;
}

.kb-key.key-system {
    background: #ABB0BA;
}

/* Candidate Bar */
.candidate-bar {
    width: 100%;
    height: 119px;
    display: flex;
    align-items: center;
    padding: 0 30px 0 30px;
    /* Align with Q's symbol (!) roughly at 30px */
    padding-right: 51px;
    /* Calculated to center chevron icon with P key center */
    justify-content: space-between;
    overflow: hidden;
    box-sizing: border-box;
    border-radius: 25px 25px 0 0;
    /* 上方圓角，下方直角 */
}

.candidate-item {
    padding: 6px 24px;
    /* Increased horizontal padding for wider selection box */
    border-radius: 25px;
    /* Updated to 25px as requested */
    cursor: default;
    white-space: nowrap;
}

.candidate-expand-btn {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    flex-shrink: 0;
    width: 40px;
    /* Fixed width to ensure center calculation holds */
}

/* Expanded candidate view */
.candidate-expanded {
    width: 100%;
    height: 775px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    padding: 0 16px 12px 16px;
    /* Match 26-key padding: 12px bottom, 16px sides */
    border-radius: 25px;
    overflow: hidden;
}

.candidate-grid {
    flex: 1;
    /* Fill remaining space */
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    padding: 0;
    /* No padding, handled by parent */
}

.candidate-grid-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.candidate-grid-item {
    flex: 1;
    text-align: center;
    padding: 12px 0;
    cursor: default;
    border-radius: 25px;
    /* Updated to 25px */
}

.candidate-nav-bar {
    display: flex;
    gap: 0;
    /* No gap, use margin on buttons instead */
    padding: 0;
    /* No padding, handled by parent */
    justify-content: space-between;
    height: auto;
    /* Auto height to accommodate button + margin */
    flex-shrink: 0;
}

.candidate-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 25px;
    border: var(--key-border-width, 0) solid var(--key-border-color, transparent);
    box-sizing: border-box;
    cursor: pointer;
    flex: 1;
    height: 146.15px;
    margin: 5.77px;
    background-color: var(--key-bg);
    transition: background-color 0.1s, transform 0.05s, box-shadow 0.05s;
    box-shadow: var(--key-shadow, 0 2px 0 rgba(0, 0, 0, 0.25));
}

.candidate-nav-btn:active {
    background-color: var(--key-active-bg) !important;
    box-shadow: var(--key-shadow-active, 0 1px 0 rgba(0, 0, 0, 0.25)) !important;
    transform: scale(0.98) translateY(1px);
}

/* Bubbles */
.kb-bubble {
    position: absolute;
    bottom: 140px;
    /* 位於按鍵上方 */
    left: 50%;
    transform: translateX(-50%);
    background: #FFFFFF;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.click-bubble {
    width: 140px;
    height: 180px;
    font-size: 80px;
}

.longpress-bubble {
    padding: 10px 20px;
    gap: 15px;
    height: 100px;
}

.bubble-item {
    font-size: 40px;
    padding: 5px 15px;
    border-radius: 10px;
}

.bubble-item.selected {
    background: #3182CE;
}

/* Numeric & Symbolic Layouts */
.kb-numeric-layout {
    display: flex;
    width: 1125px;
    height: 690px;
}

.numeric-left-panel {
    width: 300px;
    display: flex;
    flex-direction: column;
    padding: 10px;
    gap: 12px;
}

.numeric-right-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(4, 1fr);
    padding: 10px;
    gap: 12px;
}

.key-numeric-big {
    font-size: 50px;
    font-weight: 400;
}

.num-row-merge {
    grid-column: span 2;
}

/* Symbolic Layout */
.kb-symbolic-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(4, 1fr);
    padding: 10px;
    gap: 12px;
    height: 690px;
}

/* Numeric Keyboard Layout */
.numeric-kb {
    display: flex;
    width: 100%;
    gap: 11.54px;
    height: auto;
    box-sizing: border-box;
    padding: 5.77px;
    /* Match 26-key layout margins (16px container + 5.77px key margin) */
}

.num-col {
    display: flex;
    flex-direction: column;
    gap: 11.54px;
    flex: 1;
}

.num-symbol-capsule {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    padding: 20px 0;
    height: calc(146.15px * 3 + 11.54px * 2);
    border-radius: 25px;
    box-sizing: border-box;
    user-select: none;
    box-shadow: var(--key-shadow, 0 2px 0 rgba(0, 0, 0, 0.25));
    border: var(--key-border-width, 0) solid var(--key-border-color, transparent);
}

.num-symbol-item {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex: 1;
}

.num-key {
    height: 146.15px;
    border-radius: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.1s;
    user-select: none;
    box-sizing: border-box;
    cursor: pointer;
    box-shadow: var(--key-shadow, 0 2px 0 rgba(0, 0, 0, 0.25));
    border: var(--key-border-width, 0) solid var(--key-border-color, transparent);
    font-size: 28px;
    /* Default for numbers */
}

/* Specific text-alignment for function keys */
.num-key.system,
.num-key.enter {
    font-weight: 500;
}

.num-key:active {
    background-color: var(--key-active-bg) !important;
    box-shadow: var(--key-shadow-active, 0 1px 0 rgba(0, 0, 0, 0.25)) !important;
    transform: scale(0.98) translateY(1px);
    transition: background-color 0.05s, transform 0.05s, box-shadow 0.05s;
}

.num-key.num {
    font-size: 72px;
    /* 24 * 3 */
}

.num-key.system {
    font-size: 48px;
    /* 16 * 3 */
}

.num-key.enter {
    font-size: 48px;
}

.num-symbol-stack {
    display: flex;
    flex-direction: column;
    gap: 11.54px;
    height: calc(146.15px * 3 + 11.54px * 2);
}

.num-key.symbol-mini {
    flex: 1;
    height: auto;
    font-size: 48px;
}

.num-key img {
    width: 60px;
    height: 60px;
}

/* Symbolic Keyboard Styles (Refined Alignment & PS Proportions) */
.symbolic-kb {
    display: flex;
    flex-direction: column;
    padding: 5.77px;
    /* Match 26-key layout margins */
    width: 100%;
    height: 750px;
    /* 774 (Target) - 24 (Outer Padding) = 750px */
    box-sizing: border-box;
    margin: 0;
}

.sym-outer {
    display: flex;
    flex-direction: row;
    gap: 11.54px;
    height: 100%;
    width: 100%;
}

/* Left Column: Adjusted for 12px padding */
.sym-col-left {
    width: 165.5px;
    display: flex;
    flex-direction: column;
    gap: 11.54px;
    height: 100%;
}

.sym-sidebar {
    flex: 1;
    /* Use flex to fill available space, matching grid panel */
    display: flex;
    flex-direction: column;
    gap: 0;
    /* No gap, items fill the space */
    border-radius: 25px !important;
    overflow: hidden !important;
    box-shadow: var(--key-shadow, 0 2px 0 rgba(0, 0, 0, 0.25));
    border: var(--key-border-width, 0) solid var(--key-border-color, transparent);
    box-sizing: border-box;
}

.sym-category-item {
    flex: 1;
    /* Equal height distribution like grid items */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.1s;
    position: relative;
}

.sym-category-item.active .cat-label {
    background-color: rgba(255, 255, 255, 0.3);
    padding: 10px 20px;
    border-radius: 18px;
}

/* Right Column: Calculated to fit remaining width of 1125 */
.sym-col-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 11.54px;
    height: 100%;
}

.sym-grid-panel {
    flex: 1;
    /* Use flex to fill available space, matching sidebar */
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 0;
    border-radius: 25px !important;
    overflow: hidden !important;
    box-shadow: var(--key-shadow, 0 2px 0 rgba(0, 0, 0, 0.25));
    border: var(--key-border-width, 0) solid var(--key-border-color, transparent);
    box-sizing: border-box;
}

.sym-grid-item {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.1s;
}

.sym-grid-item:active {
    background-color: var(--key-active-bg) !important;
    transform: scale(0.95);
    transition: background-color 0.05s, transform 0.05s;
}

.sym-bottom-bar {
    height: 138.4px;
    flex-shrink: 0;
    /* Prevent shrinking to match exit key height */
    display: flex;
    flex-direction: row;
    gap: 11.54px;
    width: 100%;
}

.sym-func-key {
    flex: 1;
    height: 100%;
    border-radius: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--key-shadow, 0 2px 0 rgba(0, 0, 0, 0.25));
    border: var(--key-border-width, 0) solid var(--key-border-color, transparent);
    box-sizing: border-box;
    cursor: pointer;
    transition: background-color 0.1s;
}

/* Override height for exit key */
.sym-func-key.key-exit {
    height: 138.4px;
    flex: none;
}

.key-exit {
    height: 138.4px !important;
    /* Force same height as bottom bar buttons */
    width: 100%;
    flex-shrink: 0;
    /* Prevent shrinking */
}

.sym-func-key:active {
    background-color: var(--key-active-bg) !important;
    box-shadow: var(--key-shadow-active, 0 1px 0 rgba(0, 0, 0, 0.25)) !important;
    transform: scale(0.98) translateY(1px);
    transition: background-color 0.05s, transform 0.05s, box-shadow 0.05s;
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column !important;
    }

    .settings-area {
        width: 100%;
        height: 60%;
        /* 手機版：確保底部安全區域 */
        padding-bottom: var(--safe-area-inset-bottom);
    }

    .preview-area {
        height: 40%;
        flex: none;
    }
    
    /* 手機版：頂部導航欄安全區域 */
    .top-bar {
        padding-left: max(16px, var(--safe-area-inset-left));
        padding-right: max(16px, var(--safe-area-inset-right));
    }
}

.segment-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    /* Gap for icon-label symmetry */
}

/* Cleaned up redundant handedness icon CSS as we now use inline SVGs */
.icon-handedness-svg {
    width: 20px;
    height: 20px;
    transition: fill 0.2s;
}

/* Card Override States */
.settings-card.disabled-card {
    filter: grayscale(80%);
    opacity: 0.6;
    /* NO pointer-events: none here — that also blocks the card-header toggle */
}

/* Block interactions only on the BODY of the card (everything except .card-header) */
.settings-card.disabled-card>*:not(.card-header) {
    pointer-events: none;
    user-select: none;
    cursor: not-allowed;
}

/* The card-header (which holds the enable toggle) stays fully interactive */
.settings-card.disabled-card .card-header {
    pointer-events: auto;
    cursor: default;
}

/* Specific button layout fix for card overrides */
.settings-card.disabled-card .btn-reset-small {
    display: none;
    /* Hide reset button when override is off to avoid confusion */
}

.override-active-badge {
    padding: 2px 8px;
    background: var(--accent-color);
    color: white;
    font-size: 10px;
    font-weight: 700;
    border-radius: 4px;
    margin-left: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(var(--accent-rgb), 0.3);
    white-space: nowrap;
}

.card-status-info {
    display: flex;
    align-items: center;
    margin-top: 4px;
    margin-bottom: 12px;
}


/* ===== 桌面縮放優化系列 ===== */

/* 中等螢幕：1080px - 769px 顏色選擇器和拉桿優化 */
@media (max-width: 1080px) and (min-width: 769px) {
    .opacity-slider-container {
        gap: 6px;
        min-width: 80px;
    }
    
    .opacity-slider-value {
        width: 35px !important;
        font-size: 12px;
    }
    
    .color-hex-input {
        width: 80px !important;
        font-size: 12px;
        padding: 4px 6px;
    }
    
    .color-row .input-label[style*="min-width: 120px"] {
        min-width: 100px !important;
        font-size: 14px;
    }
    
    .color-picker-trigger {
        width: 30px;
        height: 30px;
    }
    
    .color-row input[type="range"] {
        min-width: 80px;
        flex: 1 1 auto;
    }
}

/* 中等螢幕：1011px - 769px 工具配置和按鍵布局優化 */
@media (max-width: 1011px) and (min-width: 769px) {
    /* 工具配置：縮小工具卡片 */
    .toolbar-grid-container {
        padding: 12px !important;
    }
    
    .toolbar-slot-grid,
    .tool-cards-grid {
        gap: 8px !important;
    }
    
    .toolbar-slot-card,
    .tool-option-card {
        padding: 8px 6px !important;
    }
    
    .tool-card-label {
        font-size: 12px !important;
    }
    
    .tool-card-icon {
        font-size: 20px !important;
    }
    
    .slot-badge {
        width: 20px !important;
        height: 20px !important;
        font-size: 11px !important;
        top: -6px !important;
        left: -6px !important;
    }
    
    .slot-content {
        font-size: 10px !important;
    }
    
    /* 按鍵布局：縮小行卡片 */
    .advanced-row-grid {
        gap: 10px !important;
    }
    
    .row-card {
        padding: 12px 10px !important;
    }
    
    .row-card-title {
        font-size: 14px !important;
    }
    
    .row-card .input-label {
        font-size: 13px !important;
    }
}

/* 更窄螢幕：973px - 769px 顏色選擇器加強優化 */
@media (max-width: 973px) and (min-width: 769px) {
    .opacity-slider-container {
        gap: 4px !important;
        min-width: 60px !important;
    }
    
    .opacity-slider-value {
        width: 32px !important;
        font-size: 11px !important;
    }
    
    .color-hex-input {
        width: 75px !important;
        font-size: 11px !important;
        padding: 3px 5px !important;
    }
    
    .color-row .input-label[style*="min-width: 120px"] {
        min-width: 90px !important;
        font-size: 13px !important;
    }
    
    .color-picker-trigger {
        width: 28px !important;
        height: 28px !important;
    }
    
    .color-row input[type="range"] {
        min-width: 60px !important;
        flex: 1 1 auto !important;
    }
    
    .input-row {
        gap: 6px !important;
        padding: 8px !important;
    }
    
    .size-icon-trigger {
        width: 28px !important;
        height: 28px !important;
    }
    
    .size-icon-trigger svg {
        width: 26px !important;
        height: 26px !important;
    }
    
    .size-spacer {
        width: 75px !important;
    }
}

/* ===== 桌面縮放優化：880px - 769px ===== */
@media (max-width: 880px) and (min-width: 769px) {
    /* 工具配置容器 */
    .toolbar-grid-container {
        padding: 8px !important;
    }
    
    /* 選中工具：改為 4 列以提供更多空間 */
    .toolbar-slot-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px !important;
    }
    
    /* 常用功能：保持 5 列 */
    .tool-cards-grid {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 6px !important;
    }
    
    /* 選中工具卡片 */
    .toolbar-slot-card {
        padding: 6px 4px !important;
        min-width: 0 !important;
    }
    
    /* 常用功能卡片 */
    .tool-option-card {
        padding: 5px 3px !important;
        min-width: 0 !important;
    }
    
    /* Badge 樣式 */
    .slot-badge {
        width: 18px !important;
        height: 18px !important;
        font-size: 10px !important;
        top: -5px !important;
        left: -5px !important;
    }
    
    /* 選中工具的文字內容 */
    .toolbar-slot-card .slot-content {
        font-size: 11px !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 100% !important;
        width: 100% !important;
        padding: 0 3px !important;
        box-sizing: border-box !important;
    }
    
    /* 常用功能的文字標籤 */
    .tool-card-label {
        font-size: 9px !important;
        line-height: 1.1 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        max-width: 100% !important;
    }
    
    /* 圖標大小 */
    .tool-card-icon {
        font-size: 16px !important;
    }
}

/* 極窄螢幕：841px - 769px 最激進優化 */
@media (max-width: 841px) and (min-width: 769px) {
    .opacity-slider-container {
        gap: 3px !important;
        min-width: 50px !important;
    }
    
    .opacity-slider-value {
        width: 30px !important;
        font-size: 10px !important;
    }
    
    .color-hex-input {
        width: 70px !important;
        font-size: 10px !important;
        padding: 3px 4px !important;
    }
    
    .color-row .input-label[style*="min-width: 120px"] {
        min-width: 85px !important;
        font-size: 12px !important;
    }
    
    .color-picker-trigger {
        width: 26px !important;
        height: 26px !important;
    }
    
    .color-row input[type="range"] {
        min-width: 50px !important;
    }
    
    .input-row {
        gap: 5px !important;
        padding: 6px !important;
    }
    
    .size-icon-trigger {
        width: 26px !important;
        height: 26px !important;
    }
    
    .size-icon-trigger svg {
        width: 24px !important;
        height: 24px !important;
    }
    
    .size-spacer {
        width: 70px !important;
    }
    
    /* 按鍵布局：進一步縮小 */
    .advanced-row-grid {
        gap: 8px !important;
    }
    
    .row-card {
        padding: 10px 8px !important;
    }
    
    .row-card-title {
        font-size: 13px !important;
    }
    
    .row-card .input-label {
        font-size: 12px !important;
    }
}

/* 超窄螢幕：806px - 769px 拉桿最終優化 */
@media (max-width: 806px) and (min-width: 769px) {
    .opacity-slider-container {
        gap: 2px !important;
        min-width: 40px !important;
    }
    
    .opacity-slider-value {
        width: 28px !important;
        font-size: 9px !important;
    }
    
    .color-hex-input {
        width: 65px !important;
        font-size: 9px !important;
        padding: 2px 3px !important;
    }
    
    .color-row .input-label[style*="min-width: 120px"] {
        min-width: 80px !important;
        font-size: 11px !important;
    }
    
    .color-picker-trigger {
        width: 24px !important;
        height: 24px !important;
    }
    
    .color-row input[type="range"] {
        min-width: 40px !important;
    }
    
    .input-row {
        gap: 4px !important;
        padding: 5px !important;
    }
    
    .size-icon-trigger {
        width: 24px !important;
        height: 24px !important;
    }
    
    .size-icon-trigger svg {
        width: 22px !important;
        height: 22px !important;
    }
    
    .size-spacer {
        width: 65px !important;
    }
}

/* ===== 手機版 RWD 優化 ===== */
@media (max-width: 767px) {
    /* 減少設置區域的 padding */
    .settings-scroll {
        padding: 8px !important;
        gap: 10px;
    }
    
    /* 減少卡片的 padding */
    .settings-card {
        padding: 12px;
        gap: 12px;
    }
    
    /* 手機版：隱藏百分比符號，只顯示數字 */
    .opacity-slider-value {
        font-size: 11px;
    }
    
    .percent-symbol {
        display: none;
    }
}

/* 極小手機：進一步優化 */
@media (max-width: 480px) {
    .settings-scroll {
        padding: 6px !important;
        gap: 8px;
    }
    
    .settings-card {
        padding: 10px;
        gap: 10px;
    }
}


/* Font Size Sync Card Styles */
.font-sync-card {
    background: #f8f9fa;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.3s ease;
}

.font-sync-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.font-sync-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.font-sync-title {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 6px;
}

.font-sync-description {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

.font-sync-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* 手機/小屏模式：開關移到右上角 */
@media (max-width: 767px) {
    .font-sync-header {
        display: block !important;
        position: relative !important;
        min-height: 50px !important;
    }
    
    .font-sync-toggle {
        position: absolute !important;
        top: 0 !important;
        right: 0 !important;
        left: auto !important; /* 確保不會被 left 屬性影響 */
        z-index: 10 !important;
        margin: 0 !important;
        gap: 0 !important; /* 移除 gap */
        display: block !important; /* 改為 block 而不是 flex */
    }
    
    .font-sync-toggle .switch {
        float: right !important; /* 確保開關靠右 */
    }
    
    .font-sync-info {
        width: 100% !important;
        padding-right: 80px !important;
    }
    
    .font-sync-title {
        margin-bottom: 4px !important;
    }
}

/* Manual Sync Actions */
.font-sync-actions {
    display: flex;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.btn-sync {
    flex: 1;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #4a90e2;
    background: white;
    border: 1px solid #4a90e2;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.btn-sync:hover {
    background: #4a90e2;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
}

.btn-sync:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(74, 144, 226, 0.3);
}

/* Dark mode styles */
.appearance-dark .font-sync-card {
    background: #2c2c2e;
    border-color: rgba(255, 255, 255, 0.1);
}

.appearance-dark .font-sync-title {
    color: #fff;
}

.appearance-dark .font-sync-description {
    color: #aaa;
}

.appearance-dark .font-sync-actions {
    border-top-color: rgba(255, 255, 255, 0.1);
}

.appearance-dark .btn-sync {
    background: #3a3a3c;
    border-color: #4a90e2;
    color: #4a90e2;
}

.appearance-dark .btn-sync:hover {
    background: #4a90e2;
    color: white;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .font-sync-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .font-sync-toggle {
        width: 100%;
        justify-content: space-between;
    }
}


/* ===== Export Success Modal Styles ===== */
.export-success-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.export-success-modal {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(60px) saturate(180%);
    -webkit-backdrop-filter: blur(60px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 28px;
    padding: 20px;
    width: 90%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 
                0 0 0 1px rgba(255, 255, 255, 0.5) inset;
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.appearance-dark .export-success-modal {
    background: rgba(44, 44, 46, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 
                0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.export-success-title {
    font-size: 17px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 10px;
    color: #1c1c1e;
}

.appearance-dark .export-success-title {
    color: #ffffff;
}

.export-success-message {
    font-size: 14px;
    text-align: center;
    margin-bottom: 20px;
    color: #3c3c43;
    line-height: 1.5;
}

.appearance-dark .export-success-message {
    color: #ebebf5;
}

.export-success-message .highlight-red {
    color: #FF3B30;
    font-weight: 600;
}

.export-success-text .highlight-red {
    color: #FF3B30;
    font-weight: 600;
}

.export-success-items {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: transparent;
    border-radius: 24px;
    overflow: hidden;
    margin: 0 24px;
}

.appearance-dark .export-success-items {
    background: transparent;
}

.export-success-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    cursor: default;
    transition: background 0.2s;
}

.export-success-item:first-child {
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
}

.export-success-item:last-child {
    border-bottom-left-radius: 24px;
    border-bottom-right-radius: 24px;
    border-bottom: none;
}

.appearance-dark .export-success-item {
    background: rgba(58, 58, 60, 0.6);
}

.export-success-item:hover {
    background: rgba(255, 255, 255, 0.8);
}

.appearance-dark .export-success-item:hover {
    background: rgba(58, 58, 60, 0.8);
}

.export-success-item.delete-item {
    color: #FF3B30;
}

.export-success-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.export-success-icon svg {
    width: 100%;
    height: 100%;
}

.export-success-icon.blue {
    color: #007AFF;
}

.export-success-icon.red {
    color: #FF3B30;
}

.export-success-text {
    flex: 1;
    font-size: 15px;
    font-weight: 500;
    color: #1c1c1e;
}

.appearance-dark .export-success-text {
    color: #ffffff;
}

.export-success-item.delete-item .export-success-text {
    color: #FF3B30;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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