/* huoshi editor. Same warm palette as the public site. */
:root {
  --bg: #f6f1e8; --surface: #fffdf9; --ink: #1f1b16; --ink-2: #4a433a; --muted: #7a7064;
  --rule: #e3dacb; --accent: #8a3b22; --accent-ink: #fff; --ok: #2f6b45; --warn: #a26a00; --bad: #b3261e;
  --sans: 'PingFang SC', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
  --serif: 'Songti SC', 'Noto Serif SC', serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14120f; --surface: #1c1915; --ink: #ede6da; --ink-2: #cfc6b8; --muted: #988e80; --rule: #332e27; --accent: #e08a62; --accent-ink: #1a120d; --ok: #7cc495; --warn: #e0b04a; --bad: #f08a80; color-scheme: dark; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; color: var(--muted); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--rule); background: var(--surface); padding: 7px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-danger { color: var(--bad); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-link { border: 0; background: none; padding: 4px 6px; color: var(--accent); cursor: pointer; }

input[type=text], input[type=password], input[type=search], input[type=datetime-local], select, textarea {
  width: 100%; border: 1px solid var(--rule); background: var(--surface); border-radius: 8px; padding: 8px 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 4px; }
.field { margin-bottom: 14px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Login */
.auth { max-width: 380px; margin: 12vh auto; padding: 32px; background: var(--surface); border: 1px solid var(--rule); border-radius: 16px; }
.auth h1 { font: 700 22px/1.3 var(--serif); margin: 0 0 4px; display: flex; align-items: center; gap: 10px; }
.auth h1 img { width: 36px; height: 36px; }
.auth p { color: var(--muted); margin: 0 0 22px; }
.auth .btn { width: 100%; justify-content: center; padding: 10px; }
.err { color: var(--bad); font-size: 14px; min-height: 1.4em; margin: 0 0 10px; }

/* Shell */
.top { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--rule); }
.top-in { max-width: 1320px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 8px; font: 700 17px var(--serif); color: var(--ink); text-decoration: none; }
.brand img { width: 28px; height: 28px; }
.top-sp { flex: 1; }
.build { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }
.dot.bad { background: var(--bad); } .dot.busy { background: var(--warn); }
.who { font-size: 13px; color: var(--ink-2); }
.page { max-width: 1320px; margin: 0 auto; padding: 20px; }

/* List */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin-bottom: 16px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a[aria-current] { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.tabs .n { font-size: 12px; color: var(--muted); margin-left: 4px; }
.tools { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.tools input[type=search] { max-width: 280px; }
.tools select { width: auto; }
.tools .sp { flex: 1; }
.list { background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; }
.item { display: grid; grid-template-columns: 1fr 110px 170px 170px auto; gap: 14px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--rule); }
.item:first-child { border-top: 0; }
.item.head { font-size: 12px; color: var(--muted); background: var(--bg); padding-top: 8px; padding-bottom: 8px; }
.item .t { min-width: 0; }
.item .t a { color: var(--ink); text-decoration: none; font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .t a:hover { color: var(--accent); }
.item .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .note { color: var(--warn); }
.item .c, .item .d { font-size: 13px; color: var(--ink-2); }
.item .acts { display: flex; gap: 2px; justify-content: flex-end; }
.chip { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--bg); border: 1px solid var(--rule); color: var(--ink-2); }
.chip.pub { color: var(--ok); } .chip.sch { color: var(--warn); } .chip.dr { color: var(--muted); }
.empty { padding: 48px; text-align: center; color: var(--muted); }
.more { padding: 12px; text-align: center; }

/* Editor */
.ed-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.ed-bar .sp { flex: 1; }
.ed-status { font-size: 13px; color: var(--muted); }
.ed-status .dirty { color: var(--warn); }
.ed { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; padding: 18px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.title-in { font: 700 20px/1.4 var(--serif) !important; }
.slug { display: flex; align-items: center; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); overflow: hidden; }
.slug span { padding: 8px 0 8px 10px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.slug input { border: 0 !important; padding-left: 2px; }
.cover { display: flex; gap: 12px; align-items: center; }
.cover img { width: 160px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; border: 1px solid var(--rule); background: var(--bg); }
.cover .none { width: 160px; aspect-ratio: 16/9; border-radius: 8px; border: 1px dashed var(--rule); display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.body-head { display: flex; justify-content: space-between; align-items: end; }
textarea.body { min-height: 60vh; font: 15px/1.8 var(--mono); resize: vertical; }
.preview { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow: auto; }
.preview h1.pt { font: 700 26px/1.35 var(--serif); margin: 0 0 8px; }
.pv-meta { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.pv-hint { margin: 0 0 12px; }
.preview [contenteditable="true"] { outline: none; border-radius: 6px; transition: background .15s; }
.preview [contenteditable="true"]:focus { background: color-mix(in srgb, var(--accent) 7%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent); }
.pt:empty::before { content: attr(data-ph); color: var(--muted); }
.blk { position: relative; margin: 0 -10px; padding: 0 10px; border-radius: 8px; }
.blk:hover { background: color-mix(in srgb, var(--ink) 4%, transparent); }
.blk-c { padding: 1px 4px; margin: 0 -4px; }
.blk-c > :first-child { margin-top: 0; }
.blk-c > :last-child { margin-bottom: 0; }
.blk + .blk { margin-top: 1em; }
.blk-del { position: absolute; top: 2px; right: 2px; display: none; font-size: 12px; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--rule); background: var(--surface); color: var(--bad); cursor: pointer; }
.blk:hover .blk-del, .blk:focus-within .blk-del { display: block; }
@media (hover: none) { .blk-del { display: block; opacity: .8; } }
.prose { font: 17px/1.95 var(--serif); }
.prose h2 { font-size: 21px; margin: 1.6em 0 .5em; }
.prose h3 { font-size: 18px; margin: 1.4em 0 .4em; }
.prose blockquote { margin: 1.2em 0; padding: 4px 0 4px 18px; border-left: 3px solid var(--accent); color: var(--ink-2); }
.prose img { max-width: 100%; border-radius: 8px; }
.prose table { border-collapse: collapse; width: 100%; font-size: 15px; }
.prose td, .prose th { border: 1px solid var(--rule); padding: 6px 8px; }
.publish-box { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.publish-box input { width: auto; }

/* Review */
.progress { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: baseline; font-size: 14px; color: var(--ink-2); margin-bottom: 12px; }
.progress b { color: var(--ink); }
.progress .me { color: var(--accent); font-weight: 600; }
.progress-inbox { margin-left: 12px; font-weight: 600; }
.progress-todo { margin-left: auto; color: var(--muted); font-size: 13px; }
.chip.rv-todo { color: var(--warn); } .chip.rv-done { color: var(--ok); } .chip.rv-again { color: var(--bad); }
.rv-bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 16px; background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; }
.rv-left, .rv-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.rv-meta { font-size: 13px; color: var(--muted); }
.rv-bar kbd { font: 11px var(--sans); opacity: .75; margin-left: 4px; }
.warn-banner { padding: 10px 14px; margin-bottom: 12px; border-radius: 10px; background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--ink); font-size: 14px; }

/* Drawer */
.drawer { position: fixed; inset: 0 0 0 auto; width: min(420px, 100%); background: var(--surface); border-left: 1px solid var(--rule); box-shadow: -10px 0 30px rgba(0,0,0,.12); z-index: 20; display: flex; flex-direction: column; }
.drawer header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--rule); }
.drawer h2 { font-size: 16px; margin: 0; }
.drawer .scroll { overflow: auto; padding: 8px 18px 18px; }
.rev { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--rule); font-size: 13px; }
.rev b { font-weight: 600; }
.rev-view { white-space: pre-wrap; font: 13px/1.6 var(--mono); background: var(--bg); padding: 10px; border-radius: 8px; max-height: 40vh; overflow: auto; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 30; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; padding: 22px; max-width: 460px; width: 100%; }
.modal h2 { margin: 0 0 8px; font-size: 17px; }
.modal p { color: var(--ink-2); margin: 0 0 16px; }
.modal .acts { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 40; max-width: calc(100% - 32px); }
#toast.on { opacity: 1; }
#toast.bad { background: var(--bad); color: #fff; }

@media (max-width: 1000px) {
  .ed { grid-template-columns: 1fr; }
  .preview { position: static; max-height: none; }
}
@media (max-width: 760px) {
  .top-in { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
  .build { display: none; }
  .page { padding: 16px; }
  .item { grid-template-columns: 1fr auto; gap: 4px 10px; }
  .item.head { display: none; }
  .item .c, .item .d { grid-column: 1; font-size: 12px; }
  .item .acts { grid-column: 2; grid-row: 1 / span 4; flex-direction: column; }
  .row2 { grid-template-columns: 1fr; }
  .tools input[type=search] { max-width: none; flex: 1 1 100%; }
}
