/* 基本樣式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8f9fa;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body > header {
    flex-shrink: 0;
    width: 100%;
}

body > main {
    flex: 1 0 auto;
    width: 100%;
}

body > footer {
    flex-shrink: 0;
    width: 100%;
}

body.modal-open {
    overflow: hidden;
}

/* ========== 首頁作者橫向滑動 ========== */
.home-authors {
    max-width: 1200px;
    margin: 1rem auto 0;
    padding: 1rem;
}

.author-carousel {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.author-carousel.dragging {
    cursor: grabbing;
    user-select: none;
}

/* 隱藏 scrollbar（仍可滑動） */
.author-carousel::-webkit-scrollbar {
    height: 8px;
}
.author-carousel::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.45);
    border-radius: 999px;
}
.author-carousel::-webkit-scrollbar-track {
    background: transparent;
}

.author-card {
    flex: 0 0 360px;
    scroll-snap-align: start;
    display: flex;
    gap: 0.9rem;
    padding: 1rem;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.author-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(0,0,0,0.10);
    border-color: #d1d5db;
}

.author-card-avatar {
    width: 72px;
    height: 72px;
    border-radius: 14px;
    object-fit: cover;
    border: 1px solid #eef2f7;
    background: #f1f5f9;
}

.author-card-avatar.placeholder {
    background: linear-gradient(135deg, #e2e8f0, #f8fafc);
}

.author-card-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    font-weight: 800;
    color: #111827;
}

.author-card-title .name {
    font-size: 1.1rem;
}

.author-card-bio {
    margin-top: 0.35rem;
    color: #4b5563;
    font-size: 0.95rem;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
}

.author-card-cta {
    margin-top: 0.6rem;
    color: #2563eb;
    font-weight: 700;
}

@media (max-width: 768px) {
    .author-card {
        flex-basis: 82%;
    }
}

/* 標題樣式 */
h1, h2, h3, h4, h5, h6 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

/* 連結樣式 */
a {
    color: #3498db;
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: #2980b9;
}

/* 按鈕樣式 */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    margin: 0.25rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
    color: white;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
    color: white;
}

.btn-warning {
    background-color: #f39c12;
    color: white;
}

.btn-warning:hover {
    background-color: #e67e22;
    color: white;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
    color: white;
}

/* 導航列 */
header {
    background-color: #2c3e50;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    z-index: 100;
}

/* ========== 作者專頁 ========== */
.author-hero {
    max-width: 1200px;
    margin: 1.5rem auto 0;
    padding: 1rem;
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 1rem;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.06);
}

