/* The admin editor. Colours and article typography come from prose.css. */

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.95rem;
}

button,
input,
textarea { font: inherit; color: inherit; }

input,
textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
}
textarea { resize: vertical; }
input:focus,
textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

label { display: block; color: var(--muted); font-size: 0.85rem; margin-bottom: 0.8rem; }
label input,
label textarea { margin-top: 0.25rem; color: var(--text); font-size: 0.95rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid var(--rule);
  background: var(--surface);
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
.btn:disabled { opacity: 0.45; cursor: default; }

.hint { color: var(--muted); font-size: 0.82rem; font-weight: 400; }
.error { color: var(--danger); min-height: 1.2em; margin: 0.4rem 0; font-size: 0.88rem; }

/* Sign-in and loading screens */
.center { min-height: 100vh; display: grid; place-items: center; padding: 1rem; color: var(--muted); }
.card {
  width: min(22rem, 100%);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 1.6rem;
  color: var(--text);
}
.card h1 { margin: 0 0 1.2rem; font-size: 1.3rem; }
.card .btn { width: 100%; justify-content: center; padding: 0.6rem; }

.card label { margin-bottom: 0.25rem; }
.password-field { position: relative; }
.password-field input { padding-right: 4.2rem; }
.reveal {
  position: absolute;
  top: 50%;
  right: 0.3rem;
  transform: translateY(-50%);
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
}
.reveal:hover { background: var(--accent-soft); }

/* Top bar */
.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}
.brand { margin-right: auto; }
.status { color: var(--muted); font-size: 0.85rem; margin-right: 0.4rem; }
.status.error { color: var(--danger); margin: 0 0.4rem 0 0; min-height: 0; }
.status.ok { color: var(--ok); }
.banner { margin: 0; padding: 0.6rem 1rem; background: var(--accent-soft); font-size: 0.88rem; }

/* Two-column layout */
.layout {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
  min-height: calc(100vh - 3.2rem);
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .bar { flex-wrap: wrap; }
}

.side { border-right: 1px solid var(--rule); padding: 1.2rem 1rem; }
.side section + section { margin-top: 2rem; }
.side h2 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 0.6rem; }

.page-list { list-style: none; margin: 0 0 0.6rem; padding: 0; }
.page-list li { display: flex; align-items: center; border-radius: 6px; }
.page-list li.active { background: var(--accent-soft); }
.page-link {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: none;
  border: 0;
  padding: 0.45rem 0.5rem;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.page-list li.active .page-link { font-weight: 600; }
.tag { font-size: 0.7rem; color: var(--muted); border: 1px solid var(--rule); border-radius: 4px; padding: 0 0.3rem; margin-left: 0.3rem; font-weight: 400; }
.icon { background: none; border: 0; padding: 0.3rem 0.35rem; cursor: pointer; color: var(--muted); border-radius: 4px; }
.icon:hover:not(:disabled) { background: var(--rule); color: var(--text); }
.icon:disabled { opacity: 0.25; cursor: default; }

/* Main editing column */
.main { padding: 1.6rem clamp(1rem, 4vw, 3rem) 5rem; max-width: 52rem; width: 100%; }

.page-title {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  border: 0;
  background: none;
  padding: 0.2rem 0;
}
.page-title:focus { outline: none; box-shadow: 0 2px 0 var(--accent); }

.slug-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin: 0.4rem 0 1.2rem; }
.slug-row label { display: flex; align-items: center; gap: 0.3rem; margin: 0; }
.slug-row input { width: 14rem; margin: 0; padding: 0.25rem 0.4rem; font-family: ui-monospace, Menlo, monospace; font-size: 0.85rem; }
.slug-prefix { font-family: ui-monospace, Menlo, monospace; }
.slug-row .danger { margin-left: auto; }

.toolbar {
  position: sticky;
  top: 3.2rem;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px 8px 0 0;
}
.toolbar button {
  border: 1px solid transparent;
  background: none;
  border-radius: 5px;
  padding: 0.3rem 0.55rem;
  min-width: 2rem;
  cursor: pointer;
}
.toolbar button:hover { background: var(--bg); border-color: var(--rule); }
.toolbar button.on { background: var(--accent-soft); color: var(--accent); }
.toolbar .sep { width: 1px; height: 1.3rem; background: var(--rule); margin: 0 0.25rem; }

.editor {
  min-height: 24rem;
  padding: 1.4rem 1.6rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  outline: none;
}
.editor:focus { box-shadow: inset 0 0 0 2px var(--accent-soft); }
.editor > :first-child { margin-top: 0; }
.editor sup.cite {
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 3px;
  padding: 0 0.15em;
  cursor: default;
  user-select: all;
}

/* Sources under the editor */
.sources-panel { margin-top: 2rem; }
.sources-panel h2 { font-size: 1rem; margin: 0 0 0.8rem; }
#source-list { list-style: none; padding: 0; margin: 0 0 0.8rem; }
#source-list li {
  display: grid;
  grid-template-columns: 2.4rem minmax(0, 1fr) auto;
  gap: 0.6rem;
  align-items: start;
  padding: 0.8rem 0;
  border-top: 1px solid var(--rule);
}
#source-list .num { font-weight: 600; padding-top: 0.45rem; color: var(--accent); }
#source-list .fields { display: grid; gap: 0.35rem; }
#source-list .fields .hint { margin: 0; }
.ref-actions { display: flex; flex-direction: column; gap: 0.35rem; }
#sources-empty { margin: 0 0 0.8rem; }

/* Dialogs */
dialog {
  width: min(30rem, calc(100% - 2rem));
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 1.4rem;
}
dialog::backdrop { background: rgb(0 0 0 / 0.35); }
dialog h2 { margin: 0 0 1rem; font-size: 1.15rem; }
dialog fieldset { border: 0; padding: 0; margin: 0; }
.dialog-actions { display: flex; gap: 0.5rem; margin-top: 0.6rem; }
.dialog-actions .spacer { flex: 1; }
.pick-label { color: var(--muted); font-size: 0.85rem; margin: 0 0 0.4rem; }
.ref-picks { list-style: none; padding: 0; margin: 0 0 1.2rem; max-height: 12rem; overflow: auto; border: 1px solid var(--rule); border-radius: 6px; }
.ref-picks li + li { border-top: 1px solid var(--rule); }
.ref-pick { display: flex; gap: 0.5rem; width: 100%; text-align: left; background: none; border: 0; padding: 0.5rem 0.6rem; cursor: pointer; }
.ref-pick:hover { background: var(--accent-soft); }
.ref-pick .num { color: var(--accent); font-weight: 600; flex: none; }
