:root {
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    
    /* 暖色調主題 - 與牛仔褲課程一致 */
    --primary-brown: #8B4513;
    --secondary-brown: #DEB887;
    --light-brown: #F4A460;
    --cream-bg: #FFF5EE;
    --warm-white: #FFF8DC;
    
    /* 毛玻璃效果 */
    --glass-bg: rgba(255, 245, 238, 0.85);
    --glass-border: rgba(222, 184, 135, 0.3);
    --card-bg: rgba(255, 255, 255, 0.95);
    
    /* 漸層背景 */
    --warm-gradient: linear-gradient(135deg, #FFF5EE 0%, #F5F5DC 50%, #FFF8DC 100%);
    --brown-gradient: linear-gradient(135deg, #DEB887 0%, #F4A460 100%);
    
    /* 陰影 */
    --shadow-light: 0 4px 6px rgba(139, 69, 19, 0.1);
    --shadow-medium: 0 10px 25px rgba(139, 69, 19, 0.15);
    --shadow-heavy: 0 20px 40px rgba(139, 69, 19, 0.2);
    
    /* 圓角 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

/* 基本重置與全域設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: "Microsoft JhengHei", -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--glass-bg);
    background-attachment: fixed;
    height: 100vh;
    height: calc(100vh - var(--safe-area-top) - var(--safe-area-bottom));
    color: var(--primary-brown);
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    width: 100%;
    min-height: 100vh;
    padding-top: var(--safe-area-top);
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
}

.platform-header {
    text-align: center;
    padding: 1.5rem;
    flex-shrink: 0;
    margin-bottom: 2rem;
    background: transparent;
    margin: 0.5rem 0.5rem 1rem 0.5rem;
}

.header-image {
    margin-bottom: 1rem;
}

.platform-logo {
    max-height: 100px;
    width: 100%;
    height: auto;
    filter: drop-shadow(var(--shadow-light));
    transition: transform 0.3s ease;
    object-fit: contain;
}

.platform-logo:hover {
    transform: scale(1.05);
}

.platform-header h1 {
    font-family: 'Noto Serif TC', '標楷體', 'DFKai-SB', serif;
    font-size: 2em;
    font-weight: 700;
    color: var(--primary-brown);
    text-shadow: 1px 1px 2px rgba(139, 69, 19, 0.1);
    margin-bottom: 0.5rem;
}

.platform-subtitle {
    font-size: 0.9em;
    color: var(--secondary-brown);
    letter-spacing: 1px;
    font-weight: 500;
    opacity: 0.8;
}


.platform-subtitle {
    font-size: 0.7em;
    color: rgba(255,255,255,0.8);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: 0.3rem;
}

.content-area {
    position: relative;
    flex-grow: 1;
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 400px;
    background: transparent;
    padding: 1rem;
    margin: 0 0.5rem 0.5rem 0.5rem;
}

.books-view {
    height: 100%;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    max-width: 100%;
    margin: 0 auto;
    align-content: start;
    row-gap: 1rem;
    transition: transform 0.3s ease;
	padding: 0;
}

.books-view.shifted {
    transform: translateX(-100%);
}

.book-item {
    position: relative;
    width: 100%;
    max-width: 160px; /* 從 140px 改成 160px，讓書本稍微大一點 */
    margin: 0 auto;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.book-cover {
    width: 100%;
    padding-bottom: 130%;
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 0.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.book-cover:hover {
    transform: translateY(-2px);
}

.book-cover img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.book-title {
    font-size: 1em;
    font-weight: 600;
    text-align: center;
    width: 100%;
}

.book-item:active {
    transform: scale(0.95);
}

.lessons-panel.active {
    transform: translateX(-100%);
}

.lessons-panel {
    position: absolute;
    top: 0;
    right: -100%;
    width: 100%;
    height: 100%;
    background: var(--warm-gradient);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: 1rem;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(222, 184, 135, 0.3);
    background: transparent;
}

.back-btn {
    padding: 0.8rem;
    margin-right: 0.8rem;
    font-size: 1.4em;
    background: none;
    border: none;
    color: #2D3748;
    cursor: pointer;
    transition: color 0.3s ease;
}

.panel-header h2 {
    font-size: 1.3em;
    font-weight: 800;
    color: #2D3748;
}

.lessons-scroll {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0 1.5rem 1rem 1.5rem;
}

.lessons-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.lesson-item,
.review-item {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0;
    font-size: 1em;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    border-bottom: 1px solid rgba(222, 184, 135, 0.3);
}

.lesson-item {
    background: transparent;
    color: #2D3748;
}

.lesson-item:not(.locked):hover {
    background: rgba(222, 184, 135, 0.1);
}

.lesson-item.locked {
    background: rgba(0, 0, 0, 0.05);
    color: #666;
}

.review-item {
    justify-content: center;
}


.lesson-title {
    flex-grow: 1;
    text-align: left;
    font-weight: 500;
    letter-spacing: 0.3px;
    color: inherit;
}

.review-container {
    display: flex;
    justify-content: flex-end;
    padding: 0.5rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    margin-top: 0.8rem;
    width: 100%;
}

.lesson-item:hover,
.review-item:hover {
    transform: translateX(5px);
    filter: brightness(1.1);
}

/* 鎖定狀態樣式 */
.book-item.locked {
    opacity: 0.7;
    cursor: not-allowed;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.book-item.locked .book-cover {
    filter: grayscale(100%);
    transition: all 0.3s ease;
}

.book-item.locked:hover {
    transform: translateY(-2px);
}

.book-item.locked:hover::after {
    content: "尚未開放";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px;
    font-size: 0.9em;
    text-align: center;
    animation: slideUp 0.3s ease;
}

.lock-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2em;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(0, 0, 0, 0.5);
    padding: 15px;
    border-radius: 50%;
    animation: pulse 2s infinite;
    z-index: 2;
}

.lesson-item.locked {
    opacity: 0.7;
    cursor: not-allowed;
    position: relative;
    overflow: hidden;
    background: rgba(128, 128, 128, 0.3) !important;
    transition: all 0.3s ease;
}

.lesson-item.locked:hover {
    transform: translateX(0) !important;
    background: rgba(128, 128, 128, 0.4) !important;
}

.lesson-item.locked:hover::after {
    content: "課程尚未開放";
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 0 15px 0 15px;
    font-size: 0.8em;
    animation: fadeIn 0.3s ease;
}

.lesson-item:not(.locked) {
    position: relative;
    overflow: hidden;
}

.lesson-item:not(.locked)::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    animation: shine 2s infinite;
}

/* 動畫效果 */
@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes shine {
    0% {
        left: -100%;
    }
    20% {
        left: 100%;
    }
    100% {
        left: 100%;
    }
}

.book-item:not(.locked):hover {
    transform: translateY(-5px);
}

.lesson-item:not(.locked):hover {
    transform: translateX(10px) !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* 響應式設計 */
@media (max-width: 360px) {
    .platform-header {
        padding: 0.3rem;
    }
    
    .books-view {
        gap: 0.3rem;
        row-gap: 0.8rem;
    }
    
    .book-item {
        max-width: 120px;
    }

    .app-container {
        padding: 0.5rem;
    }

    .content-area {
        padding: 0.5rem;
    }
    
    .lesson-item,
    .review-item {
        padding: 0.8rem;
    }
    
    .lesson-badge {
        width: 24px;
        height: 24px;
        font-size: 0.8em;
    }

.platform-logo {
    max-height: 80px;
    width: 100%;
}

.platform-header {
    margin: 0.25rem 0.25rem 0.75rem 0.25rem;
}
}

@media (min-width: 768px) {
    .books-view {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .platform-header h1 {
        font-size: 1.8em;
    }
    
    .books-view {
        gap: 0.3rem;
        row-gap: 0.8rem;
    }
    
    .book-container {
        padding: 0.8rem;
    }
    
    .lock-icon {
        width: 32px;
        height: 32px;
    }

    .book-title {
        font-size: 1rem;
    }
}

@media (max-width: 314px) {
    .platform-header h1 {
        font-size: 1.5em;
    }

    .books-view {
        gap: 0.3rem;
        row-gap: 0.8rem;
    }
    
    .book-container {
        padding: 0.5rem;
    }
    
    .book-title {
        font-size: 0.9rem;
        margin-top: 0.8rem;
    }
}

/* 無障礙設計 */
@media (prefers-reduced-motion: reduce) {
    .book-item,
    .lesson-item,
    .lessons-panel,
    .books-view {
        transition: none;
    }
    
    .lock-icon {
        animation: none;
    }
    
    .lesson-item:not(.locked)::before {
        animation: none;
    }
}

/* 客服圖示 */
.customer-service{
    width: 50px;
    height: 50px;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.3s ease;
    flex-shrink: 0;
    box-shadow:
      0 0 12px rgba(255,255,255,.4),
      0 0 24px rgba(78,198,202,.3),
      0 0 36px rgba(67,56,159,.2);
    animation: glow-pulse 2s ease-in-out infinite alternate;
  }
  .customer-service:hover{
    transform: scale(1.1);
    box-shadow:
      0 0 18px rgba(255,255,255,.6),
      0 0 36px rgba(78,198,202,.5),
      0 0 54px rgba(67,56,159,.4);
  }
  .customer-service img{
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
  }
  
  /* 行動版放大與右側安全邊距 */
  .header-content .customer-service{
    width: clamp(56px, 12vw, 64px) !important;
    height: clamp(56px, 12vw, 64px) !important;
    margin-right: calc(env(safe-area-inset-right, 0px) + 16px);
    padding: 4px;
  }
  
  /* 光暈動畫 */
  @keyframes glow-pulse{
    0%{
      box-shadow:
        0 0 10px rgba(255,255,255,.3),
        0 0 20px rgba(78,198,202,.2),
        0 0 30px rgba(67,56,159,.1);
    }
    100%{
      box-shadow:
        0 0 14px rgba(255,255,255,.5),
        0 0 28px rgba(78,198,202,.4),
        0 0 42px rgba(67,56,159,.3);
    }
  }

  /* 頁尾區塊 */
.site-footer{
    background: rgba(0,0,0,.4);
    color:#fff;
    padding: 12px 16px;
    text-align:center;
    font-size: .9em;
  }
  
  /* 頁尾內的「版權聲明」按鈕 */
  .site-footer .footer-link{
    margin-left: 8px;
    background: transparent;
    border: 0;
    color: #fff;
    text-decoration: underline;
    cursor: pointer;
    font: inherit;
  }
  
  /* 從頁尾往上滑出的面板 */
  .copyright-panel{
    position: fixed;
    left: 0;
    right: 0;
    bottom: -100%;
    background: #fff;
    color: #333;
    box-shadow: 0 -4px 20px rgba(0,0,0,.25);
    transition: bottom .35s ease-out;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    z-index: 999;
    max-height: 80vh;
    overflow-y: auto;
  }
  .copyright-panel.active{ bottom: 0; }
  
  .copyright-panel .panel-content{
    padding: 20px;
    max-width: 800px;
    margin: auto;
    line-height: 1.7;
  }
  .copyright-panel h3{ margin-top: 0; }
  
  .copyright-panel .close-btn{
    position: absolute;
    right: 16px;
    top: 10px;
    border: 0;
    background: transparent;
    font-size: 26px;
    cursor: pointer;
    color: #333;
  }
  
  /* 讓 footer 穩定貼底並避開底部安全區（可選） */
  .site-footer{
    margin-top: auto;
    position: relative;
    z-index: 2;
    padding-bottom: calc(12px + var(--safe-area-inset-bottom, 0px));
  }

  /* 客服圖示容器樣式 */
.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    flex-wrap: nowrap;
}

/* 主要 Logo 樣式 */
.main-logo {
    max-width: 380px;
    width: 100%;
    height: auto;
    display: block;
    flex-shrink: 0;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.3));
}

/* 客服圖示樣式 */
.customer-service {
    width: 50px;
    height: 50px;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.3s ease;
    flex-shrink: 0;
    box-shadow: 
        0 0 12px rgba(255, 255, 255, 0.4),
        0 0 24px rgba(78, 198, 202, 0.3),
        0 0 36px rgba(67, 56, 159, 0.2);
    animation: glow-pulse 2s ease-in-out infinite alternate;
}

.customer-service:hover {
    transform: scale(1.1);
    box-shadow: 
        0 0 18px rgba(255, 255, 255, 0.6),
        0 0 36px rgba(78, 198, 202, 0.5),
        0 0 54px rgba(67, 56, 159, 0.4);
}

.customer-service img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

/* 原有 Logo 樣式（備用） */
.platform-header img:not(.customer-service img) {
    max-width: 380px;
    width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.3));
}

@keyframes glow {
    0% {
        filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.5));
    }
    50% {
        filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.8));
    }
    100% {
        filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.5));
    }
}

/* 客服圖示光暈動畫 */
@keyframes glow-pulse {
    0% {
        box-shadow: 
            0 0 10px rgba(255, 255, 255, 0.3),
            0 0 20px rgba(78, 198, 202, 0.2),
            0 0 30px rgba(67, 56, 159, 0.1);
    }
    100% {
        box-shadow: 
            0 0 14px rgba(255, 255, 255, 0.5),
            0 0 28px rgba(78, 198, 202, 0.4),
            0 0 42px rgba(67, 56, 159, 0.3);
    }
}

