:root { --ink: #1e1913; --bronze: #9a682c; --bronze-d: #7d5222; --cream: #f5efe3; --paper: #fffdf9; --line: #ded2bd; --muted: #6a5d4f; --text: #2a231b; --ok: #3f6b5e; --err: #a2351f; }
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Switzer', 'Helvetica Neue', Arial, sans-serif; font-size: 15px; line-height: 1.5; color: var(--text); background: var(--cream); }
h1, h2 { font-family: 'Gambetta', Georgia, serif; font-weight: 500; color: var(--ink); margin: 0 0 .4rem; }
h2 { font-size: 1.5rem; }
.muted { color: var(--muted); margin: 0 0 1rem; }
[hidden] { display: none !important; }
label { display: grid; gap: .3rem; font-weight: 500; font-size: 14px; }
input, textarea { font: inherit; font-size: 15px; color: var(--text); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .65rem .75rem; width: 100%; }
textarea { resize: vertical; min-height: 90px; }
input:focus, textarea:focus { outline: 2px solid var(--bronze); outline-offset: 0; border-color: var(--bronze); }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: .5rem 1rem; border-radius: 999px; border: 1px solid transparent; font: 600 14px/1 inherit; font-family: inherit; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--bronze); color: #fff; }
.btn.primary:hover { background: var(--bronze-d); }
.btn.primary:disabled { opacity: .6; cursor: wait; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { border-color: var(--bronze); }
.btn.ghost.light { color: #fff; border-color: rgba(255,255,255,.35); }
.btn.small { min-height: 32px; padding: .35rem .8rem; font-size: 13px; }
.btn.danger { color: var(--err); border-color: #e3c2b8; background: #fff; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: radial-gradient(800px 400px at 50% 0%, rgba(154,104,44,.25), transparent 60%), var(--ink); }
.login-card { width: min(100%, 400px); background: var(--paper); border-radius: 14px; padding: 2rem; display: grid; gap: 1rem; text-align: center; box-shadow: 0 30px 80px -30px rgba(0,0,0,.6); }
.login-card img { margin: 0 auto; }
.login-card label { text-align: left; }
.login-card h1 { font-size: 1.9rem; margin: 0; }
.login-card .muted { margin: -.6rem 0 .5rem; }
.err { color: var(--err); font-weight: 600; margin: 0; min-height: 1.2em; font-size: 14px; }
.back { color: var(--muted); font-size: 13px; }

.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem; padding: .6rem 1.25rem; background: var(--ink); color: #f3eadb; flex-wrap: wrap; }
.top-brand { display: flex; align-items: center; gap: .6rem; font-family: 'Gambetta', Georgia, serif; font-size: 1.2rem; margin-right: auto; }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.tabs button { background: transparent; border: 0; color: #cbbca6; font: 500 14px inherit; font-family: inherit; padding: .55rem .8rem; border-radius: 6px; cursor: pointer; }
.tabs button[aria-selected="true"] { color: #fff; background: rgba(210,164,106,.18); }
.count { display: inline-block; min-width: 1.3em; padding: 0 .35em; border-radius: 999px; background: var(--bronze); color: #fff; font-size: 12px; }
.count:empty { display: none; }
.top-actions { display: flex; gap: .5rem; }
.top-actions .btn { color: #f3eadb; border-color: rgba(243,234,219,.3); }

.main { padding: 1.5rem 1.25rem 7rem; max-width: 1280px; margin: 0 auto; }
.edit-layout { display: grid; grid-template-columns: 250px 1fr; gap: 1.5rem; align-items: start; }
.page-list { position: sticky; top: 76px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; max-height: calc(100vh - 100px); overflow: auto; }
.page-list h2 { font-size: 1.1rem; }
.page-list ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.page-list button { width: 100%; text-align: left; background: transparent; border: 0; padding: .55rem .7rem; border-radius: 6px; font: inherit; font-size: 14px; cursor: pointer; color: var(--text); display: flex; justify-content: space-between; gap: .5rem; }
.page-list button:hover { background: var(--cream); }
.page-list button[aria-current="true"] { background: var(--ink); color: #fff; }
.page-list .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bronze); align-self: center; }

.editor { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 1.5rem; min-width: 0; }
.editor-head { display: flex; justify-content: space-between; gap: 1rem; align-items: start; border-bottom: 1px solid var(--line); padding-bottom: 1rem; margin-bottom: 1.25rem; }
.field { padding: 1rem 0; border-bottom: 1px solid #efe6d6; display: grid; gap: .45rem; }
.field-top { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.field-label { font-weight: 600; font-size: 14px; }
.field-key { font-size: 12px; color: #9a8c79; }
.field.changed { background: linear-gradient(90deg, rgba(154,104,44,.08), transparent); margin: 0 -1.5rem; padding-inline: 1.5rem; }
.badge { font-size: 12px; font-weight: 600; color: var(--bronze-d); }
.linkbtn { background: none; border: 0; color: var(--bronze-d); font: inherit; font-size: 13px; cursor: pointer; text-decoration: underline; padding: 0; }
.img-field { display: grid; grid-template-columns: 160px 1fr; gap: 1rem; align-items: start; }
.img-field img { width: 160px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--cream); }
.img-actions { display: grid; gap: .6rem; }
.img-actions .row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.group-h { margin: 2rem 0 .25rem; font-size: 1.15rem; }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.chars { font-size: 12px; color: #9a8c79; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 1.5rem; }
.panel.narrow { max-width: 640px; }
.stack { display: grid; gap: 1rem; max-width: 420px; }
.note { margin: 0; font-weight: 600; }
.note.ok { color: var(--ok); } .note.err { color: var(--err); }
.msg { border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.1rem; margin-bottom: .8rem; background: #fff; }
.msg-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .4rem; }
.msg-head strong { font-size: 16px; }
.msg dl { display: grid; grid-template-columns: max-content 1fr; gap: .2rem .9rem; margin: .5rem 0; font-size: 14px; }
.msg dt { color: var(--muted); }
.msg dd { margin: 0; }
.msg p { white-space: pre-wrap; margin: .6rem 0; }
.hist { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .8rem 0; border-bottom: 1px solid #efe6d6; }
.empty { color: var(--muted); padding: 1.5rem 0; }
.prose li { margin-bottom: .5rem; }

.savebar { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 20; background: var(--ink); color: #fff; border-radius: 999px; padding: .5rem .5rem .5rem 1.25rem; display: flex; align-items: center; gap: .75rem; box-shadow: 0 20px 50px -15px rgba(0,0,0,.6); }
.toast { position: fixed; right: 1.25rem; bottom: 5.5rem; background: var(--ok); color: #fff; padding: .75rem 1rem; border-radius: 8px; font-weight: 600; opacity: 0; transform: translateY(10px); transition: .25s; pointer-events: none; z-index: 30; }
.toast.show { opacity: 1; transform: none; }
.toast.err { background: var(--err); }

@media (max-width: 860px) {
  .edit-layout { grid-template-columns: 1fr; }
  .page-list { position: static; max-height: none; }
  .page-list ul { grid-template-columns: 1fr 1fr; }
  .img-field { grid-template-columns: 1fr; }
  .top-actions { width: 100%; }
  .savebar { width: calc(100% - 1.5rem); justify-content: flex-end; border-radius: 14px; }
  .savebar span { margin-right: auto; font-size: 13px; }
}
