:root {
  --bg: #f6f4f0; --panel: #fff; --ink: #24201c; --muted: #6f665c; --rule: #e4ddd2;
  --accent: #7a3b2e; --accent-ink: #fff; --accent-soft: #f4e9e3; --danger: #b3261e; --ok: #2e6b3a;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: var(--accent); }

.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 0.75rem 1.5rem; background: var(--panel); border-bottom: 1px solid var(--rule);
}
.brand { font: 600 1.15rem var(--serif); color: var(--ink); text-decoration: none; }
.brand span { font: 500 0.75rem var(--sans); color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; margin-left: 0.4rem; }
.who { display: flex; gap: 1.25rem; align-items: center; color: var(--muted); font-size: 0.85rem; }

.shell { display: grid; grid-template-columns: 13rem 1fr; min-height: calc(100vh - 3.2rem); }
.side { padding: 1.25rem 0.75rem; border-right: 1px solid var(--rule); background: var(--panel); }
.side a { display: block; padding: 0.5rem 0.75rem; border-radius: 6px; color: var(--ink); text-decoration: none; margin-bottom: 2px; }
.side a:hover { background: var(--bg); }
.side a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.main { padding: 1.75rem 2rem 4rem; max-width: 60rem; width: 100%; }

.head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
h1 { font: 600 1.6rem var(--serif); margin: 0; }
.crumb { font-size: 0.85rem; margin-bottom: 0.5rem; display: inline-block; }
.muted { color: var(--muted); }
.help { color: var(--muted); font-size: 0.85rem; margin: 0.25rem 0 0; }

