/* 全局重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS 變數定義 */
:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --secondary: #764ba2;
    --accent: #f093fb;
    --bg-light: #fafbff;
    --bg-dark: #0f0f23;
    --text-light: #2d3748;
    --text-dark: #e2e8f0;
    --card-light: rgba(255, 255, 255, 0.8);
    --card-dark: rgba(255, 255, 255, 0.05);
    --shadow-light: 0 10px 25px rgba(102, 126, 234, 0.1);
    --shadow-dark: 0 10px 25px rgba(0, 0, 0, 0.3);
    --code-bg-light: #f7fafc;
    --code-bg-dark: #1a202c;
    --border-light: rgba(102, 126, 234, 0.2);
    --border-dark: rgba(255, 255, 255, 0.1);
    --gradient: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
}

/* 淺色主題 */
[data-theme="light"] {
    --bg: var(--bg-light);
    --text: var(--text-light);
    --card: var(--card-light);
    --shadow: var(--shadow-light);
    --code-bg: var(--code-bg-light);
    --border: var(--border-light);
}

/* Body 樣式 */
body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
    line-height: 1.7;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
    position: relative;
}

/* Body 背景漸變疊加層 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient);
    opacity: 0.05;
    z-index: -1;
    transition: opacity 0.3s ease;
}

/* 容器樣式 */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 5rem 1rem 2rem;
}

/* 頁面標頭樣式 */
.header {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
}

.header::after {
    content: '';
    position: absolute;
    bottom: -1rem;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: var(--gradient);
    border-radius: 2px;
}

h1 {
    font-size: 3rem;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 1rem;
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.8;
    font-weight: 300;
}

.theme-toggle,
.nav-back-btn {
    position: absolute;
    top: 2rem;
    background: var(--card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    box-shadow: var(--shadow);
    z-index: 1000;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 懸停效果共用 */
.theme-toggle:hover,
.nav-back-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.2);
}

/* 主題切換按鈕 (右側 ) */
.theme-toggle {
    right: 2rem;
}

/* 返回首頁按鈕 (左側 ) */
.nav-back-btn {
    left: 2rem;
    text-decoration: none;
    color: var(--text);
    font-weight: 500;
}

.nav-back-btn:hover {
    color: var(--primary);
}

/* 軟體卡片網格佈局 */
.software-grid {
    display: grid;
    gap: 2rem;
    margin-bottom: 3rem;
}

/* 軟體卡片樣式 */
.software-card {
    background: var(--card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    position: relative;
    animation: fadeInUp 0.6s ease forwards;
    opacity: 0;
}

.software-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(102, 126, 234, 0.2);
}

.software-header {
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
}

.software-icon {
    width: 50px;
    height: 50px;
    background: var(--gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
    font-size: 1.5rem;
    color: white;
}

.software-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
}

.software-description {
    margin-bottom: 1.5rem;
    opacity: 0.8;
    line-height: 1.6;
}

/* 連結按鈕樣式 */
.link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center; /* 按鈕內容居中 */
    background: var(--gradient);
    color: white;
    text-decoration: none;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    font-weight: 500;
    transition: all 0.3s ease;
    margin: 0.5rem 0;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    border: none; /* 確保 button 和 input[type=submit] 沒有默認邊框 */
}

.link-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.link-button::after {
    margin-left: 0.5rem;
    transition: transform 0.3s ease;
}

.link-button:hover::after {
    transform: translateX(3px);
}

/* 備註區塊樣式 */
.notes-section {
    background: var(--card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: var(--shadow);
    position: relative;
    animation: fadeInUp 0.6s ease forwards;
    opacity: 0;
    animation-delay: 0.4s;
}

.notes-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--primary);
}

.note-item {
    display: flex;
    align-items: flex-start;
    margin-bottom: 0.8rem;
    padding: 0.8rem;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 10px;
    transition: all 0.3s ease;
    word-break: break-word; /* 允許長單詞或連結換行 */
}

.note-item:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: translateX(5px);
}

.note-bullet {
    color: var(--primary);
    margin-right: 0.8rem;
    font-weight: bold;
    line-height: 1.6;
}

.note-item span:last-child {
    line-height: 1.6;
}

/* 行內程式碼樣式 */
.inline-code {
    background: var(--code-bg);
    color: var(--primary);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-family: 'JetBrains Mono', Consolas, monospace;
    font-size: 0.85em;
    font-weight: 500;
    word-break: break-all; /* 允許代碼塊內的長字串換行 */
}

/* 小卡片容器 */
.small-card-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-top: 1.5rem;
}

.small-card {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    animation: fadeInUp 0.6s ease forwards;
    opacity: 0;
}

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

.small-card img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    margin-bottom: 0.5rem;
    border-radius: 8px;
}

.small-card .title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
    color: var(--primary);
    word-break: break-word;
}

.small-card .description {
    font-size: 0.85rem;
    opacity: 0.7;
    line-height: 1.4;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0.5rem 0;
}

.small-card .download-link {
    display: block;
    font-size: 0.8rem;
    color: var(--primary);
    text-decoration: none;
    margin-top: auto;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.small-card .download-link:hover {
    text-decoration: underline;
}

/* 平板裝置 (max-width: 768px) */
@media (max-width: 768px) {
    .container {
        padding: 4.5rem 1.5rem 1.5rem;
    }

    h1 {
        font-size: 2.5rem;
    }

    .subtitle {
        font-size: 1.1rem;
    }

    .theme-toggle,
    .nav-back-btn {
        top: 1rem;
        padding: 0.6rem 1rem;
        font-size: 0.8rem;
    }

    .theme-toggle {
        right: 1rem;
    }

    .nav-back-btn {
        left: 1rem;
    }

    .software-card {
        padding: 1.5rem;
    }

    .small-card-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 4rem 1rem 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .software-card {
        padding: 1.25rem;
    }

    /* --- 關鍵改動: 工具頁面卡片網格變為單欄 --- */
    .small-card-grid {
        grid-template-columns: 1fr; /* 變為單欄佈局 */
        gap: 1.5rem; /* 增加垂直間距 */
    }

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

    .small-card .description {
        font-size: 0.9rem;
    }

    .small-card .download-link {
        font-size: 0.85rem;
    }

    /* --- 關鍵改動: gh_proxy.html 表單優化 --- */
    form .url {
        font-size: 16px !important; /* 防止 iOS 縮放 */
        width: 100%;
    }

    form .link-button {
        width: 100%; /* 按鈕寬度變為 100% */
        padding-top: 1rem;
        padding-bottom: 1rem;
        font-size: 1rem;
    }

    form .link-button::after {
        display: none; /* 在手機上隱藏下載按鈕的箭頭 */
    }
}


/* 淡入動畫定義 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 錯開動畫延遲 */
.software-card:nth-child(1), .small-card:nth-child(1) {
    animation-delay: 0.1s;
}

.software-card:nth-child(2), .small-card:nth-child(2) {
    animation-delay: 0.2s;
}

.software-card:nth-child(3), .small-card:nth-child(3) {
    animation-delay: 0.3s;
}

.small-card:nth-child(4) {
    animation-delay: 0.4s;
}

.small-card:nth-child(5) {
    animation-delay: 0.5s;
}

.small-card:nth-child(6) {
    animation-delay: 0.6s;
}

.small-card:nth-child(7) {
    animation-delay: 0.7s;
}

.small-card:nth-child(8) {
    animation-delay: 0.8s;
}