.author-avatar {
    width: 96px;
    height: 96px;
    border-radius: 16px;
    object-fit: cover;
    border: 1px solid #eef2f7;
    background: #f1f5f9;
}
.author-avatar.placeholder {
    width: 96px;
    height: 96px;
    border-radius: 16px;
    background: linear-gradient(135deg, #e2e8f0, #f8fafc);
    border: 1px solid #eef2f7;
}

.author-name {
    margin-bottom: 0.25rem;
}
.author-desc {
    color: #64748b;
    margin: 0;
}

.author-social-links {
    display: flex;
    gap: 1rem;
    margin-top: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.author-social-links .social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #f1f5f9;
    color: #64748b;
    transition: all 0.2s ease;
    text-decoration: none;
}

.author-social-links .social-link:hover {
    background-color: #e2e8f0;
    color: #475569;
    transform: translateY(-2px);
}

.author-social-links .social-link svg {
    width: 20px;
    height: 20px;
}

.author-plans,
.author-articles {
    max-width: 1200px;
    margin: 1rem auto 0;
    padding: 1rem;
}

/* ========== 首頁作者卡片 ========== */
.home-authors {
    max-width: 1200px;
    margin: 1rem auto 0;
    padding: 1rem;
}

.author-card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.author-card {
    display: flex;
    gap: 0.9rem;
    padding: 1rem;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.author-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(0,0,0,0.10);
    border-color: #d1d5db;
}

.author-card-avatar {
    width: 72px;
    height: 72px;
    border-radius: 14px;
    object-fit: cover;
    border: 1px solid #eef2f7;
    background: #f1f5f9;
}

.author-card-avatar.placeholder {
    width: 72px;
    height: 72px;
    border-radius: 14px;
    background: linear-gradient(135deg, #e2e8f0, #f8fafc);
    border: 1px solid #eef2f7;
}

.author-card-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    font-weight: 800;
    color: #111827;
}

.author-card-title .name {
    font-size: 1.1rem;
}

.author-card-bio {
    margin-top: 0.35rem;
    color: #4b5563;
    font-size: 0.95rem;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
}

.author-card-cta {
    margin-top: 0.6rem;
    color: #2563eb;
    font-weight: 700;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.section-head h3 {
    margin: 0;
    white-space: nowrap;
    font-size: 1.5rem;
    font-weight: 700;
    color: #2c3e50;
}

.section-head .muted {
    margin: 0;
    flex: 1;
    text-align: right;
}

.muted {
    color: #6b7280;
}

.plan-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.plan-card {
    text-align: left;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1rem;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.plan-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(0,0,0,0.10);
    border-color: #d1d5db;
}

.plan-name {
    font-weight: 700;
    color: #111827;
}

.plan-price {
    margin-top: 0.75rem;
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    color: #111827;
}
.plan-price .amount {
    font-size: 1.6rem;
    font-weight: 800;
}
.plan-price .per,
.plan-price .currency {
    color: #6b7280;
    font-size: 0.9rem;
}

.plan-desc {
    margin-top: 0.65rem;
    color: #4b5563;
    font-size: 0.95rem;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3; /* 顯示 3 行，多的以 ... 截斷 */
    overflow: hidden;
}

.plan-cta {
    margin-top: 0.75rem;
    display: inline-block;
    color: #2563eb;
    font-weight: 600;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    width: min(560px, 100%);
    background: #fff;
    border-radius: 14px;
    padding: 1.25rem;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
    position: relative;
}

.modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    border: none;
    background: transparent;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    color: #64748b;
}

.modal-close:hover {
    color: #111827;
}

.modal-price {
    margin: 0.5rem 0 0.75rem;
    font-weight: 700;
    color: #111827;
}

.modal-desc {
    color: #374151;
    white-space: pre-wrap;
}

.modal-actions {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

@media (max-width: 900px) {
    .plan-grid {
        grid-template-columns: 1fr;
    }
    .author-hero {
        grid-template-columns: 96px 1fr;
    }
    .author-card-grid {
        grid-template-columns: 1fr;
    }
}

nav {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 漢堡選單按鈕 */
.hamburger-menu {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 101;
}

.hamburger-menu span {
    width: 100%;
    height: 3px;
    background-color: white;
    border-radius: 3px;
    transition: all 0.3s ease;
    transform-origin: center;
}

.hamburger-menu.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.hamburger-menu.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active span:nth-child(3) {
    transform: rotate(-45deg) translate(8px, -8px);
}

/* 桌面版顯示，手機版隱藏 */
.desktop-only {
    display: flex;
}

/* 側邊欄覆蓋層 */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* 側邊欄選單 */
.sidebar-menu {
    position: fixed;
    top: 0;
    left: -300px;
    width: 280px;
    height: 100vh;
    background-color: #2c3e50;
    color: white;
    z-index: 999;
    transition: left 0.3s ease;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
}

.sidebar-menu.active {
    left: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid #3a4a5a;
    background-color: #243444;
}

.sidebar-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.sidebar-close:hover {
    color: #ecf0f1;
}

.sidebar-logo {
    color: #ecf0f1;
    font-weight: 700;
    font-size: 1.2rem;
    text-decoration: none;
}

.sidebar-content {
    padding: 1rem 0;
}

/* 用戶資訊區塊 */
.sidebar-user-info {
    padding: 1rem;
    border-bottom: 1px solid #3a4a5a;
    margin-bottom: 1rem;
}

.sidebar-user-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #ecf0f1;
    transition: opacity 0.2s ease;
}

.sidebar-user-link:hover {
    opacity: 0.9;
}

.sidebar-user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background-color: #34495e;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-user-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-user-avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #95a5a6;
}

.sidebar-user-details {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #ecf0f1;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-email {
    font-size: 0.8rem;
    color: #95a5a6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-arrow {
    flex-shrink: 0;
    color: #95a5a6;
    display: flex;
    align-items: center;
}

/* 登入/註冊按鈕區塊 */
.sidebar-login-section {
    padding: 1rem;
    border-bottom: 1px solid #3a4a5a;
    margin-bottom: 1rem;
}

.sidebar-login-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #ecf0f1;
    transition: opacity 0.2s ease;
    padding: 0.5rem 0;
}

