:root {
  --paper: #f4efe5;
  --paper-deep: #ebe3d4;
  --ink: #17261e;
  --muted: #6d746e;
  --line: #d6cebf;
  --accent: #da562f;
  --accent-dark: #b43e20;
  --green: #2e6b4d;
  --white: #fffdf8;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Manrope", system-ui, sans-serif;
  --mono: "DM Mono", monospace;
}

* { box-sizing: border-box; }
html { height: 100%; }
body { margin: 0; min-height: 100%; color: var(--ink); background: var(--paper); font-family: var(--sans); }
button, input, textarea { font: inherit; }
button { color: inherit; }

.topbar { height: 76px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 30px; background: rgba(244,239,229,.94); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; font: 25px/1 var(--serif); }
.brand em { color: var(--accent); font-weight: 400; }
.brand-mark { display: grid; place-items: center; width: 33px; height: 39px; color: var(--paper); background: var(--ink); border-radius: 48% 48% 45% 45%; font: italic 25px var(--serif); transform: rotate(-3deg); }
.top-actions { display: flex; align-items: center; gap: 14px; }
.save-state { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.save-state i { width: 6px; height: 6px; border-radius: 50%; background: #6fa281; }
.icon-button { width: 39px; height: 39px; display: grid; place-items: center; border: 1px solid var(--line); background: transparent; border-radius: 50%; cursor: pointer; }
.icon-button:hover { background: var(--white); }
.icon-button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.publish-button, .primary { border: 0; background: var(--accent); color: white; border-radius: 3px; padding: 12px 17px; font-weight: 700; font-size: 12px; letter-spacing: .02em; cursor: pointer; box-shadow: 0 3px 0 var(--accent-dark); }
.publish-button:hover, .primary:hover { transform: translateY(-1px); }
.publish-button span { margin-left: 8px; }

.workspace { display: grid; grid-template-columns: minmax(300px, 32%) 1fr; min-height: calc(100vh - 76px); }
.metadata-panel { padding: 35px clamp(25px, 4vw, 66px) 70px 36px; border-right: 1px solid var(--line); background: var(--paper-deep); }
.writing-panel { min-width: 0; padding: 35px clamp(24px, 4vw, 64px) 30px; display: flex; flex-direction: column; }
.eyebrow { display: flex; align-items: center; gap: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .16em; font-size: 10px; font-weight: 700; margin-bottom: 34px; }
.eyebrow span { color: var(--accent); }
.field-label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; margin: 26px 0 9px; }
.title-input, .description-input { width: 100%; border: 0; border-bottom: 1px solid var(--ink); border-radius: 0; background: transparent; color: var(--ink); resize: none; outline: 0; padding: 5px 0 10px; }
.title-input { font: 31px/1.08 var(--serif); }
.description-input { font: 14px/1.65 var(--sans); border-bottom-color: var(--line); }
textarea::placeholder, input::placeholder { color: #9b9a91; }
.field-meta, .field-hint { display: flex; justify-content: space-between; color: #86887f; font-size: 9px; line-height: 1.5; margin: 6px 0 0; }
.chip-editor { border-bottom: 1px solid var(--line); padding: 4px 0 9px; }
.chip-editor input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 12px; padding: 5px 0; }
.category-select { width: 100%; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--ink); padding: 8px 24px 10px 0; font-size: 13px; outline: 0; cursor: pointer; }
.category-select:focus { border-bottom-color: var(--accent); }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip { border: 1px solid #bcb8ac; background: rgba(255,255,255,.35); padding: 5px 7px; border-radius: 2px; text-transform: uppercase; letter-spacing: .06em; font-size: 8px; font-weight: 700; }
.chip button { border: 0; background: none; padding: 0 0 0 5px; cursor: pointer; color: var(--muted); }
.field-label-row { display: flex; align-items: baseline; justify-content: space-between; }
.field-label-row button { background: none; border: 0; color: var(--accent); font-size: 10px; cursor: pointer; }
.cover-drop { width: 100%; min-height: 128px; border: 1px dashed #aaa89f; background: rgba(255,255,255,.27); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; position: relative; overflow: hidden; }
.cover-drop:hover { border-color: var(--accent); background: rgba(255,255,255,.5); }
.cover-drop img { position: absolute; width: 100%; height: 100%; object-fit: cover; }
.upload-symbol { font-size: 24px; color: var(--accent); }
.cover-drop strong { font-size: 11px; }
.cover-drop small { font-size: 8px; color: var(--muted); }

.editor-head { display: flex; align-items: flex-start; justify-content: space-between; }
.view-switch { display: flex; border-bottom: 1px solid var(--line); }
.view-switch button { border: 0; background: none; color: var(--muted); padding: 5px 10px 9px; font-size: 10px; text-transform: uppercase; letter-spacing: .09em; cursor: pointer; }
.view-switch button.active { color: var(--ink); border-bottom: 2px solid var(--accent); }
.toolbar { height: 43px; display: flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-bottom: 0; background: rgba(255,255,255,.25); padding: 0 8px; }
.toolbar button { width: 31px; height: 29px; border: 0; background: transparent; border-radius: 2px; cursor: pointer; font-family: var(--serif); font-size: 14px; }
.toolbar button:hover { background: var(--white); color: var(--accent); }
.toolbar > span { width: 1px; height: 18px; background: var(--line); margin: 0 5px; }
.editor-stage { flex: 1; min-height: 580px; border: 1px solid var(--line); background: rgba(255,253,248,.5); display: grid; }
.editor-stage.write-view { grid-template-columns: 1fr; }
.editor-stage.preview-view { grid-template-columns: 1fr; }
.editor-stage.split-view { grid-template-columns: 1fr 1fr; }
.markdown-side, .preview-side { min-width: 0; }
.markdown-side { display: flex; flex-direction: column; }
.preview-side { display: none; padding: 35px 42px; overflow: auto; }
.preview-view .markdown-side { display: none; }
.preview-view .preview-side, .split-view .preview-side { display: block; }
.split-view .preview-side { border-left: 1px solid var(--line); }
#markdown { width: 100%; flex: 1; min-height: 510px; border: 0; outline: 0; resize: none; background: transparent; padding: 38px 42px 20px; color: #26342d; font: 14px/1.85 var(--mono); }
.inline-drop { align-self: center; margin: 5px 0 18px; padding: 9px 16px; border: 1px dashed var(--line); background: transparent; color: var(--muted); font-size: 9px; cursor: pointer; }
.inline-drop.dragging { border-color: var(--accent); color: var(--accent); background: #fff8f2; }
.editor-footer { display: flex; gap: 20px; padding-top: 10px; color: #8a8b83; text-transform: uppercase; letter-spacing: .1em; font-size: 8px; }
.editor-footer .spacer { flex: 1; }

.prose { font: 19px/1.7 var(--serif); color: #243229; }
.prose h1 { font: 44px/1.05 var(--serif); margin: 0 0 25px; }
.prose h2 { font: 32px/1.1 var(--serif); margin: 35px 0 15px; }
.prose h3 { font: 24px/1.2 var(--serif); }
.prose p { margin: 0 0 20px; }
.prose a { color: var(--accent); }
.prose img { max-width: 100%; height: auto; margin: 15px 0; }
.prose blockquote { margin: 25px 0; padding: 3px 0 3px 20px; border-left: 3px solid var(--accent); font-style: italic; color: #56645b; }
.prose pre { background: var(--ink); color: #eff5ed; padding: 18px; overflow: auto; font: 12px/1.6 var(--mono); }
.prose code { font-family: var(--mono); font-size: .75em; background: #e6dfd3; padding: 2px 4px; }
.prose pre code { background: none; padding: 0; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 35px 0; }

dialog { width: min(620px, calc(100% - 30px)); border: 0; padding: 0; background: transparent; color: var(--ink); }
dialog::backdrop { background: rgba(19,30,24,.68); backdrop-filter: blur(3px); }
.dialog-card { background: var(--paper); padding: 42px; position: relative; box-shadow: 0 18px 60px rgba(0,0,0,.25); }
.dialog-close { position: absolute; top: 16px; right: 18px; border: 0; background: none; font-size: 25px; cursor: pointer; }
.dialog-card .eyebrow { margin-bottom: 18px; }
.dialog-card h2 { font: 38px/1.1 var(--serif); margin: 0 0 8px; }
.dialog-card > p, #publishReady > p { color: var(--muted); font-size: 12px; line-height: 1.6; }
.form-grid { display: grid; gap: 15px; margin-top: 18px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.dialog-card label { display: flex; flex-direction: column; gap: 7px; text-transform: uppercase; letter-spacing: .08em; font-size: 9px; font-weight: 700; }
.dialog-card label span { color: var(--muted); font-weight: 400; }
.dialog-card input { border: 1px solid var(--line); background: var(--white); padding: 11px; outline: none; text-transform: none; letter-spacing: normal; font-size: 12px; }
.dialog-card input:focus { border-color: var(--accent); }
.token-field { margin-top: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 25px; }
.secondary { border: 1px solid var(--line); background: transparent; padding: 11px 16px; font-weight: 700; font-size: 11px; cursor: pointer; color: var(--ink); text-decoration: none; }
.publish-summary { display: flex; gap: 15px; padding: 15px; background: var(--paper-deep); margin: 20px 0; }
.summary-cover { width: 90px; height: 70px; flex: 0 0 auto; background: var(--ink); color: var(--paper); display: grid; place-items: center; font: italic 35px var(--serif); background-size: cover; background-position: center; }
.publish-summary strong { font: 22px var(--serif); }
.publish-summary p { margin: 6px 0 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.slug-field { position: relative; }
.slug-field input { width: 100%; padding-right: 42px; font-family: var(--mono); }
.slug-field > span { position: absolute; right: 11px; bottom: 11px; }
.commit-field { margin-top: 16px; }
.destination { font-family: var(--mono); font-size: 9px !important; }
.publishing-state, .success-state { text-align: center; padding: 50px 15px; }
.spinner { width: 46px; height: 46px; margin: 0 auto 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.success-mark { width: 52px; height: 52px; margin: 0 auto 20px; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: white; font-size: 24px; }
.centered { justify-content: center; }
.toast { position: fixed; left: 50%; bottom: 25px; transform: translate(-50%, 20px); background: var(--ink); color: white; padding: 11px 17px; border-radius: 2px; font-size: 11px; opacity: 0; pointer-events: none; transition: .2s; z-index: 100; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .metadata-panel { border-right: 0; border-bottom: 1px solid var(--line); padding: 30px 25px 45px; }
  .writing-panel { padding: 30px 20px; }
  .editor-stage.split-view { grid-template-columns: 1fr; }
  .split-view .preview-side { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 600px) {
  .topbar { height: 64px; padding: 0 14px; }
  .brand { font-size: 20px; }
  .brand-mark { width: 29px; height: 34px; }
  .save-state, .icon-button { display: none; }
  .publish-button { padding: 10px 12px; }
  .workspace { min-height: calc(100vh - 64px); }
  .view-switch button[data-view="split"] { display: none; }
  #markdown, .preview-side { padding: 28px 20px; }
  .form-grid.two { grid-template-columns: 1fr; }
  .dialog-card { padding: 35px 22px 25px; }
}
