/* === Publish === */

:root {
  --bg: #f7f6f4;
  --surface: #e6e6e6;
  --ink: #3a3a3a;
  --muted: #545454;
  --rule: #cbc9c5;
  --focus: #4846af;
  --publish: #0d6144;
  --draft: #854a00;
  --danger: #b42318;
  --on-publish: #ffffff;

  --radius: 10px;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #141414;
    --ink: #e5e4db;
    --muted: #969696;
    --rule: #303030;
    --focus: #22a6b3;
    --publish: #2ea37a;
    --draft: #d08a2c;
    --danger: #e5675c;
    --on-publish: #04150f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--ui);
  -webkit-text-size-adjust: 100%;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

:where(a, button, input, textarea, summary):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bg);
}

.gate[hidden] { display: none; }

.gate-card {
  width: 100%;
  max-width: 22rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  text-align: center;
}

.gate-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  color: var(--ink);
}

.gate-note {
  margin: 0 0 1.25rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.gate-note.is-error { color: var(--danger); }
.gate .btn { width: 100%; }

.gate .btn-publish {
  background: var(--focus);
  color: #ffffff;
}

@media (prefers-color-scheme: dark) {
  .gate .btn-publish { color: #04150f; }
}

.bar {
  position: sticky;
  z-index: 10;
  background: var(--surface);
  border-color: var(--rule);
  border-style: solid;
  border-width: 0;
}

.bar-top { top: 0; border-bottom-width: 1px; }

.bar-bottom {
  bottom: 0;
  border-top-width: 1px;
  padding-bottom: max(0px, env(safe-area-inset-bottom) - 0.6rem);
}

.bar-inner {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.commit-path {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.35;
  padding-left: 0.7rem;
  border-left: 3px solid var(--publish);
}

.commit-path.is-draft { border-left-color: var(--draft); }
.commit-repo { display: block; color: var(--muted); }
.commit-file {
  display: block;
  color: var(--ink);
  font-weight: 600;
  overflow-wrap: anywhere;
}

button { font: inherit; cursor: pointer; }

.btn {
  min-height: 44px;
  padding: 0 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 600;
}

.btn-publish { background: var(--publish); color: var(--on-publish); }
.btn-draft { background: transparent; color: var(--draft); border-color: var(--draft); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn[disabled] { opacity: 0.45; cursor: default; }

.ghost {
  min-height: 40px;
  padding: 0 0.75rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  white-space: nowrap;
}

.actions { display: flex; gap: 0.5rem; }

.status {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.status.is-error { color: var(--danger); }
.status.is-good { color: var(--publish); }

.segmented {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}

.seg {
  min-height: 40px;
  padding: 0 0.9rem;
  background: transparent;
  color: var(--muted);
  border: 0;
}

.seg + .seg { border-left: 1px solid var(--rule); }
.seg.is-on { background: var(--ink); color: var(--surface); }
.segmented-sm .seg { min-height: 34px; font-size: 0.875rem; }

.sheet {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

.library {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-bottom: 1.25rem;
}

.library-head {
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.filter { display: block; margin-bottom: 0.5rem; }
.library-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 40vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.library-list li + li { border-top: 1px solid var(--rule); }
.library-list button {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 0.6rem 0.25rem;
  background: transparent;
  border: 0;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.8125rem;
  text-align: left;
  overflow-wrap: anywhere;
}

.library-note {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin: 0;
}

.field { border: 0; padding: 0; margin: 0; }

.field label:not(.radio),
.field legend {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--muted);
  padding: 0;
}

input[type="text"],
input[type="url"],
input[type="search"],
input[type="datetime-local"],
textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.6rem 0.7rem;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font: inherit;
}

textarea { resize: vertical; line-height: 1.55; }

#slug, #body, #raw-frontmatter { font-family: var(--mono); font-size: 0.9375rem; }
#title { font-size: 1.125rem; font-weight: 600; }

.slug-row { display: flex; gap: 0.5rem; align-items: stretch; }
.slug-row input { flex: 1; min-width: 0; }

.hint {
  margin: 0.35rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.hint code { font-family: var(--mono); }

.radios { display: flex; gap: 0.5rem; }

.radio {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0 0.75rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0;
}

.radio:has(input:checked) { border-color: var(--ink); color: var(--ink); }

.radio input {
  accent-color: var(--focus);
  width: 1.1em;
  height: 1.1em;
  margin: 0;
  flex: none;
}

.tag-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.tag-chip {
  min-height: 36px;
  padding: 0 0.7rem;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.8125rem;
}

.tag-chip:hover { border-color: var(--focus); }

.body-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.body-head label { margin: 0; }

.preview {
  min-height: 12rem;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow-wrap: anywhere;
}

.preview > :first-child { margin-top: 0; }
.preview > :last-child { margin-bottom: 0; }
.preview img { max-width: 100%; height: auto; }
.preview pre {
  overflow-x: auto;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: var(--radius);
}

.preview code { font-family: var(--mono); font-size: 0.9em; }
.preview blockquote {
  margin: 1rem 0;
  padding-left: 1rem;
  border-left: 3px solid var(--rule);
  color: var(--muted);
}

.raw summary {
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--muted);
  min-height: 44px;
  display: flex;
  align-items: center;
}

.raw pre {
  margin: 0;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.8125rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .ghost, .seg { transition: background-color 0.15s ease, color 0.15s ease; }
}
