:root { --bg:#f7f4ef; --card:#fff; --ink:#1c1a18; --muted:#6b655d; --line:#e4ded4; --accent:#9a4a2c; --ok:#2f6b3a; --err:#a12a2a; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; padding-bottom: 90px; }
a { color: var(--accent); }
h1 { font: 500 34px/1.15 Georgia, serif; margin: 8px 0 16px; }
h2 { font: 500 24px Georgia, serif; margin: 32px 0 10px; }
h3 { margin: 10px 0; font-size: 16px; }
.muted { color: var(--muted); } .small { font-size: 13px; }

.top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.logo { font: 600 18px Georgia, serif; color: var(--ink); text-decoration: none; }
.logo span { font: 500 11px system-ui; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin-left: 4px; }
.logo.big { font-size: 26px; }
.top nav { display: flex; flex-wrap: wrap; gap: 4px 14px; flex: 1; }
.top nav a { color: var(--ink); text-decoration: none; font-size: 14px; padding: 4px 0; }
.top nav a:hover { color: var(--accent); }
.logout { margin-left: auto; }

.page { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }
.narrow { max-width: 460px; margin: 0 auto; padding: 48px 20px; }
.center { text-align: center; }
.center .field { text-align: left; }

.btn, button { font: inherit; cursor: pointer; }
.btn { display: inline-block; background: var(--ink); color: #fff; border: 1px solid var(--ink); border-radius: 999px; padding: 11px 22px; font-size: 15px; text-decoration: none; }
.btn:hover { background: var(--accent); border-color: var(--accent); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.wide { width: 100%; padding: 15px; font-size: 17px; margin-top: 8px; }
.btn:disabled { opacity: .55; cursor: wait; }
button.small { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; font-size: 13px; color: var(--ink); }
button.small:hover:not(:disabled) { border-color: var(--ink); }
button.small:disabled { opacity: .35; cursor: default; }
button.danger { color: var(--err); }
button.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 0; font-size: 14px; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; background: #e8f1e9; color: var(--ok); }
.flash.error { background: #f6e4e2; color: var(--err); }
.notice { background: #fbf0d9; border: 1px solid #ecd7a8; padding: 12px 16px; border-radius: 8px; }
.status { min-height: 1.5em; margin-top: 14px; }
.status.error { color: var(--err); }
.badge { display: inline-block; background: var(--accent); color: #fff; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; }

.form fieldset { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 16px 18px 6px; margin: 0 0 18px; }
.form legend { font-weight: 600; padding: 0 6px; }
.field { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.field input:not([type=file]), .field textarea, .field select { display: block; width: 100%; margin-top: 4px; font: 16px/1.4 system-ui, sans-serif; color: var(--ink); padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.field input[type=file] { display: block; margin-top: 6px; font-size: 15px; }
.field.inline select { width: auto; display: inline-block; margin-left: 8px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.row2 { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; }
.actions { margin: 10px 0 20px; }
.sticky-save { position: sticky; bottom: 76px; text-align: right; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
details.add { padding: 14px 18px; margin-bottom: 20px; }
details.add summary { cursor: pointer; font-weight: 600; color: var(--accent); }
details.add .form { margin-top: 14px; }

.works { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.work { display: grid; grid-template-columns: 150px 1fr; gap: 16px; padding: 12px; scroll-margin-top: 90px; }
.work img { width: 150px; height: 150px; object-fit: contain; background: #f1ede6; border-radius: 6px; }
.work .field { margin-bottom: 8px; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tools form { margin: 0; }
.replace summary { cursor: pointer; font-size: 13px; color: var(--accent); margin: 4px 0; }
.replace form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
.del { margin-top: 6px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-top: 18px; }
.tile { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; text-decoration: none; color: var(--ink); }
.tile img { width: 100%; height: 130px; object-fit: cover; }
.tile span { padding: 12px 14px; display: flex; flex-direction: column; }
.tile small { color: var(--muted); }
.tile.text { justify-content: center; min-height: 90px; }
.tile:hover { border-color: var(--ink); }

.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.slot { padding: 12px; }
.slot img { width: 100%; height: 200px; object-fit: contain; background: #f1ede6; border-radius: 6px; }
.slot form { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

.table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 10px; overflow: hidden; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.table form { margin: 0; }
.nowrap { white-space: nowrap; }
.hist { padding-left: 18px; } .hist li { margin: 4px 0; }

.publishbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px; background: rgba(255,255,255,.95); border-top: 1px solid var(--line); z-index: 20; }
.publishbar form { margin: 0; }

@media (max-width: 640px) {
  h1 { font-size: 28px; }
  .work { grid-template-columns: 90px 1fr; gap: 12px; }
  .work img { width: 90px; height: 90px; }
  .row2 { grid-template-columns: 1fr; }
  .table th:nth-child(3), .table td:nth-child(3) { display: none; }
  .publishbar { justify-content: stretch; } .publishbar form { flex: 1; } .publishbar .btn { width: 100%; }
}
@media (max-width: 720px) {
  .top { gap: 6px 12px; padding: 10px 14px; }
  .top nav { order: 3; width: 100%; flex: none; flex-wrap: nowrap; overflow-x: auto; gap: 16px; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .top nav a { white-space: nowrap; }
}
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 28px 0 18px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.pwform { text-align: left; }
