:root {
    color-scheme: light;
    --ink: #292c2c;
    --muted: #6e7371;
    --line: #dcded9;
    --paper: #fbfaf7;
    --surface: #ffffff;
    --stone: #eeeae2;
    --bottom: #d8d0c3;
    --bottom-deep: #514b43;
    --top: #f3f0e9;
    --accent: #5d6f66;
    --accent-dark: #43544c;
    --success-bg: #edf4ef;
    --success: #385c48;
    --error-bg: #faece9;
    --error: #8b3c32;
    --warning-bg: #fff7e5;
    --warning: #775b20;
    --shadow: 0 8px 28px rgba(46, 47, 43, 0.055);
    --radius: 10px;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 13px;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; color: var(--ink); background: var(--paper); line-height: 1.55; }
a { color: var(--accent-dark); text-decoration-thickness: 1px; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; }
button, input, select, textarea { border-radius: 6px; }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .72; }

.page-shell { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }
.site-header { border-bottom: 1px solid var(--line); background: rgba(251, 250, 247, .96); }
.header-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; color: var(--surface); background: var(--bottom-deep); font: 700 10px/1 Georgia, serif; letter-spacing: .08em; }
.brand strong, .brand small { display: block; }
.brand strong { font-family: Georgia, "Times New Roman", serif; font-size: 17px; letter-spacing: -.01em; }
.brand small { margin-top: -2px; color: var(--muted); font-size: 10px; }
nav { display: flex; gap: 22px; }
nav a { color: var(--muted); font-weight: 650; text-decoration: none; }
nav a:hover { color: var(--ink); }

.journal-heading { padding: 58px 0 36px; display: flex; justify-content: space-between; align-items: end; gap: 42px; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; letter-spacing: -.025em; }
h1 { margin-bottom: 12px; font-size: clamp(30px, 4vw, 45px); line-height: 1.08; }
h2 { margin-bottom: 0; font-size: 23px; }
h3 { margin-bottom: 6px; font-size: 15px; }
.intro { max-width: 610px; margin-bottom: 0; color: var(--muted); font-size: 14px; }

