/* Rural Handmade Studio (ADR 0009). Same tokens as the site (design system v4), denser layout for work. */
@font-face { font-family: "Instrument Sans"; src: url("../site/fonts/InstrumentSans-latin.woff2") format("woff2"); font-weight: 400 600; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url("../site/fonts/InstrumentSerif-latin.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --ink: #1f1d1b; --ink-2: #3c3833; --muted: #625c56; --page: #f6f4f0; --surface: #ffffff; --surface-2: #f1ede6;
  --line: #e6e0d7; --line-2: #d4ccc0; --control: #8a8178; --action: #2a2725; --action-hover: #000000;
  --clay: #6e3b2e; --butter: #f3ecd2; --sage: #e4e7d9; --ok: #0f6b4a; --ok-bg: #e3f1ea; --warn: #8a5a00; --warn-bg: #fbefd2;
  --bad: #a8322a; --bad-bg: #f8e4e1; --info: #1f5a85; --info-bg: #e3edf5;
  --sans: "Instrument Sans", Arial, sans-serif; --serif: "Instrument Serif", Georgia, serif; --mono: ui-monospace, Menlo, Consolas, monospace;
  --r: 6px; --nav: 232px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 400 14px/21px var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.serif { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.noscript { padding: 40px; }
[hidden] { display: none !important; }

/* buttons + fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--surface); font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink); }
.btn-dark { background: var(--action); border-color: var(--action); color: #fff; }
.btn-dark:hover { background: var(--action-hover); color: #fff; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-lg { min-height: 44px; padding: 0 20px; font-size: 15px; }
.btn:disabled { opacity: .55; cursor: default; }
.field { display: grid; gap: 6px; }
.field > label, .label { font-weight: 600; font-size: 13px; }
.hint { font-size: 12.5px; color: var(--muted); }
.err { font-size: 12.5px; color: var(--bad); }
.input, .select, .textarea { width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid var(--control); border-radius: var(--r); background: var(--surface); }
.textarea { min-height: 80px; resize: vertical; line-height: 20px; }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--bad); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.stack { display: grid; gap: 14px; }

/* badges */
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge.published { background: var(--ok-bg); color: var(--ok); }
.badge.draft { background: var(--surface-2); color: var(--ink-2); }
.badge.deleted, .badge.disabled { background: var(--bad-bg); color: var(--bad); }
.badge.retired { background: var(--warn-bg); color: var(--warn); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--butter); }
.login-card { width: min(420px, 100%); background: var(--surface); border-radius: 10px; padding: 36px 32px; box-shadow: 0 10px 40px rgba(31, 29, 27, .08); display: grid; gap: 20px; }
.login-card h1 { font-family: var(--serif); font-weight: 400; font-size: 34px; line-height: 38px; }
.login-card .brand { font-size: 13px; color: var(--muted); }
.code-input { font-family: var(--mono); font-size: 26px; letter-spacing: 10px; text-align: center; min-height: 54px; }
.notice { padding: 10px 12px; border-radius: var(--r); background: var(--info-bg); color: var(--info); font-size: 13px; }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }

/* shell */
.shell { display: grid; grid-template-columns: var(--nav) minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .logo { padding: 4px 10px 18px; font-family: var(--serif); font-size: 22px; }
.side .logo small { display: block; font-family: var(--sans); font-size: 12px; color: var(--muted); }
.side .group { margin: 14px 10px 4px; font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.side a { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 10px; border-radius: var(--r); text-decoration: none; color: var(--ink-2); }
.side a:hover { background: var(--surface-2); }
.side a[aria-current="page"] { background: var(--action); color: #fff; }
.side .me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line); display: grid; gap: 2px; font-size: 13px; }
.side .me .btn { margin-top: 8px; justify-content: flex-start; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px 28px; border-bottom: 1px solid var(--line); background: var(--page); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-family: var(--serif); font-weight: 400; font-size: 28px; line-height: 32px; }
.menu-toggle { display: none; }
.content { padding: 24px 28px 64px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.panel-pad { padding: 18px; }
.panel h2 { font-size: 15px; font-weight: 600; }

/* lists */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .select { width: auto; min-width: 180px; }
.toolbar .grow { min-width: 220px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { min-height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; }
.tab[aria-pressed="true"] { background: var(--action); border-color: var(--action); color: #fff; }
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
.list th, .list td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
.list tr:last-child td { border-bottom: 0; }
.list tbody tr:hover { background: #fcfbf9; }
.list .title-cell a { font-weight: 600; text-decoration: none; }
.list .title-cell a:hover { text-decoration: underline; }
.list .sub { font-size: 12.5px; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 14px; border-top: 1px solid var(--line); }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }

/* editor */
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.editor-grid > * { min-width: 0; }
.editor-main { display: grid; gap: 14px; min-width: 0; }
.title-input { width: 100%; border: 0; background: transparent; font-family: var(--serif); font-size: 40px; line-height: 46px; padding: 4px 0; }
.title-input:focus { outline: none; }
.title-input::placeholder { color: #b5aca1; }
.rte { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.rte-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); position: sticky; top: 64px; background: var(--surface); z-index: 3; border-radius: 10px 10px 0 0; }
.rte-bar button { min-width: 34px; height: 32px; padding: 0 8px; border: 0; border-radius: 4px; background: transparent; cursor: pointer; font-weight: 600; }
.rte-bar button:hover { background: var(--surface-2); }
.rte-bar .sep { width: 1px; background: var(--line); margin: 4px 4px; }
.rte-body { overflow-wrap: anywhere; overflow-x: auto; min-height: 420px; padding: 20px 24px; font-size: 16px; line-height: 27px; outline: none; }
.rte-body:empty::before { content: attr(data-placeholder); color: #b5aca1; }
.rte-body > * + * { margin-top: 14px; }
.rte-body h2 { font-family: var(--serif); font-weight: 400; font-size: 28px; line-height: 34px; margin-top: 26px; }
.rte-body h3 { font-size: 19px; line-height: 26px; margin-top: 22px; }
.rte-body h4 { font-size: 16px; margin-top: 18px; }
.rte-body img { max-width: 100%; height: auto; border-radius: 6px; display: block; }
.rte-body blockquote { margin: 0; padding-left: 16px; border-left: 2px solid var(--clay); font-family: var(--serif); font-size: 20px; line-height: 28px; }
.rte-body ul, .rte-body ol { padding-left: 22px; }
.rte-body table { border-collapse: collapse; }
.rte-body td, .rte-body th { border: 1px solid var(--line-2); padding: 6px 8px; }
.rte-body a { color: var(--clay); }
.side-card { display: grid; gap: 12px; }
.cover { position: relative; aspect-ratio: 16 / 9; border-radius: var(--r); background: var(--surface-2); overflow: hidden; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.counter { font-size: 12px; color: var(--muted); text-align: right; }
.counter.over { color: var(--bad); }
.serp { border: 1px solid var(--line); border-radius: var(--r); padding: 12px; font-family: Arial, sans-serif; }
.serp .u { font-size: 12px; color: #202124; }
.serp .t { font-size: 17px; line-height: 22px; color: #1a0dab; margin: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.serp .d { font-size: 13px; line-height: 19px; color: #4d5156; }
details.box { border-top: 1px solid var(--line); padding-top: 12px; }
details.box summary { cursor: pointer; font-weight: 600; list-style: none; }
details.box summary::-webkit-details-marker { display: none; }
.savebar { display: flex; gap: 8px; flex-wrap: wrap; }

/* topics */
.topic { padding: 14px 18px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.topic:last-child { border-bottom: 0; }
.subs { display: flex; flex-wrap: wrap; gap: 6px; }
.sub-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; background: var(--surface-2); font-size: 13px; }
.sub-chip button { border: 0; background: none; cursor: pointer; padding: 0 2px; color: var(--muted); }

/* docs */
.op { border-bottom: 1px solid var(--line); padding: 14px 18px; display: grid; gap: 8px; }
.op:last-child { border-bottom: 0; }
.method { display: inline-block; min-width: 58px; text-align: center; padding: 2px 6px; border-radius: 4px; font: 600 12px var(--mono); color: #fff; background: var(--ink-2); }
.method.GET { background: #1f5a85; } .method.POST { background: #0f6b4a; } .method.PATCH { background: #8a5a00; } .method.DELETE { background: #a8322a; }
pre.code { margin: 0; padding: 12px; background: #1f1d1b; color: #f3ecd2; border-radius: var(--r); overflow-x: auto; font: 12px/18px var(--mono); }
.key-box { padding: 12px; border: 1px dashed var(--clay); border-radius: var(--r); background: var(--butter); word-break: break-all; }

/* toast + dialog */
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: 380px; padding: 12px 14px; border-radius: var(--r); background: var(--ink); color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.toast.bad { background: var(--bad); }
dialog.modal { border: 0; border-radius: 10px; padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog.modal::backdrop { background: rgba(31, 29, 27, .45); }
.modal-body { padding: 22px; display: grid; gap: 14px; }
.modal-body h2 { font-family: var(--serif); font-weight: 400; font-size: 26px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* responsive */
@media (max-width: 1100px) { .editor-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform .2s ease-out; box-shadow: 0 0 40px rgba(0,0,0,.2); }
  .side.open { transform: none; }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .topbar h1 { font-size: 22px; }
  .content { padding: 16px 16px 48px; }
  .title-input { font-size: 30px; line-height: 36px; }
  .rte-bar { top: 56px; }
  .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
