:root {
  --bg: #0c1213;
  --panel: #11191a;
  --panel-2: #151f20;
  --ink: #ecf0e9;
  --muted: #8c9791;
  --dim: #606c67;
  --line: rgba(222,230,220,.13);
  --accent: #d7a86b;
  --accent-soft: #f1d0a4;
  --green: #79b5a7;
  --red: #e4877c;
  --serif: "Noto Serif SC", "Songti SC", serif;
  --sans: "Noto Sans SC", -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 48px 24px; background: radial-gradient(circle at 20% 0, rgba(121,181,167,.12), transparent 32rem), radial-gradient(circle at 100% 80%, rgba(215,168,107,.08), transparent 34rem); }
.login-card { width: min(560px, 100%); padding: 46px; border: 1px solid var(--line); background: rgba(17,25,26,.9); box-shadow: 0 35px 90px rgba(0,0,0,.35); }
.mini-brand { display: inline-flex; gap: 10px; align-items: center; color: var(--ink); text-decoration: none; font-family: var(--serif); letter-spacing: .12em; }
.mini-brand > span { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid rgba(215,168,107,.6); border-radius: 50%; color: var(--accent-soft); font-size: .85rem; }
.eyebrow { margin: 48px 0 10px; color: var(--green); font-size: .68rem; letter-spacing: .18em; }
.login-card h1 { margin: 0; font-family: var(--serif); font-size: 2.35rem; font-weight: 600; }
.login-intro { margin: 18px 0 32px; color: var(--muted); font-size: .9rem; line-height: 1.9; }
.connect-form { display: grid; gap: 18px; }
.connect-form label, .meta-grid label, .field-block, .status-select { display: grid; gap: 8px; color: var(--muted); font-size: .73rem; }
.repo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.connect-form input, .meta-grid input, .status-select select { width: 100%; border: 1px solid var(--line); border-radius: 3px; outline: 0; padding: 12px 13px; color: var(--ink); background: rgba(255,255,255,.025); transition: border-color .2s; }
.connect-form input:focus, .meta-grid input:focus, .status-select select:focus { border-color: rgba(215,168,107,.65); }
.secret-input { display: flex; }
.secret-input input { border-radius: 3px 0 0 3px; }
.secret-input button { border: 1px solid var(--line); border-left: 0; padding: 0 14px; color: var(--muted); background: rgba(255,255,255,.04); cursor: pointer; }
.privacy-note { margin: -4px 0 0; color: var(--dim); font-size: .7rem; line-height: 1.65; }
.setup-fields { display: grid; gap: 14px; }
.setup-notice { margin: 0; border-left: 2px solid var(--accent); padding: 9px 12px; color: var(--accent-soft); background: rgba(215,168,107,.06); font-size: .74rem; line-height: 1.7; }
.primary-button { height: 50px; display: flex; justify-content: space-between; align-items: center; border: 0; padding: 0 18px; color: #17201e; background: var(--accent-soft); font-weight: 600; cursor: pointer; }
.primary-button:disabled { opacity: .55; cursor: wait; }
.primary-button i { font-style: normal; font-size: 1.2rem; }
.login-card details { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--dim); font-size: .75rem; line-height: 1.8; }
.login-card summary { color: var(--muted); cursor: pointer; }
.login-card code { color: var(--accent-soft); }

