:root {
    --orange: #e86f15;
    --orange-dark: #b55310;
    --orange-soft: #fff2e8;
    --white: #ffffff;
    --ink: #1b1b1b;
    --line: #d7d7d7;
    --success: #e5f6ea;
    --success-ink: #1f6a33;
    --error: #ffe8e8;
    --error-ink: #8b1f1f;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--ink);
    background: linear-gradient(180deg, #fff 0%, #fff7f1 100%);
}

a {
    color: var(--orange-dark);
}

code,
pre {
    font-family: "Courier New", Courier, monospace;
}

input,
button {
    font: inherit;
}

.page {
    width: min(1100px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

.site-header {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-start;
    margin-bottom: 24px;
    border-bottom: 3px solid var(--orange);
    padding-bottom: 16px;
}

.site-header h1 {
    margin: 6px 0 0;
    font-size: 2rem;
}

.eyebrow {
    margin: 0;
    color: var(--orange-dark);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    font-weight: 700;
}

.top-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.top-nav a,
.button-link,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 14px;
    border: 2px solid var(--orange);
    background: var(--orange);
    color: var(--white);
    text-decoration: none;
    cursor: pointer;
}

button:hover,
.top-nav a:hover,
.button-link:hover {
    background: var(--orange-dark);
    border-color: var(--orange-dark);
}

.panel {
    background: var(--white);
    border: 2px solid var(--line);
    padding: 24px;
    margin-bottom: 24px;
}

.panel.narrow {
    width: min(480px, 100%);
}

.stack {
    display: grid;
    gap: 16px;
}

label {
    display: grid;
    gap: 8px;
    font-weight: 700;
}

input[type="email"],
input[type="text"] {
    width: 100%;
    min-height: 44px;
    border: 2px solid var(--line);
    padding: 10px 12px;
    background: var(--white);
}

input[type="email"]:focus,
input[type="text"]:focus {
    outline: none;
    border-color: var(--orange);
}

.helper-text {
    margin: 16px 0 0;
}

.flash {
    padding: 14px 16px;
    border: 2px solid;
    margin-bottom: 24px;
}

.flash-success {
    background: var(--success);
    color: var(--success-ink);
    border-color: #91c89e;
}

.flash-error {
    background: var(--error);
    color: var(--error-ink);
    border-color: #e3a3a3;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    border: 2px solid var(--orange);
    background: var(--orange-soft);
    padding: 18px;
    display: grid;
    gap: 8px;
}

.stat-card strong {
    font-size: 2rem;
}

.grid-form {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    align-items: end;
}

.checkbox-row {
    display: flex;
    gap: 10px;
    align-items: center;
    min-height: 44px;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}

th,
td {
    border: 1px solid var(--line);
    padding: 10px 12px;
    text-align: left;
    vertical-align: top;
}

th {
    background: #fff5ee;
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.period-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.period-card {
    min-height: 220px;
    display: grid;
    place-items: center;
    gap: 8px;
    padding: 24px;
    text-decoration: none;
    color: var(--ink);
    border: 3px solid var(--orange);
    background:
        radial-gradient(circle at top right, rgba(232, 111, 21, 0.22), transparent 34%),
        linear-gradient(180deg, #fff7f1 0%, #fff 100%);
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.period-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 24px rgba(181, 83, 16, 0.14);
}

.period-card-time {
    font-size: clamp(2.8rem, 7vw, 4rem);
    font-weight: 700;
    color: var(--orange-dark);
    line-height: 1;
}

.period-card-year {
    font-size: 1.5rem;
    letter-spacing: 0.04em;
}

.books-panel {
    display: grid;
    gap: 24px;
}

.books-panel-header h2 {
    margin: 6px 0 0;
    font-size: 1.8rem;
}

.books-section-stack {
    display: grid;
    gap: 28px;
}

.books-subtitle {
    margin: 0 0 16px;
    font-size: 1.2rem;
}

.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 18px;
}

.book-card {
    border: 2px solid var(--line);
    background: #fffaf7;
    overflow: hidden;
}

.book-cover-placeholder {
    min-height: 240px;
    display: grid;
    place-items: center;
    background:
        linear-gradient(135deg, rgba(232, 111, 21, 0.14), rgba(232, 111, 21, 0.04)),
        repeating-linear-gradient(
            -45deg,
            rgba(232, 111, 21, 0.06),
            rgba(232, 111, 21, 0.06) 16px,
            rgba(255, 255, 255, 0.45) 16px,
            rgba(255, 255, 255, 0.45) 32px
        );
    color: var(--orange-dark);
    font-size: 4.5rem;
    font-weight: 700;
    border-bottom: 2px solid var(--line);
}

.book-card-body {
    padding: 16px;
}

.book-card-body h4 {
    margin: 0 0 12px;
    font-size: 1rem;
    line-height: 1.35;
}

.book-card-body p {
    margin: 0;
    color: #5c534d;
}

.books-empty {
    margin: 0;
    padding: 18px;
    border: 2px dashed var(--line);
    background: #fffaf7;
}

pre {
    margin: 16px 0 0;
    padding: 16px;
    border: 2px solid var(--line);
    background: #fffaf7;
    overflow-x: auto;
}

@media (max-width: 700px) {
    .site-header {
        flex-direction: column;
    }

    .page {
        width: min(100% - 20px, 1100px);
        padding-top: 20px;
    }

    .site-header h1 {
        font-size: 1.6rem;
    }
}
