:root {
    --bg: #faf7f2;
    --surface: #ffffff;
    --ink: #1a1715;
    --muted: #6b6259;
    --accent: #8b3a2f;
    --accent-dark: #6e2c23;
    --border: #e8e2d8;
    --shadow: 0 1px 3px rgba(26, 23, 21, 0.06), 0 4px 12px rgba(26, 23, 21, 0.04);
    --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
    line-height: 1.55;
    min-height: 100vh;
}

body {
    display: flex;
    flex-direction: column;
}

main { flex: 1; }

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 1rem;
    padding-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--ink);
    text-decoration: none;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    background: var(--accent);
    color: #fff;
    border-radius: 4px;
    font-family: Georgia, serif;
    font-style: italic;
}

.nav { display: flex; gap: 1.25rem; }
.nav a { color: var(--muted); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 0.95rem; }
.nav a:hover { color: var(--ink); text-decoration: none; }

/* Hero */
.hero {
    padding: 3rem 0 2rem;
    text-align: center;
}
.hero h1 {
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    margin: 0 0 0.5rem;
    font-weight: normal;
    letter-spacing: -0.01em;
}
.hero p {
    color: var(--muted);
    max-width: 540px;
    margin: 0 auto;
    font-size: 1.05rem;
}

/* Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
    padding: 2rem 0 4rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    color: inherit;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    text-decoration: none;
}

.card-image {
    aspect-ratio: 2 / 3;
    background: #ede6da;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.card-image-placeholder {
    color: var(--muted);
    font-size: 0.9rem;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}

.card-body { padding: 0.9rem 1rem 1.1rem; }
.card-title { margin: 0 0 0.2rem; font-size: 1.05rem; font-weight: normal; line-height: 1.3; }
.card-author { margin: 0; color: var(--muted); font-size: 0.9rem; font-style: italic; }
.card-price { margin: 0.5rem 0 0; font-weight: bold; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }

.empty {
    text-align: center;
    padding: 3rem 0;
    color: var(--muted);
}

/* Book detail */
.book-detail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
    gap: 2.5rem;
    padding: 3rem 0 4rem;
    align-items: start;
}

.book-detail-image {
    aspect-ratio: 2 / 3;
    background: #ede6da;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.book-detail-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.book-detail-body h1 { font-size: 2rem; margin: 0 0 0.4rem; font-weight: normal; }
.book-detail-author { color: var(--muted); font-style: italic; margin: 0 0 1rem; }
.book-detail-price { font-size: 1.5rem; font-weight: bold; margin: 0 0 1.5rem; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }
.book-detail-description { white-space: pre-wrap; margin-bottom: 2rem; }
.back { margin-top: 1.5rem; font-family: -apple-system, BlinkMacSystemFont, sans-serif; font-size: 0.9rem; }

.buy-btn {
    background: var(--accent);
    color: #fff;
    border: 0;
    padding: 0.85rem 1.6rem;
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    cursor: pointer;
    transition: background 0.15s ease;
}
.buy-btn:hover:not([disabled]) { background: var(--accent-dark); }
.buy-btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* Admin */
.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2.5rem 0 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.admin-header h1 { margin: 0; font-weight: normal; font-size: 1.8rem; }

.btn-primary, .btn-secondary, .btn-danger {
    display: inline-block;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    cursor: pointer;
    border: 0;
    text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); text-decoration: none; }
.btn-secondary { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-secondary:hover { color: var(--ink); text-decoration: none; }
.btn-danger { background: transparent; color: var(--accent); border: 1px solid var(--border); font-size: 0.85rem; padding: 0.35rem 0.75rem; }
.btn-danger:hover { background: var(--accent); color: #fff; }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 4rem;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
}
.admin-table th, .admin-table td {
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.admin-table th {
    background: #f5f0e8;
    font-weight: 600;
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.admin-table tr:last-child td { border-bottom: 0; }
.thumb-cell { width: 60px; }
.thumb-cell img {
    width: 44px;
    height: 60px;
    object-fit: cover;
    border-radius: 3px;
    display: block;
}

/* Forms */
.form-page {
    max-width: 600px;
    margin: 0 auto;
    padding: 3rem 0 4rem;
}
.form-page h1 { font-weight: normal; margin: 0 0 1.5rem; }

.book-form {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
}
.book-form label {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.9rem;
    color: var(--muted);
}
.book-form input[type="text"],
.book-form input[type="number"],
.book-form textarea {
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--bg);
    color: var(--ink);
}
.book-form input:focus, .book-form textarea:focus {
    outline: none;
    border-color: var(--accent);
}
.book-form textarea { resize: vertical; }

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.1rem;
}
@media (max-width: 480px) {
    .form-row { grid-template-columns: 1fr; }
}

.book-detail-meta {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.35rem 1rem;
    margin: 0 0 1.5rem;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.95rem;
}
.book-detail-meta dt {
    color: var(--muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    align-self: center;
}
.book-detail-meta dd { margin: 0; }

/* Authors */
.author-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
    padding: 2rem 0 4rem;
}
.author-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    color: inherit;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.author-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    text-decoration: none;
}
.author-photo {
    aspect-ratio: 1 / 1;
    background: #ede6da;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.author-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.author-photo-placeholder {
    color: var(--muted);
    font-size: 0.95rem;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    text-align: center;
    padding: 1rem;
}
.author-body { padding: 0.9rem 1.1rem 1.2rem; }
.author-name { margin: 0 0 0.15rem; font-size: 1.1rem; font-weight: normal; line-height: 1.3; }
.author-lifespan {
    margin: 0 0 0.5rem;
    color: var(--muted);
    font-size: 0.85rem;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
}
.author-bio { margin: 0; color: var(--ink); font-size: 0.92rem; line-height: 1.5; }

.author-detail {
    display: grid;
    grid-template-columns: minmax(0, 280px) minmax(0, 1fr);
    gap: 2.5rem;
    padding: 3rem 0 2.5rem;
    align-items: start;
}
.author-detail-photo {
    aspect-ratio: 1 / 1;
    background: #ede6da;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.author-detail-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.author-detail-body h1 { font-size: 2rem; margin: 0 0 0.4rem; font-weight: normal; }
.author-detail-bio { margin: 1rem 0 0; font-size: 1.05rem; line-height: 1.6; }

.author-books { padding: 0 0 4rem; }
.author-books h2 { font-weight: normal; font-size: 1.4rem; margin: 1rem 0 0.5rem; }
.author-books .grid { padding-top: 1rem; padding-bottom: 0; }

@media (max-width: 720px) {
    .author-detail {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    .author-detail-photo {
        max-width: 240px;
        margin: 0 auto;
    }
}

/* Footer */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 1.5rem 0;
    margin-top: auto;
    color: var(--muted);
    font-size: 0.85rem;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    text-align: center;
}

/* Responsive */
@media (max-width: 720px) {
    .book-detail {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    .book-detail-image {
        max-width: 280px;
        margin: 0 auto;
    }
    .admin-table thead { display: none; }
    .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; }
    .admin-table tr { border-bottom: 1px solid var(--border); padding: 0.75rem 0; }
    .admin-table tr:last-child { border-bottom: 0; }
    .admin-table td { padding: 0.3rem 1rem; border: 0; }
    .thumb-cell { padding-top: 0.75rem; }
}