.btn {
  display: inline-flex; align-items: center; gap: 0.35rem; font: 500 0.9rem var(--sans);
  padding: 0.5rem 1rem; border-radius: 6px; border: 1px solid var(--rule); background: var(--panel);
  color: var(--ink); cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.small { padding: 0.25rem 0.55rem; font-size: 0.8rem; }

.card { background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; }
table.list { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.list th, .list td { text-align: left; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.list th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; background: #faf8f5; }
.list tr:last-child td { border-bottom: 0; }
.list td a.title { font-weight: 600; color: var(--ink); text-decoration: none; }
.list td a.title:hover { color: var(--accent); }
.list .actions { white-space: nowrap; text-align: right; }
.list .actions .btn { margin-left: 0.25rem; }
.pill { display: inline-block; font-size: 0.75rem; padding: 0.1rem 0.55rem; border-radius: 999px; background: var(--bg); color: var(--muted); }
.pill.published, .pill.shown { background: #e5f1e7; color: var(--ok); }

form.edit { display: grid; gap: 1.1rem; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
.row3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 1.1rem; }
label.f { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 0.35rem; }
input[type=text], input[type=url], input[type=date], select, textarea {
  width: 100%; font: 15px/1.45 var(--sans); padding: 0.55rem 0.7rem; color: var(--ink);
  border: 1px solid var(--rule); border-radius: 6px; background: var(--panel);
}
input.big { font: 600 1.35rem var(--serif); padding: 0.6rem 0.75rem; }
textarea { min-height: 5rem; resize: vertical; }
input:focus, select:focus, textarea:focus, .editor .content:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
.slug { display: flex; align-items: center; border: 1px solid var(--rule); border-radius: 6px; background: var(--panel); overflow: hidden; }
.slug span { padding: 0 0.1rem 0 0.7rem; color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
.slug input { border: 0; padding-left: 0; }
.slug input:focus { outline: 0; }
.bar { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; padding-top: 0.5rem; }
.bar .spacer { flex: 1; }

/* Rich text editor */
.editor { border: 1px solid var(--rule); border-radius: 8px; background: var(--panel); }
.toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 0.4rem; border-bottom: 1px solid var(--rule); background: #faf8f5; border-radius: 8px 8px 0 0; position: sticky; top: 0; z-index: 2; }
.toolbar button { font: 500 0.85rem var(--sans); min-width: 2rem; padding: 0.3rem 0.5rem; border: 1px solid transparent; border-radius: 5px; background: none; color: var(--ink); cursor: pointer; }
.toolbar button:hover { background: var(--panel); border-color: var(--rule); }
.toolbar .sep { width: 1px; background: var(--rule); margin: 0.2rem 0.3rem; }
.editor .content {
  min-height: 18rem; padding: 1rem 1.25rem; font: 1.1rem/1.7 var(--serif); border-radius: 0 0 8px 8px;
}
.editor.short .content { min-height: 8rem; }
.content h2 { font-size: 1.4rem; margin: 1.5rem 0 0.5rem; }
.content h3 { font-size: 1.15rem; margin: 1.25rem 0 0.4rem; }
.content p { margin: 0 0 0.9rem; }
.content blockquote { margin: 1rem 0; padding-left: 1rem; border-left: 3px solid var(--accent); color: var(--muted); font-style: italic; }
.content a { color: var(--accent); }

#toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(150%);
  background: var(--ink); color: #fff; padding: 0.7rem 1.1rem; border-radius: 8px; font-size: 0.9rem;
  transition: transform 0.2s, visibility 0.2s; max-width: 90vw; z-index: 40; visibility: hidden;
}
#toast.show { transform: translateX(-50%) translateY(0); visibility: visible; }
#toast.error { background: var(--danger); }

@media (max-width: 52rem) {
  .shell { grid-template-columns: 1fr; }
  .side { display: flex; gap: 0.25rem; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--rule); padding: 0.5rem; }
  .side a { white-space: nowrap; }
  .main { padding: 1.25rem 1rem 3rem; }
  .row, .row3 { grid-template-columns: 1fr; }
  .list .hide-sm { display: none; }
}

/* Sign-in pages */
form.inline { display: inline; margin: 0; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }
body.auth { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; padding: 1.5rem; }
.auth-box { width: 100%; max-width: 24rem; padding: 1.75rem 1.75rem 2rem; }
.auth-box .brand { margin: 0 0 1.25rem; }
.auth-box h1 { font-size: 1.4rem; margin-bottom: 1rem; }
.auth-box .btn { width: 100%; justify-content: center; padding: 0.65rem 1rem; }
input[type=email], input[type=password] {
  width: 100%; font: 15px/1.45 var(--sans); padding: 0.55rem 0.7rem; color: var(--ink);
  border: 1px solid var(--rule); border-radius: 6px; background: var(--panel);
}
input[type=email]:focus, input[type=password]:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.msg { background: #fbeaea; color: var(--danger); padding: 0.6rem 0.8rem; border-radius: 6px; font-size: 0.9rem; }
.auth-foot { font-size: 0.85rem; margin-top: 1rem; }

/* ---- Preview, pictures, design ---- */
.pill.scheduled { background: #e8eef9; color: #2c4f8a; }
input[type=number] { width: 100%; font: 15px/1.45 var(--sans); padding: 0.55rem 0.7rem; border: 1px solid var(--rule); border-radius: 6px; background: var(--panel); color: var(--ink); }
h2.sub { font: 600 1.1rem var(--serif); margin: 0 0 1rem; }
.upload { cursor: pointer; }
.upload.busy { opacity: 0.7; pointer-events: none; }
body.no-scroll { overflow: hidden; }

.modal { position: fixed; inset: 0; z-index: 30; background: rgba(20, 16, 12, 0.55); display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.modal-box { background: var(--panel); border-radius: 12px; width: 100%; max-width: 46rem; max-height: calc(100vh - 3rem); overflow: auto; padding: 1.25rem 1.4rem 1.5rem; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
.modal-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.modal-head h2 { font: 600 1.25rem var(--serif); margin: 0; flex: 1; }
.preview-modal .modal-head h2 { flex: 0 0 auto; }
.modal-head .spacer { flex: 1; }
.preview-modal .modal-box { max-width: 84rem; height: calc(100vh - 3rem); display: flex; flex-direction: column; padding: 0.9rem 1rem 1rem; }
.frame-wrap { flex: 1; background: #e9e5df; border-radius: 8px; display: flex; justify-content: center; overflow: hidden; }
.frame-wrap iframe { width: 100%; height: 100%; border: 0; background: #fff; transition: width 0.2s; }
.frame-wrap iframe.phone { width: 390px; border-left: 1px solid var(--rule); border-right: 1px solid var(--rule); }

.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; }
.seg button, .seg label { font: 500 0.85rem var(--sans); padding: 0.35rem 0.8rem; background: var(--panel); border: 0; cursor: pointer; display: flex; align-items: center; gap: 0.35rem; }
.seg button + button, .seg label + label { border-left: 1px solid var(--rule); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 0.75rem; margin-top: 1rem; }
.thumb { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.5rem; border: 1px solid var(--rule); border-radius: 8px; background: var(--panel); text-align: left; font: inherit; color: var(--ink); min-width: 0; }
.thumb img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 5px; background: #f0ece6; display: block; }
.thumb span { font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb small { font-size: 0.75rem; }
.picker .thumb { cursor: pointer; }
.picker .thumb:hover { border-color: var(--accent); }
.chosen img { max-height: 12rem; max-width: 100%; border-radius: 6px; display: block; }

.imgfield { display: flex; gap: 1rem; align-items: center; }
.imgfield img, .imgfield .noimg { width: 6rem; height: 6rem; object-fit: contain; border: 1px solid var(--rule); border-radius: 6px; background: #f6f3ee; }
.imgfield .noimg { display: flex; align-items: center; justify-content: center; font-size: 0.75rem; color: var(--muted); }
.imgfield .btn { margin: 0 0.3rem 0.3rem 0; }
img.mini { width: 2.25rem; height: 3rem; object-fit: cover; border-radius: 3px; display: block; }

.colorpick { display: flex; align-items: center; gap: 0.6rem; }
.colorpick input[type=color] { width: 3rem; height: 2.4rem; padding: 0.15rem; border: 1px solid var(--rule); border-radius: 6px; background: var(--panel); cursor: pointer; }
.sample { margin: 0.6rem 0 0; font-size: 1.35rem; line-height: 1.3; padding: 0.6rem 0.8rem; background: #faf8f5; border-radius: 6px; }
.sample.small { font-size: 1.05rem; line-height: 1.6; }

.content figure { margin: 1rem 0; }
.content figure img, .content img { max-width: 100%; height: auto; border-radius: 4px; display: block; }
.content figure.img-small img { max-width: 50%; }
.content figure.img-medium img { max-width: 75%; }
.content figcaption { font: 0.85rem var(--sans); color: var(--muted); margin-top: 0.4rem; }
[hidden] { display: none !important; }
