:root {
  --petrol: #0f6f7a;
  --ink: #0d2226;
  --muted: #586d71;
  --line: #dfe8ea;
  --sand: #f4f8f8;
  --gold: #ffd701;
  --white: #fff;
  --ok: #1f7a52;
  --warn: #8a4b12;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, "Segoe UI", Arial, sans-serif; color: var(--ink); background: var(--sand); font-size: 1.05rem; line-height: 1.5; }
.top { display: flex; gap: 1.2rem; align-items: center; justify-content: space-between; padding: .8rem 1.2rem; background: var(--petrol); color: #fff; flex-wrap: wrap; }
.top a { color: #fff; text-decoration: none; font-weight: 650; }
.top nav { display: flex; gap: .9rem; flex-wrap: wrap; }
.brand { font-size: 1.15rem; }
main { padding: 1.2rem; max-width: 1180px; margin: 0 auto; }
h1 { font-size: 1.8rem; margin: 0 0 .4rem; }
h2 { font-size: 1.2rem; }
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 650; margin: .7rem 0; }
input, textarea, select { font: inherit; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); width: 100%; }
textarea { resize: vertical; }
.btn, button.btn { background: var(--gold); color: var(--ink); border: 0; border-radius: 999px; padding: .75rem 1.1rem; font: inherit; font-weight: 750; cursor: pointer; }
.btn--ghost { background: #fff; border: 1px solid var(--line); }
.btn--danger { background: #9c2f2f; color: #fff; }
.bar, .stack, .tools, .filters { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.bar { justify-content: space-between; margin-bottom: 1rem; }
.filters input, .filters select { width: auto; }
.card, .grid, .block, .topics article { background: #fff; border-radius: 16px; box-shadow: 0 8px 24px rgba(8,63,70,.06); }
.card { padding: 1rem 1.1rem; margin: .8rem 0; }
.narrow { max-width: 460px; margin: 8vh auto; }
.grid { width: 100%; border-collapse: collapse; overflow: hidden; }
.grid th, .grid td { text-align: left; padding: .75rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid a { color: var(--petrol); }
.muted { color: var(--muted); font-weight: 500; }
.alert { background: #fff4e5; color: var(--warn); padding: .7rem .9rem; border-radius: 10px; }
.ok { background: #e7f6ee; color: var(--ok); padding: .7rem .9rem; border-radius: 10px; }
.check { flex-direction: row; align-items: center; font-weight: 550; }
.check input { width: auto; }
.split, .editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1rem; align-items: start; }
.editor-grid > div:first-child { overflow: hidden; }
.editor-grid > aside { position: relative; z-index: 1; }
img { max-width: 100%; }
#cover-preview { max-width: 100%; overflow: hidden; border-radius: 12px; }
.block img, .cover-box img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 240px;
  object-fit: cover;
  border-radius: 12px;
}
.cover-box .tools { margin: .2rem 0 .4rem; }
.cover-upload { position: relative; overflow: hidden; cursor: pointer; }
.cover-upload input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.block { padding: .7rem .8rem; margin: .6rem 0; }
.block header { display: flex; justify-content: space-between; gap: .5rem; color: var(--muted); font-size: .92rem; }
.block-actions, .rewrite, .addblock { display: flex; flex-wrap: wrap; gap: .35rem; }
.block-actions button, .rewrite button, .addblock button, .linkish, .topics button { background: var(--sand); border: 0; border-radius: 999px; padding: .35rem .7rem; font: inherit; cursor: pointer; }
.side-extra { max-width: 320px; margin-left: auto; }
label.btn { width: auto; display: inline-flex; align-items: center; cursor: pointer; margin: 0; }
.addblock { margin: 1rem 0 2rem; }
.topics { display: grid; gap: .7rem; margin: .8rem 0; }
.topics article { padding: .8rem 1rem; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .7rem; margin: 1rem 0; }
.stats div { background: #fff; border-radius: 14px; padding: .9rem; }
.stats b { display: block; font-size: 1.35rem; }
.revs form { display: inline; }
#preview-wrap { position: fixed; inset: 0; background: rgba(5,46,51,.45); z-index: 20; display: flex; flex-direction: column; padding: 1rem; }
#preview-wrap[hidden] { display: none; }
.preview-bar { display: flex; justify-content: space-between; color: #fff; margin-bottom: .5rem; }
#preview-frame { flex: 1; border: 0; background: #fff; margin: 0 auto; border-radius: 12px; }
#image-modal { position: fixed; inset: 0; background: rgba(5,46,51,.45); z-index: 30; display: grid; place-items: center; padding: 1rem; }
#image-modal[hidden] { display: none; }
.modal { background: #fff; border-radius: 18px; padding: 1rem 1.1rem; width: min(560px, 100%); }
.plain { padding-left: 1.1rem; }
code { background: #fff; padding: .15rem .35rem; border-radius: 6px; }
body:has(#workbar) { padding-bottom: 92px; }
.workbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .85rem 1.2rem; background: #fff; border-top: 4px solid var(--line); box-shadow: 0 -10px 28px rgba(8,63,70,.12); }
.workbar__text { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.workbar strong { display: block; font-size: 1rem; }
.workbar span { color: var(--muted); }
.workbar.is-dirty { background: #fff8d6; border-top-color: var(--gold); }
.workbar.is-dirty span { color: #6a5200; font-weight: 700; }
.workbar.is-saving { background: #e7f3f5; border-top-color: var(--petrol); }
.workbar.is-saving span { color: var(--petrol); font-weight: 700; }
.workbar.is-saved { background: #e7f6ee; border-top-color: var(--ok); }
.workbar.is-saved span { color: var(--ok); font-weight: 750; }
.workbar.is-error { background: #fdecec; border-top-color: #9c2f2f; }
.workbar.is-error span { color: #9c2f2f; font-weight: 700; }
.workbar .btn { min-width: 11rem; }
.workbar .btn:disabled { opacity: .7; cursor: progress; }
.spin { width: 18px; height: 18px; border: 3px solid #d7e4e6; border-top-color: var(--petrol); border-radius: 50%; animation: spin .7s linear infinite; flex: 0 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 700px) {
  .workbar { align-items: stretch; flex-direction: column; }
  .workbar .btn { width: 100%; }
}
  .split, .editor-grid, .stats { grid-template-columns: 1fr; }
  .side-extra { max-width: none; margin-left: 0; }
}
