:root {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --secondary: #ff7b54;
    --background: #F3F6FB;
    --card-bg: #FFFFFF;
    --text: #1F2937;
    --subtext: #6B7280;
    --radius: 12px;
    --shadow: 0 4px 12px rgba(0,0,0,.08);
}

/* Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Poppins', sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
}

a {
    color: var(--primary);
    text-decoration: none;
}

/* Navbar */
.navbar {
    background: var(--primary);
    color: #fff;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

    .navbar a {
        color: #fff;
        margin-left: 1rem;
        font-weight: 500;
    }

/* Container */
.container {
    padding: 2rem;
}

/* Hero */
.hero {
    background: url('Content/images/hero.jpg') center/cover no-repeat;
    border-radius: var(--radius);
    height: 350px;
    position: relative;
    margin-bottom: 2rem;
    overflow: hidden;
}

    .hero::before {
        content: '';
        position: absolute;
        inset: 0;
        background: rgba(31,41,55,.6);
    }

.hero-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: #fff;
    padding: 0 1rem;
}

.headline {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: .5rem;
}

.subhead {
    font-size: 1.1rem;
    font-weight: 300;
    margin-bottom: 1.5rem;
    max-width: 650px;
}

/* Buttons */
.btn {
    padding: .6rem 1.3rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1rem;
    transition: background .2s, transform .2s;
}

.btn-primary {
    background: var(--secondary);
    color: #fff;
}

    .btn-primary:hover {
        background: #ff5722;
        transform: translateY(-1px);
    }

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

    .btn-outline:hover {
        background: var(--primary);
        color: #fff;
    }

/* Sections */
.section-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 1rem;
    text-align: center;
}

/* Features grid */
.features {
    display: grid;
    gap: 1rem;
    margin: 2rem 0;
}

@media(min-width:700px) {
    .features {
        grid-template-columns: repeat(3,1fr);
    }
}

.feature-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

/* Book cards & tables */
.book-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.book-cover {
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.book-info {
    padding: 1rem;
}

.author {
    font-size: .9rem;
    color: var(--subtext);
    margin-bottom: .5rem;
}

.description {
    font-size: .95rem;
    color: var(--subtext);
    margin-bottom: 1rem;
}

.book-table {
    width: 100%;
    border-collapse: collapse;
}

    .book-table th,
    .book-table td {
        border: 1px solid #e5e7eb;
        padding: .5rem;
        text-align: center;
    }

/* Summary form & textarea */
.summary-form {
    max-width: 650px;
    margin: auto;
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.input-field,
.textarea-field {
    width: 100%;
    padding: .6rem;
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
}

.textarea-field {
    resize: vertical;
}

.book-selected {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    font-weight: 600;
}

/* Success panel & footer */
.success-panel {
    text-align: center;
    border-radius: var(--radius);
    background: var(--card-bg);
    padding: 2rem;
    box-shadow: var(--shadow);
    max-width: 500px;
    margin: auto;
}

.footer {
    text-align: center;
    padding: 1rem;
    color: var(--subtext);
    font-size: .9rem;
}

/* --- Admin Management Styles --- */
form#form1 {
    width: 100%;
    max-width: 1200px;
    min-width: 320px;
    margin: 0 auto;
}

.admin-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    height: 200px;
    position: relative;
    border-radius: 0 0 var(--radius) var(--radius);
    margin-bottom: 1.5rem;
    color: #fff;
}

    .admin-header h1 {
        position: absolute;
        bottom: 1rem;
        left: 2rem;
        font-size: 2.5rem;
        margin: 0;
    }

.admin-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin: -1rem 0 2rem;
    padding: 1rem;
}

    .admin-nav a {
        display: inline-block;
        padding: .75rem 1.5rem;
        background: var(--card-bg);
        color: var(--primary);
        border-radius: var(--radius);
        font-weight: 500;
        box-shadow: var(--shadow);
        transition: all .2s ease;
    }

        .admin-nav a:hover {
            background: var(--primary);
            color: #fff;
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        }

.admin-content {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

    .admin-content h3 {
        margin-top: 0;
        color: var(--primary-dark);
    }

    .admin-content .form-check {
        margin-bottom: 1rem;
    }

    .admin-content .form-check-input {
        margin-right: .5rem;
    }

    .admin-content .btn {
        margin-top: .5rem;
    }

    .admin-content hr {
        margin: 2rem 0;
        border: none;
        border-top: 1px solid #e0e0e0;
    }

/* Utility */
.bullet-list {
    margin-bottom: 1rem;
    padding-left: 1.2rem;
}

    .bullet-list li {
        margin-bottom: .5rem;
    }

.grade-line {
    font-weight: bold;
    margin-bottom: .5rem;
}

.aspect {
    margin-left: 1rem;
    margin-bottom: .25rem;
}

/* =========================
   ? Base: 全站 RWD / Touch
   ========================= */
html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
}

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

.btn, .input-field, .textarea-field, input, select, textarea, button {
    font-size: 16px; /* iOS 避免自動放大 */
    touch-action: manipulation;
}

.btn {
    min-height: 44px; /* 觸控友善 */
    padding: 10px 14px;
}

/* 讓內容不要貼邊：平板很重要 */
.container, .main, .MainContent, #MainContent {
    padding-left: 16px;
    padding-right: 16px;
}

/* =========================
   ? Default.aspx (hero/features)
   ========================= */
/* 如果你的 .features 是 flex 或 grid，這段會讓它在平板自動換欄 */
.features {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 768px) {
    .features {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
}

/* hero 文字在平板別太大或太擠 */
.hero .headline {
    font-size: clamp(28px, 4vw, 44px);
}

.hero .subhead {
    font-size: clamp(14px, 2vw, 18px);
}

/* =========================
   ? Books.aspx (book-grid)
   ========================= */
.book-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

@media (min-width: 768px) {
    .book-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}

@media (min-width: 1024px) {
    .book-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }
}

/* =========================
   ? WriteSummary.aspx (textarea/buttons/panels)
   ========================= */
.textarea-field, textarea {
    width: 100%;
    box-sizing: border-box;
    font-size: 16px; /* iOS */
    line-height: 1.5;
}

/* 三顆按鈕在窄螢幕要換行；平板可並排 */
@media (max-width: 767px) {
    .btn {
        width: 100%;
        display: block;
        margin-bottom: 10px;
    }
}

/* iPad/平板：按鈕並排但保留間距 */
@media (min-width: 768px) {
    #MainContent .btn {
        width: auto;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        margin-right: 10px;
        margin-bottom: 10px;
    }

    /* 摘要欄位在平板高度舒適一點 */
    .textarea-field {
        min-height: 240px;
    }
}

/* ? 避免 iOS overscroll 造成背景穿透（可選） */
body {
    overscroll-behavior: contain;
}

/* =========================
   WriteSummary / 平板觸控穩定性修正
   ========================= */

/* (A) iPad / iOS：避免點到輸入框時自動放大頁面 */
.textarea-field, textarea,
.input-field, input, select {
    font-size: 16px;
}

/* (B) 觸控裝置沒有 hover：避免按鈕 hover 樣式「黏住」 */
@media (hover: none) {
    .btn:hover {
        filter: none;
        transform: none;
        box-shadow: none;
    }
}