.app { min-height: 100vh; display: grid; grid-template-columns: 320px minmax(0,1fr); }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 5; width: 320px; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #0e1516; }
.sidebar-header { height: 76px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; border-bottom: 1px solid var(--line); }
.admin-badge { border: 1px solid var(--line); border-radius: 99px; padding: 4px 8px; color: var(--dim); font-size: .65rem; }
.sidebar-actions { flex: none; padding: 20px; border-bottom: 1px solid var(--line); }
.new-button { width: 100%; height: 42px; border: 0; color: #16201e; background: var(--accent-soft); cursor: pointer; font-size: .83rem; font-weight: 600; }
.new-button span { margin-right: 5px; }
.list-search { height: 40px; display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 0 10px; border: 1px solid var(--line); color: var(--dim); }
.list-search input { min-width: 0; flex: 1; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: .78rem; }
.article-list { flex: 1; overflow: auto; }
.article-list-empty { padding: 36px 20px; color: var(--dim); text-align: center; font-size: .78rem; }
.article-item { width: 100%; display: block; border: 0; border-bottom: 1px solid var(--line); padding: 17px 20px; color: inherit; background: transparent; text-align: left; cursor: pointer; transition: background .2s; }
.article-item:hover, .article-item.active { background: rgba(255,255,255,.035); }
.article-item.active { box-shadow: inset 2px 0 var(--accent); }
.item-meta { display: flex; justify-content: space-between; margin-bottom: 7px; color: var(--dim); font-size: .64rem; }
.item-status { color: var(--green); }
.item-status.draft { color: var(--accent); }
.article-item strong { display: block; overflow: hidden; color: #d7ddd6; font-family: var(--serif); font-size: .87rem; font-weight: 600; line-height: 1.55; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer { height: 54px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-top: 1px solid var(--line); color: var(--dim); font-size: .68rem; }
.sidebar-footer span::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: var(--green); }
.sidebar-footer button { border: 0; color: var(--muted); background: none; cursor: pointer; }

.editor-shell { grid-column: 2; min-width: 0; }
.editor-topbar { position: sticky; top: 0; z-index: 4; height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(12,18,19,.92); backdrop-filter: blur(16px); }
.editor-topbar p { margin: 0 0 4px; font-size: .8rem; }
.editor-topbar > div > span { color: var(--dim); font-size: .65rem; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-actions a, .ghost-danger, .save-button { border: 0; padding: 10px 13px; text-decoration: none; font-size: .72rem; cursor: pointer; }
.topbar-actions a { color: var(--muted); }
.ghost-danger { color: var(--red); background: transparent; }
.save-button { min-width: 102px; color: #16201e; background: var(--accent-soft); font-weight: 600; }
.save-button:disabled { color: var(--dim); background: rgba(255,255,255,.06); cursor: default; }
.save-button.saving { cursor: wait; }
.empty-editor { min-height: calc(100vh - 76px); display: grid; place-content: center; justify-items: center; color: var(--muted); text-align: center; }
.empty-glyph { color: var(--accent); font-size: 1.4rem; }
.empty-editor h2 { margin: 18px 0 6px; color: var(--ink); font-family: var(--serif); font-size: 1.5rem; }
.empty-editor p { margin: 0; font-size: .82rem; }
.empty-editor button { margin-top: 24px; border: 1px solid var(--line); padding: 9px 16px; color: var(--accent-soft); background: transparent; cursor: pointer; }

.editor { display: grid; grid-template-columns: minmax(440px, .9fr) minmax(420px, 1.1fr); min-height: calc(100vh - 76px); }
.form-pane { min-width: 0; padding: 46px clamp(28px, 4vw, 66px) 70px; border-right: 1px solid var(--line); }
.status-row { display: flex; align-items: end; justify-content: space-between; margin-bottom: 30px; }
.status-select { width: 110px; }
.status-select select { padding: 8px 10px; }
#articleIdLabel { color: var(--dim); font-family: ui-monospace, monospace; font-size: .62rem; }
.title-field textarea { width: 100%; min-height: 110px; resize: none; overflow: hidden; border: 0; outline: 0; padding: 0; color: var(--ink); background: transparent; font-family: var(--serif); font-size: clamp(2rem, 3.4vw, 3rem); font-weight: 600; line-height: 1.35; }
.title-field textarea::placeholder { color: #384341; }
.meta-grid { display: grid; grid-template-columns: 1.3fr .8fr 1fr; gap: 12px; margin: 38px 0 28px; }
.field-block { position: relative; margin-top: 25px; }
.field-block > span { position: absolute; right: 0; color: var(--dim); }
.field-block textarea { width: 100%; resize: vertical; border: 1px solid var(--line); outline: 0; padding: 14px; color: var(--ink); background: rgba(255,255,255,.018); font-size: .84rem; line-height: 1.8; }
.field-block textarea:focus { border-color: rgba(215,168,107,.55); }
.content-field textarea { min-height: 430px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; line-height: 1.9; }

.preview-pane { min-width: 0; padding: 46px clamp(30px, 5vw, 82px) 80px; background: #0a1011; }
.preview-label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 62px; color: var(--muted); font-size: .7rem; }
.preview-label small { color: var(--dim); letter-spacing: .16em; }
.preview-meta { display: flex; gap: 18px; color: var(--dim); font-size: .7rem; }
.preview-meta span { color: var(--green); }
.preview-article h1 { margin: 22px 0 18px; font-family: var(--serif); font-size: clamp(2rem, 3.3vw, 3.1rem); line-height: 1.4; font-weight: 600; }
.preview-article > p { color: var(--muted); font-size: .85rem; line-height: 1.85; }
.preview-rule { height: 1px; margin: 38px 0; background: var(--line); }
.preview-prose { color: #d0d6cf; font-family: var(--serif); font-size: .94rem; line-height: 2; }
.preview-prose p, .preview-prose ul, .preview-prose ol, .preview-prose blockquote, .preview-prose pre { margin: 0 0 1.5em; }
.preview-prose h2, .preview-prose h3 { margin: 2em 0 .7em; color: var(--ink); }
.preview-prose a { color: var(--accent-soft); }
.preview-prose blockquote { padding-left: 18px; border-left: 2px solid var(--accent); color: var(--muted); }
.preview-prose code { padding: .1em .35em; background: rgba(255,255,255,.05); font-family: ui-monospace, monospace; }
.preview-prose pre { overflow: auto; padding: 16px; background: #060a0b; }

.toast { position: fixed; top: 20px; left: 50%; z-index: 50; transform: translate(-50%, -16px); opacity: 0; pointer-events: none; border: 1px solid var(--line); padding: 11px 17px; color: var(--ink); background: #182223; box-shadow: 0 16px 45px rgba(0,0,0,.35); font-size: .76rem; transition: .25s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { border-color: rgba(228,135,124,.5); color: #f4b3aa; }

@media (max-width: 1050px) {
  .editor { grid-template-columns: 1fr; }
  .form-pane { border-right: 0; }
  .preview-pane { border-top: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .app { display: block; }
  .sidebar { position: static; width: 100%; height: auto; border-right: 0; }
  .article-list { max-height: 260px; }
  .sidebar-footer { display: none; }
  .editor-shell { width: 100%; }
  .editor-topbar { top: 0; padding-inline: 16px; }
  .editor-topbar > div:first-child { display: none; }
  .topbar-actions { width: 100%; justify-content: end; }
  .meta-grid { grid-template-columns: 1fr; }
  .repo-grid { grid-template-columns: 1fr; }
  .login-card { padding: 32px 24px; }
  .form-pane, .preview-pane { padding-inline: 20px; }
}
