:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --accent: #f59e0b;
    --success: #16a34a;
    --danger: #dc2626;
    --radius: 12px;
    --shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.55; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { width: 100%; max-width: 1220px; margin: 0 auto; padding: 0 18px; }
.muted { color: var(--muted); }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 18px; }
.brand-logo { font-size: 1.4rem; font-weight: 800; color: var(--text); text-decoration: none !important; }
.brand-logo span { color: var(--primary); }
.header-search { display: flex; flex: 1; max-width: 420px; }
.header-search input { flex: 1; padding: 9px 14px; border: 1px solid var(--border); border-right: none; border-radius: 8px 0 0 8px; font-size: 0.95rem; }
.header-search button { padding: 9px 16px; background: var(--primary); color: #fff; border: none; border-radius: 0 8px 8px 0; font-weight: 600; cursor: pointer; }
.main-nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; font-weight: 500; font-size: 0.95rem; }
.main-nav a { color: var(--text); }
.nav-pill-free { background: #dcfce7; color: #15803d !important; padding: 4px 10px; border-radius: 999px; font-weight: 700; }

/* Buttons & Badges */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: 8px; font-weight: 600; border: 1px solid transparent; cursor: pointer; text-decoration: none !important; font-size: 0.95rem; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.badge { display: inline-block; padding: 3px 9px; border-radius: 6px; font-size: 0.78rem; font-weight: 700; background: #eff6ff; color: var(--primary); }
.badge-sale { background: #fef2f2; color: var(--danger); }
.badge-free { background: #dcfce7; color: #15803d; }

/* Grids & Cards */
.section { padding: 36px 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 20px; gap: 12px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 20px; }
.ws-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; transition: transform 0.15s ease; }
.ws-card:hover { transform: translateY(-3px); }
.ws-thumb { position: relative; aspect-ratio: 4/3; background: #e2e8f0; overflow: hidden; }
.ws-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ws-thumb .badge-top { position: absolute; top: 10px; right: 10px; }
.ws-body { padding: 15px; display: flex; flex-direction: column; flex: 1; gap: 8px; }
.ws-title { font-size: 1.03rem; font-weight: 700; color: var(--text); }
.ws-author { font-size: 0.84rem; color: var(--muted); }
.ws-footer { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.price-now { font-size: 1.12rem; font-weight: 800; color: var(--text); }
.price-old { font-size: 0.86rem; color: var(--muted); text-decoration: line-through; margin-right: 5px; }

/* Worksheet Detail Layout */
.detail-layout { display: grid; grid-template-columns: 1.35fr 1fr; gap: 32px; align-items: start; padding: 32px 0; }
.preview-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.preview-main img { width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.preview-thumbs { display: flex; gap: 10px; margin-top: 12px; overflow-x: auto; }
.preview-thumbs img { width: 76px; height: 96px; object-fit: cover; border-radius: 6px; border: 2px solid transparent; cursor: pointer; }
.preview-thumbs img.active { border-color: var(--primary); }
.buy-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); position: sticky; top: 86px; }
.spec-table { width: 100%; border-collapse: collapse; margin: 18px 0; font-size: 0.92rem; }
.spec-table td { padding: 9px 0; border-bottom: 1px solid var(--border); }
.spec-table td:last-child { text-align: right; font-weight: 600; }

/* Author Banner */
.author-hero { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px; display: flex; gap: 22px; align-items: center; margin: 28px 0; }
.author-avatar { width: 88px; height: 88px; border-radius: 50%; object-fit: cover; border: 3px solid #eff6ff; }

/* Ad Slot Container */
.ad-slot { margin: 22px auto; text-align: center; min-height: 90px; background: #f1f5f9; border: 1px dashed #cbd5e1; border-radius: 8px; padding: 10px; overflow: hidden; }
.ad-slot-grid-item { grid-column: 1 / -1; }

/* Footer */
.site-footer { background: #0f172a; color: #cbd5e1; padding: 42px 0 24px; margin-top: 56px; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 28px; }
.footer-grid h4 { color: #fff; margin-bottom: 12px; }
.footer-grid ul { list-style: none; display: grid; gap: 8px; font-size: 0.92rem; }
.footer-grid a { color: #94a3b8; }
.footer-bottom { border-top: 1px solid #1e293b; margin-top: 28px; padding-top: 18px; font-size: 0.85rem; color: #64748b; }

@media (max-width: 860px) {
    .detail-layout { grid-template-columns: 1fr; }
    .buy-box { position: static; }
    .author-hero { flex-direction: column; text-align: center; }
}

@media (max-width: 900px) {
    .header-search input[type="search"] {
        width: 115px !important;
        padding: 4px 8px !important;
        font-size: 0.78rem !important;
    }
}