.status-bar { min-width: 320px; margin: 0; padding: 13px 16px; display: grid; grid-template-columns: .7fr 1.4fr .7fr; gap: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.status-bar div + div { padding-left: 14px; border-left: 1px solid var(--line); }
.status-bar dt { color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.status-bar dd { margin: 2px 0 0; font-weight: 700; white-space: nowrap; }

.notice { margin-bottom: 28px; padding: 10px 14px; display: flex; gap: 7px; border: 1px solid currentColor; border-radius: 7px; font-size: 11px; }
.notice-ready { color: var(--success); background: var(--success-bg); }
.notice-error { color: var(--error); background: var(--error-bg); }
.notice-warning { color: var(--warning); background: var(--warning-bg); }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.recipe-form-panel { padding: 27px; }
.section-heading { margin-bottom: 24px; display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.section-heading.compact { margin-bottom: 16px; }
.section-heading > div { display: flex; align-items: baseline; gap: 11px; }
.section-number { margin: 0; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .1em; }
.build-label { padding: 5px 8px; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; font-size: 9px; letter-spacing: .03em; }

.recipe-form label { display: grid; gap: 6px; color: #4d514f; font-size: 10px; font-weight: 750; letter-spacing: .035em; text-transform: uppercase; }
input, select, textarea { width: 100%; border: 1px solid #cfd2cc; color: var(--ink); background: rgba(255, 255, 255, .8); outline: none; }
input, select { min-height: 34px; padding: 7px 10px; }
textarea { min-height: 76px; padding: 9px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(93, 111, 102, .13); }
input::placeholder, textarea::placeholder { color: #969a97; font-weight: 400; text-transform: none; letter-spacing: 0; }
.identity-grid { display: grid; grid-template-columns: 1fr 3fr; gap: 16px; }
.coat-grid { margin-top: 28px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.coat-section { min-width: 0; margin: 0; padding: 20px; display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 15px; border: 0; border-radius: 8px; }
.bottom-coat { color: #312e2a; background: var(--bottom); }
.top-coat { color: #3e403e; background: var(--top); border: 1px solid #e4e0d7; }
.coat-section legend { width: 100%; padding: 0 0 14px; display: flex; justify-content: space-between; align-items: baseline; }
.coat-section legend span { font-family: Georgia, "Times New Roman", serif; font-size: 18px; }
.coat-section > .wide-field, .coat-section > .file-field, .coat-choice-field { grid-column: 1 / -1; }
.coat-choice-field { display: grid; gap: 6px; }
.field-label { color: #4d514f; font-size: 10px; font-weight: 750; letter-spacing: .035em; text-transform: uppercase; }
.coat-checkboxes { display: flex; flex-wrap: wrap; gap: 7px; }
.recipe-form .coat-checkbox { width: 34px; height: 34px; display: grid; place-items: center; position: relative; border: 1px solid rgba(62, 62, 58, .22); border-radius: 6px; color: var(--ink); background: rgba(255, 255, 255, .64); cursor: pointer; }
.coat-checkbox input { position: absolute; width: 1px; height: 1px; min-height: 0; margin: 0; opacity: 0; }
.coat-checkbox span { font-size: 11px; font-weight: 800; }
.coat-checkbox:has(input:checked) { color: white; border-color: var(--accent-dark); background: var(--accent-dark); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .26); }
.coat-checkbox:focus-within { outline: 3px solid rgba(93, 111, 102, .2); outline-offset: 1px; }
.file-field input { padding: 5px; font-size: 10px; }
.file-field small { color: var(--muted); font-size: 8px; font-weight: 550; letter-spacing: 0; text-transform: none; }
.form-footer { margin-top: 20px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.fired-photo { width: min(340px, 100%); }
.form-actions { display: flex; gap: 8px; }
.form-message { min-height: 17px; margin: 14px 0 0; color: var(--success); font-size: 10px; font-weight: 650; }
.form-message.error { color: var(--error); }

.button { min-height: 34px; padding: 7px 14px; border: 1px solid transparent; font-size: 10px; font-weight: 800; letter-spacing: .035em; text-transform: uppercase; text-decoration: none; }
.button-primary { min-width: 120px; color: white; background: var(--accent-dark); }
.button-secondary { color: white; background: var(--bottom-deep); }
.button-quiet { color: var(--ink); border-color: var(--line); background: var(--surface); }

.search-section { padding: 58px 0 72px; }
.search-toolbar { padding: 12px; display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.search-field input { height: 100%; }
.results-summary { padding: 12px 3px 10px; display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; }
.empty-state { padding: 52px 20px; text-align: center; border: 1px dashed #cfd2cc; border-radius: var(--radius); color: var(--muted); background: rgba(255, 255, 255, .4); }
.empty-icon { display: block; margin-bottom: 10px; color: #999c98; font-size: 24px; }
.empty-state p { margin-bottom: 0; }
#results.loading { opacity: .55; }
.recipe-entry { margin-bottom: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.entry-header { padding: 18px 20px; display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.entry-identity h3 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 19px; font-weight: 600; }
.entry-description { max-width: 760px; margin: 5px 0 0; color: var(--muted); font-family: Georgia, "Times New Roman", serif; font-size: 12px; font-style: italic; }
.entry-actions { display: flex; gap: 7px; flex-shrink: 0; }
.icon-button { min-height: 29px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: transparent; font-size: 9px; font-weight: 750; text-transform: uppercase; text-decoration: none; }
.icon-button:hover { color: var(--ink); border-color: #aeb2ac; background: var(--paper); }
.icon-button.delete:hover { color: var(--error); border-color: #d8aaa4; background: var(--error-bg); }
.photo-button { width: 29px; min-height: 29px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 5px; color: var(--accent-dark); background: var(--top); font-size: 15px; line-height: 1; text-decoration: none; }
.photo-button:hover { border-color: var(--accent); background: var(--surface); }
.print-button { width: 31px; display: grid; place-items: center; padding: 4px; font-size: 14px; }
.entry-coat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.entry-coat { min-height: 145px; padding: 20px; }
.entry-coat + .entry-coat { border-left: 1px solid rgba(72, 72, 68, .12); }
.bottom-entry { color: #312e2a; background: var(--bottom); }
.top-entry { color: #3e403e; background: var(--top); }
.entry-coat-heading { margin-bottom: 13px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.entry-coat h3 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 14px; font-weight: 650; }
.glaze-name { margin-bottom: 3px; font-size: 13px; font-weight: 800; }
.coat-count { margin-bottom: 12px; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
.coat-notes { margin-bottom: 0; white-space: pre-wrap; font-size: 11px; }
.fired-result { min-height: 49px; padding: 9px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line); background: var(--surface); }
.fired-result strong { font-family: Georgia, "Times New Roman", serif; font-size: 13px; }
.export-button { display: inline-grid; place-items: center; white-space: nowrap; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; }
.page-button { min-width: 33px; min-height: 33px; padding: 5px 9px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: var(--surface); font-size: 10px; }
.page-button.current { color: white; border-color: var(--accent-dark); background: var(--accent-dark); }

.documentation { max-width: 760px; margin: 0 auto; padding: 64px 0 82px; }
.documentation > section { margin: 34px 0; padding-top: 28px; border-top: 1px solid var(--line); }
.documentation section p { color: var(--muted); }
.action-guide { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.action-guide div { padding: 16px; border-radius: 8px; background: var(--top); }
.action-guide dt { font-weight: 800; }
.action-guide dd { margin: 4px 0 0; color: var(--muted); }

.admin-page { max-width: 860px; }
.admin-notice { margin-top: 26px; }
.admin-grid { margin-top: 30px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.documentation .admin-panel { margin: 30px 0 0; padding: 24px; border-top: 1px solid var(--line); }
.admin-grid .admin-panel { margin: 0; }
.admin-panel h2 { margin-bottom: 10px; font-size: 21px; }
.admin-panel label { margin: 18px 0; display: grid; gap: 7px; color: #4d514f; font-size: 10px; font-weight: 750; letter-spacing: .035em; text-transform: uppercase; }
.admin-panel code { padding: 2px 5px; border-radius: 4px; background: var(--stone); }
.admin-action { display: inline-grid; place-items: center; }
.admin-panel .restore-confirm { grid-template-columns: auto 1fr; align-items: start; text-transform: none; letter-spacing: 0; font-weight: 600; }
.restore-confirm input { width: 16px; min-height: 16px; margin: 2px 0 0; }
.admin-logout { margin-top: 22px; text-align: right; }

.site-footer { border-top: 1px solid var(--line); color: var(--muted); background: var(--stone); font-size: 9px; }
.footer-inner { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 22px; }
.footer-inner p { margin: 0; }
.footer-inner a { margin-left: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 800px) {
    .page-shell { width: min(100% - 32px, 680px); }
    .journal-heading { padding-top: 40px; align-items: stretch; flex-direction: column; gap: 24px; }
    .status-bar { min-width: 0; width: 100%; }
    .identity-grid, .coat-grid { grid-template-columns: 1fr; }
    .entry-coat-grid { grid-template-columns: 1fr; }
    .entry-coat + .entry-coat { border-top: 1px solid rgba(72, 72, 68, .12); border-left: 0; }
    .recipe-form-panel { padding: 20px; }
    .admin-grid { grid-template-columns: 1fr; }
    .build-label { display: none; }
}

@media (max-width: 540px) {
    :root { font-size: 14px; }
    .page-shell { width: min(100% - 24px, 500px); }
    .header-inner { min-height: 62px; }
    .brand small { display: none; }
    nav { gap: 14px; }
    .journal-heading { padding: 32px 0 24px; }
    h1 { font-size: 32px; }
    .status-bar { grid-template-columns: .65fr 1.5fr .65fr; padding-inline: 10px; }
    .status-bar div + div { padding-left: 9px; }
    .status-bar dd { font-size: 11px; }
    .notice { align-items: flex-start; flex-direction: column; }
    .recipe-form-panel { padding: 16px; }
    .coat-section { padding: 16px; grid-template-columns: 1fr; }
    .coat-section label { grid-column: 1 / -1; }
    .recipe-form .coat-checkbox { width: 42px; height: 42px; }
    .coat-section legend { align-items: start; flex-direction: column; gap: 2px; }
    .form-footer { align-items: stretch; flex-direction: column; }
    .form-actions { flex-direction: column-reverse; }
    .fired-photo { width: 100%; }
    .button { min-height: 42px; }
    .search-section { padding: 42px 0 54px; }
    .search-toolbar { grid-template-columns: 1fr 1fr; }
    .search-field { grid-column: 1 / -1; }
    .export-button { grid-column: 1 / -1; }
    .action-guide { grid-template-columns: 1fr; }
    .entry-header { padding: 16px; align-items: stretch; flex-direction: column; gap: 13px; }
    .entry-actions { width: 100%; }
    .icon-button { min-height: 40px; flex: 1; }
    .photo-button { width: 40px; min-height: 40px; flex: 0 0 40px; }
    .print-button { width: auto; min-height: 40px; flex: 0 0 44px; }
    .entry-coat { min-height: 0; padding: 17px 16px; }
    .pagination { flex-wrap: wrap; }
    .footer-inner { padding-block: 18px; align-items: flex-start; flex-direction: column; gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