.sidebar-login-link:hover {
    opacity: 0.9;
}

.sidebar-login-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background-color: #34495e;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #95a5a6;
}

.sidebar-login-text {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 600;
    color: #ecf0f1;
    white-space: nowrap;
}

.sidebar-login-arrow {
    flex-shrink: 0;
    color: #95a5a6;
    display: flex;
    align-items: center;
}

.sidebar-section {
    margin-bottom: 1.5rem;
}

.sidebar-section-first {
    margin-bottom: 1rem;
    border-bottom: 1px solid #3a4a5a;
    padding-bottom: 1rem;
}

.sidebar-section-title {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #95a5a6;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-nav-list,
.sidebar-author-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav-list li,
.sidebar-author-list li {
    margin: 0;
}

.sidebar-link {
    display: block;
    padding: 0.75rem 1rem;
    color: #ecf0f1;
    text-decoration: none;
}

.sidebar-link-home {
    font-weight: 600;
    font-size: 1.05rem;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    margin: 0 0.5rem;
    transition: background-color 0.2s ease, color 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar-link-home:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar-link-home.active {
    background-color: rgba(52, 152, 219, 0.2);
    border-left-color: #3498db;
    color: #3498db;
}

.sidebar-link:hover {
    background-color: #34495e;
    color: white;
}

.sidebar-link.active {
    background-color: #3498db;
    color: white;
    border-left-color: #2980b9;
}

/* 側邊欄滾動條樣式 */
.sidebar-menu::-webkit-scrollbar {
    width: 6px;
}

.sidebar-menu::-webkit-scrollbar-track {
    background: #243444;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background: #5a6c7d;
    border-radius: 3px;
}

.sidebar-menu::-webkit-scrollbar-thumb:hover {
    background: #6a7c8d;
}

nav h1 {
    color: white;
    margin: 0;
}

.logo {
    color: #ecf0f1;
    font-weight: 700;
    font-size: 1.4rem;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 2rem;
}

/* 作者 Hover 下拉選單 */
.author-menu {
    position: relative;
}

/* 建立一個無形的 hover 橋，避免按鈕與選單之間有空隙導致收起 */
.author-menu::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 6px; /* 橋接距離，可視需要調整 */
}


/* 讓「全部作者」的按鈕視覺與右側導覽連結一致 */
.author-toggle {
    background: transparent;
    color: #ffffff;
    border: none;
    border-radius: 0;
    padding: 0 4px;
    height: auto;
    line-height: normal;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
}

.author-toggle:hover { color: #ecf0f1; }
.author-toggle:focus { outline: none; }

/* 在文字右側加一個下拉箭頭，風格輕量不突兀 */
.author-toggle::after {
    content: none; /* 不顯示三角形 */
}

.author-menu:hover .author-toggle,
.author-menu:focus-within .author-toggle { color: #ecf0f1; }

.author-list {
    position: absolute;
    top: calc(100% + 2px); /* 緊貼按鈕下方，避免 hover 中斷 */
    left: 0;
    min-width: 180px;
    background: #243444;
    border: 1px solid #3a4a5a;
    border-radius: 8px;
    padding: 6px 0;
    display: none;
    z-index: 20;
}

.author-list li { list-style: none; }

.author-list a {
    display: block;
    padding: 8px 12px;
    color: #ecf0f1;
}

.author-list a:hover { background: #2f4255; }

/* 用 hover 與鍵盤 focus 展開 */
.author-menu:hover .author-list,
.author-menu:focus-within .author-list {
    display: block;
}

nav ul {
    list-style: none;
    display: flex;
    gap: 2rem;
}

nav a {
    color: white;
    font-weight: 500;
}

nav a:hover {
    color: #ecf0f1;
}

/* 導覽列作者下拉樣式微調 */
.nav-filter {
    position: relative;
}

/* 美化 select：深色、圓角、隱藏原生箭頭、加上自製箭頭 */
.author-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: #243444;
    color: #ecf0f1;
    border: 1px solid #3a4a5a;
    border-radius: 999px;
    padding: 6px 36px 6px 12px;
    height: 34px;
    line-height: 20px;
    font-size: 0.9rem;
    transition: border-color .2s ease, background-color .2s ease;
}

.author-select:hover {
    border-color: #58708a;
}

.author-select:focus {
    outline: none;
    border-color: #7cb1ff;
    box-shadow: 0 0 0 2px rgba(124,177,255,.25);
}

/* 自製箭頭 */
.nav-filter::after {
    content: "";
    position: absolute;
    right: 12px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 2px solid #cfd8e3;
    border-bottom: 2px solid #cfd8e3;
    transform: translateY(-50%) rotate(45deg);
    pointer-events: none;
}

/* 主要內容 */
main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* 英雄區域 */
.hero {
    text-align: center;
    padding: 3rem 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.hero h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: white;
}

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

/* 文章列表 */
.article-list {
    display: grid;
    gap: 1.5rem;
    margin-top: 2rem;
}

.article-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.article-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.article-card h3,
.article-card h4 {
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.article-card h3 a,
.article-card h4 a {
    color: #2c3e50;
}

.article-card h3 a:hover,
.article-card h4 a:hover {
    color: #3498db;
}

/* 置頂文章釘子圖示 */
.pinned-icon {
    display: inline-block;
    font-size: 1.2em;
    line-height: 1;
    margin-right: 0.25rem;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
    animation: none;
}

/* 文章詳情頁面的置頂圖示 */
.article-detail header h1 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.article-detail header h1 .pinned-icon {
    font-size: 1.5em;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.author {
    color: #7f8c8d;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.date {
    color: #95a5a6;
    font-size: 0.8rem;
    margin-bottom: 1rem;
}

.content-preview {
    color: #555;
    margin-bottom: 1rem;
    line-height: 1.5;
    white-space: pre-line; /* 保留換行符但合併多餘空格 */
    overflow: hidden;
    word-wrap: break-word; /* 長單詞自動換行 */
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3; /* 限制顯示3行 */
    -webkit-box-orient: vertical;
    max-width: 100%; /* 確保不超出容器 */
}

/* 文章預覽中的表格處理 */
.content-preview table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    overflow: hidden;
    font-size: 0.7rem; /* 進一步縮小字體 */
    max-width: 100%;
}

.content-preview th,
.content-preview td {
    border: 1px solid #ddd;
    padding: 0.2rem;
    text-align: left;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    max-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 首頁文章預覽容器限制 */
.content-preview {
    max-width: 100%;
    overflow: hidden;
    position: relative;
    word-wrap: break-word;
}

/* 所有文章頁面的容器限制 */
.article-card {
    max-width: 100%;
    overflow: hidden;
    position: relative;
    word-wrap: break-word;
}

/* 首頁預覽中的圖片處理 - 強制限制大小但不置中 */
.content-preview img {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    max-height: 120px !important;
    object-fit: cover !important;
    display: block !important;
    margin: 1rem 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

/* 所有文章頁面的圖片處理 - 強制限制大小但不置中 */
.article-card img {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    max-height: 120px !important;
    object-fit: cover !important;
    display: block !important;
    margin: 1rem 0 !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

/* 強制覆蓋所有內聯樣式的圖片 */
.content-preview img[style*="width"],
.content-preview img[style*="height"],
.content-preview img[style*="width:"],
.content-preview img[style*="height:"] {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    max-height: 120px !important;
    object-fit: cover !important;
}

/* 所有文章頁面的內聯樣式圖片處理 */
.article-card img[style*="width"],
.article-card img[style*="height"],
.article-card img[style*="width:"],
.article-card img[style*="height:"] {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    max-height: 120px !important;
    object-fit: cover !important;
}

/* 處理所有內聯樣式 */
.content-preview img[style],
.article-card img[style] {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    max-height: 120px !important;
    object-fit: cover !important;
}


/* 首頁預覽中的表格完全隱藏或簡化 */
.content-preview table {
    display: none !important; /* 完全隱藏表格 */
}

/* 或者顯示簡化版本 */
.content-preview table.simple-table {
    display: table !important;
    font-size: 0.6rem;
    max-width: 100%;
}

.content-preview table.simple-table th,
.content-preview table.simple-table td {
    padding: 0.1rem;
    font-size: 0.6rem;
    max-width: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.content-preview th {
    background-color: #f8f9fa;
    font-weight: bold;
}

.article-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* 文章詳情 */
.article-detail {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.article-detail h1 {
    color: white;
    font-size: 2.5rem;
    margin-bottom: 1rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.article-meta {
    border-bottom: 1px solid #ecf0f1;
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}


/* 強制清理文章內容中的多餘空白 */
.article-content * {
    white-space: pre-line !important;
}

.article-content p {
    margin: 0 0 1em 0;
    padding: 0;
}

.article-content p:last-child {
    margin-bottom: 0;
}

/* 表單樣式 */
.article-form {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    max-width: 800px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #2c3e50;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input[type="checkbox"] {
    width: auto !important;
    min-width: auto !important;
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
    margin-right: 0.5rem !important;
    cursor: pointer;
    flex-shrink: 0;
    height: auto;
}

.form-group label.checkbox-label {
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem;
    cursor: pointer;
    margin-bottom: 0;
    flex-wrap: nowrap;
}

.form-group label.checkbox-label span {
    flex: 1;
    line-height: 1.5;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-start;
    flex-wrap: wrap;
}

/* 操作按鈕 */
.actions {
    margin-bottom: 2rem;
    text-align: right;
}

/* 錯誤頁面 */
.error,
.not-found {
    text-align: center;
    padding: 3rem 0;
}

.error-message,
.not-found-message {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
    padding: 1rem;
    border-radius: 4px;
    margin: 2rem 0;
}

.error-actions,
.not-found-actions {
    margin-top: 2rem;
}

/* 主內容區域 */
main {
    flex: 1 0 auto;
}

/* 頁尾 */
footer {
    background-color: #2c3e50;
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
    flex-shrink: 0;
}

/* 富文本編輯器樣式 */
.ql-editor {
    min-height: 200px;
    font-size: 16px;
    line-height: 1.6;
}

/* 字型選擇樣式 */
.ql-editor .ql-font-新細明體 {
    font-family: "新細明體", "PMingLiU", serif;
}

.ql-editor .ql-font-標楷體 {
    font-family: "標楷體", "DFKai-SB", serif;
}

.ql-editor .ql-font-微軟正黑體 {
    font-family: "微軟正黑體", "Microsoft JhengHei", sans-serif;
}

.ql-editor .ql-font-Arial {
    font-family: Arial, sans-serif;
}

.ql-editor .ql-font-Times\ New\ Roman {
    font-family: "Times New Roman", serif;
}

.ql-editor .ql-font-serif {
    font-family: serif;
}

.ql-editor .ql-font-monospace {
    font-family: monospace;
}

/* 圖片調整大小功能樣式 */
.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    background: #3498db;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: se-resize;
    opacity: 0;
    transition: opacity 0.3s ease, background 0.3s ease;
    z-index: 10;
    user-select: none;
}

.resize-handle:hover {
    background: #2980b9;
    transform: scale(1.1);
}

/* 調整大小時的視覺回饋 */
img.resizing {
    outline: 2px dashed #3498db;
    outline-offset: 2px;
}

.ql-toolbar {
    border-top: 1px solid #ccc;
    border-left: 1px solid #ccc;
    border-right: 1px solid #ccc;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
}

.ql-container {
    border-bottom: 1px solid #ccc;
    border-left: 1px solid #ccc;
    border-right: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 4px 4px;
}

.ql-editor.ql-blank::before {
    color: #999;
    font-style: italic;
}

/* 富文本內容顯示樣式 */
.article-content {
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 2rem;
    white-space: pre-line; /* 保留換行符但合併多餘空格 */
    word-wrap: break-word; /* 長單詞自動換行 */
    overflow-x: hidden; /* 防止水平捲軸 */
    max-width: 100%;
    box-sizing: border-box;
}

.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4,
.article-content h5,
.article-content h6 {
    margin: 1.5rem 0 1rem 0;
    color: #2c3e50;
    font-weight: bold;
}

.article-content h1 { font-size: 2rem; }
.article-content h2 { font-size: 1.75rem; }
.article-content h3 { font-size: 1.5rem; }
.article-content h4 { font-size: 1.25rem; }
.article-content h5 { font-size: 1.1rem; }
.article-content h6 { font-size: 1rem; }

.article-content p {
    margin: 0 0 1em 0;
    padding: 0;
}

.article-content p:last-child {
    margin-bottom: 0;
}

.article-content ul,
.article-content ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

.article-content li {
    margin: 0.5rem 0;
}

.article-content blockquote {
    border-left: 4px solid #3498db;
    margin: 1rem 0;
    padding: 0.5rem 1rem;
    background-color: #f8f9fa;
    font-style: italic;
}

.article-content code {
    background-color: #f1f2f6;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.article-content pre {
    background-color: #f1f2f6;
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
    margin: 1rem 0;
}

.article-content pre code {
    background: none;
    padding: 0;
}

.article-content a {
    color: #3498db;
    text-decoration: underline;
}

.article-content a:hover {
    color: #2980b9;
}

.article-content img {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    border-radius: 4px;
    margin: 1rem 0;
    display: block;
    box-sizing: border-box;
}

/* 確保所有圖片都不會超出容器 */
.article-content img,
.content-preview img {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    box-sizing: border-box;
}


/* 強制所有媒體元素響應式 */
.article-content img,
.article-content video,
.article-content iframe,
.article-content embed,
.article-content object {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    box-sizing: border-box;
}

/* 特別處理富文本編輯器產生的圖片 */
.article-content img[style*="width"],
.article-content img[style*="height"] {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
}

/* 處理內聯樣式的圖片 */
.article-content img[style] {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
}

/* 強制覆蓋所有內聯樣式 */
.article-content img[style*="width:"] {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
}

.article-content img[style*="height:"] {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
}

/* 處理所有可能的圖片樣式 */
.article-content img {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    border-radius: 4px;
    margin: 1rem 0;
    display: block;
    box-sizing: border-box;
    overflow: hidden;
}

/* 確保圖片容器不會溢出 */
.article-content {
    overflow-x: hidden;
    max-width: 100%;
    word-wrap: break-word;
    box-sizing: border-box;
}

/* 強制所有元素不超出容器 */
.article-content * {
    max-width: 100%;
    box-sizing: border-box;
}

/* 特別處理富文本編輯器產生的問題 */
.article-content img {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    border-radius: 4px;
    margin: 1rem 0;
    display: block;
    box-sizing: border-box;
    overflow: hidden;
}

/* 強制覆蓋所有可能的內聯樣式 */
.article-content img[style*="width"],
.article-content img[style*="height"],
.article-content img[style*="width:"],
.article-content img[style*="height:"] {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
}

/* 處理所有內聯樣式 */
.article-content img[style] {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
}

/* 確保頁面不會出現水平捲軸 */
body {
    overflow-x: hidden;
}


/* 強制所有媒體元素響應式 */
.article-content img,
.article-content video,
.article-content iframe,
.article-content embed,
.article-content object {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    box-sizing: border-box;
}


.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    table-layout: fixed; /* 固定表格佈局，防止內容過寬 */
    max-width: 100%; /* 確保表格不超出容器 */
}

.article-content th,
.article-content td {
    border: 1px solid #ddd;
    padding: 0.5rem;
    text-align: left;
    word-wrap: break-word; /* 強制換行 */
    overflow-wrap: break-word; /* 現代瀏覽器支援 */
    hyphens: auto; /* 自動斷詞 */
    white-space: normal; /* 允許換行 */
    max-width: 0; /* 配合 table-layout: fixed 使用 */
}

.article-content th {
    background-color: #f8f9fa;
    font-weight: bold;
}


/* 為表格添加容器包裝 */
.table-container {
    overflow-x: auto;
    max-width: 100%;
    margin: 1rem 0;
}

.table-container table {
    width: 100%;
    min-width: 600px; /* 設定最小寬度 */
}

/* 響應式設計 - 平板和手機 */
@media (max-width: 1024px) {
    main {
        padding: 0 1rem;
    }
    
    .article-list {
        grid-template-columns: 1fr;
    }
}

/* 響應式設計 - 平板 */
@media (max-width: 768px) {
    /* 導航欄 */
    nav {
        flex-wrap: nowrap;
        gap: 0.5rem;
    }
    
    /* 顯示漢堡選單 */
    .hamburger-menu {
        display: flex;
    }
    
    /* 隱藏桌面版元素 */
    .desktop-only {
        display: none !important;
    }
    
    .nav-left {
        flex: 0 0 auto;
    }
    
    .logo {
        font-size: 1.2rem;
        margin-left: 0.5rem;
    }
    
    /* 主要內容 */
    main {
        margin: 1rem auto;
        padding: 0 1rem;
    }
    
    .hero {
        padding: 2rem 1rem;
        margin-bottom: 1.5rem;
    }
    
    .hero h2 {
        font-size: 2rem;
    }
    
    .hero p {
        font-size: 1rem;
    }
    
    /* 文章卡片 */
    .article-card {
        padding: 1rem;
    }
    
    .article-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .article-actions .btn {
        width: 100%;
    }
    
    /* 表單 */
    .form-actions {
        flex-direction: column;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .btn {
        width: 100%;
        text-align: center;
        margin: 0.25rem 0;
    }
    
    /* 富文本編輯器 */
    .ql-toolbar {
        flex-wrap: wrap;
    }
    
    .ql-toolbar .ql-formats {
        margin-right: 0.5rem;
    }
    
    /* 表格處理 */
    .article-content table,
    .content-preview table {
        font-size: 0.8rem;
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    .article-content th,
    .article-content td,
    .content-preview th,
    .content-preview td {
        padding: 0.25rem;
        min-width: 80px;
    }
    
    /* 訂閱方案相關 */
    .plans-grid {
        grid-template-columns: 1fr;
    }
    
    .plan-details {
        grid-template-columns: 1fr;
    }
    
    .subscription-details {
        grid-template-columns: 1fr;
    }
    
    /* 管理訂閱方案 */
    .manage-plans-container,
    .subscriptions-container,
    .subscription-plans-container {
        padding: 0 0.5rem;
    }
    
    .plan-item {
        padding: 1rem;
    }
    
    .plan-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .plan-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .plan-actions .btn {
        width: 100%;
    }
    
    /* 表單容器 */
    .create-plan-form,
    .article-form {
        padding: 1.5rem;
    }
    
    /* 頁尾 */
    footer {
        padding: 1.5rem 0;
        font-size: 0.9rem;
    }
}

/* 響應式設計 - 手機 */
@media (max-width: 480px) {
    /* 導航欄 */
    nav {
        flex-wrap: nowrap;
        gap: 0.5rem;
    }
    
    /* 顯示漢堡選單 */
    .hamburger-menu {
        display: flex;
    }
    
    /* 隱藏桌面版元素 */
    .desktop-only {
        display: none !important;
    }
    
    .logo {
        font-size: 1.1rem;
        margin-left: 0.5rem;
    }
    
    /* 側邊欄寬度調整 */
    .sidebar-menu {
        width: 260px;
        left: -260px;
    }
    
    /* 主要內容 */
    main {
        margin: 0.5rem auto;
        padding: 0 0.5rem;
    }
    
    .hero {
        padding: 1.5rem 0.5rem;
        margin-bottom: 1rem;
    }
    
    .hero h2 {
        font-size: 1.5rem;
    }
    
    .hero p {
        font-size: 0.9rem;
    }
    
    /* 文章卡片 */
    .article-card {
        padding: 0.75rem;
    }
    
    .article-card h3,
    .article-card h4 {
        font-size: 1.1rem;
    }
    
    /* 表單 */
    .create-plan-form,
    .article-form {
        padding: 1rem;
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* 防止 iOS 自動縮放 */
    }
    
    /* 按鈕 */
    .btn {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }
    
    /* 表格處理 */
    .article-content table,
    .content-preview table {
        font-size: 0.7rem;
    }
    
    .article-content th,
    .article-content td,
    .content-preview th,
    .content-preview td {
        padding: 0.2rem;
        min-width: 60px;
    }
    
    /* 訂閱相關 */
    .subscription-card {
        padding: 1rem;
    }
    
    .subscription-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .subscription-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .subscription-actions .btn {
        width: 100%;
    }
    
    .plan-card {
        padding: 1rem;
    }
    
    .plan-card h3 {
        font-size: 1.2rem;
    }
    
    /* 管理頁面 */
    .manage-plans-container,
    .subscriptions-container,
    .subscription-plans-container {
        padding: 0 0.5rem;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
    }
    
    .plan-item {
        padding: 0.75rem;
    }
    
    .plan-name {
        font-size: 1.1rem;
    }
    
    /* 確認對話框 */
    .confirm-dialog {
        max-width: 90%;
        padding: 1.5rem;
        margin: 1rem;
    }
    
    /* 頁尾 */
    footer {
        padding: 1rem 0;
        font-size: 0.85rem;
    }
}

/* 強制表格響應式處理 */
.article-content table {
    width: 100% !important;
    max-width: 100% !important;
    table-layout: fixed !important;
    word-wrap: break-word !important;
}

.article-content th,
.article-content td {
    max-width: 0 !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
}

/* 移除舊版頁內作者選擇器樣式（已改為導覽列下拉） */

/* 確保頁面不會出現水平捲軸 */
body {
    overflow-x: hidden;
}


 
 