/* invisiq admin — same visual language as the public site (public/styles.css):
   pure black, white type, the slanted slash, Geologica + Martian Mono, thin 1px lines. */
:root {
  --bg: #000;
  --fg: #fff;
  --fg-2: rgba(255, 255, 255, .64);
  --fg-3: rgba(255, 255, 255, .5);
  --line: rgba(255, 255, 255, .14);
  --line-strong: rgba(255, 255, 255, .32);
  --ghost: rgba(255, 255, 255, .07);
  --error: #ff9a8f; /* ~ 9.6:1 on black */

  --font: "Geologica", system-ui, sans-serif;
  --mono: "Martian Mono", ui-monospace, monospace;

  --gutter: clamp(16px, 4vw, 56px);
  --max: 1100px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --slant: -15deg;

  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--fg); color: var(--bg); }

a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .02em;
  font-weight: 400;
  color: var(--fg-3);
}

.slash polygon { fill: currentColor; }

.skip {
  position: fixed;
  left: var(--gutter);
  top: -100px;
  z-index: 200;
  padding: 12px 18px;
  background: var(--fg);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 13px;
}
.skip:focus { top: 16px; }

/* ───────────────────────── brand ───────────────────────── */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-weight: 500;
  font-size: 18px;
  letter-spacing: -.02em;
}
.brand .slash { width: 9px; height: 24px; flex: none; }
.brand__sep { color: var(--fg-3); }
.brand__section { color: var(--fg-2); }

.brand--stacked { gap: 14px; }
.brand--stacked .slash { width: 14px; height: 38px; }

/* ───────────────────────── header bar ───────────────────────── */
.bar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px var(--gutter);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.bar__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* ───────────────────────── page ───────────────────────── */
.page {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(32px, 6vw, 72px) var(--gutter);
}
.page:focus { outline: none; }
.page__title {
  font-weight: 500;
  font-size: clamp(32px, 6vw, 56px);
  line-height: 1.05;
  letter-spacing: -.035em;
}
.page__lead {
  margin-top: 16px;
  max-width: 56ch;
  color: var(--fg-2);
}

/* ───────────────────────── login ───────────────────────── */
.auth__main {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 32px 16px;
}

.card {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: clamp(28px, 7vw, 48px);
  border: 1px solid var(--line);
  background: var(--bg);
  overflow: hidden;
  isolation: isolate;
}
/* the slash motif as a ghosted watermark in the card corner */
.card::after {
  content: "";
  position: absolute;
  right: -28px;
  bottom: -36px;
  z-index: -1;
  width: 120px;
  height: 334px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='416 266 168 468'%3E%3Cpolygon points='542,266 584,266 458,734 416,734' fill='%23fff' fill-opacity='.07'/%3E%3C/svg%3E") no-repeat center / contain;
  pointer-events: none;
}

.auth__title {
  margin: 28px 0 32px;
  font-weight: 500;
  font-size: clamp(28px, 7vw, 36px);
  line-height: 1.1;
  letter-spacing: -.03em;
}

/* ───────────────────────── forms ───────────────────────── */
.form { display: grid; gap: 24px; }

.field { display: grid; gap: 10px; }

.field__label {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .02em;
  color: var(--fg-2);
}

.field__input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 16px; /* no zoom-on-focus on iOS */
  transition: border-color .2s;
}
.field__input:hover { border-color: var(--fg-2); }
.field__input:focus { border-color: var(--fg); }
.field__input:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.field__input[aria-invalid="true"] { border-color: var(--error); }
.field__input[aria-invalid="true"]:focus-visible { outline-color: var(--error); }

.field__error {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--error);
}

/* ───────────────────────── buttons (as the site's .btn) ───────────────────────── */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 22px;
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: .02em;
  line-height: 1;
  border: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--fg);
  overflow: hidden;
  isolation: isolate;
  cursor: pointer;
  transition: color .3s var(--ease), border-color .3s;
}
.btn::before {
  content: "";
  position: absolute;
  inset: 0 -20%;
  z-index: -1;
  background: var(--fg);
  transform: skewX(var(--slant)) scaleX(0);
  transform-origin: left;
  transition: transform .35s var(--ease);
}
.btn:hover { color: var(--bg); border-color: var(--fg); }
.btn:hover::before { transform: skewX(var(--slant)) scaleX(1); }
.btn:active { transform: scale(.98); }
.btn:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }

.btn--solid { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn--solid::before { background: var(--bg); }
.btn--solid:hover { color: var(--fg); }

.btn--danger { border-color: var(--error); color: var(--error); }
.btn--danger::before { background: var(--error); }
.btn--danger:hover { color: var(--bg); border-color: var(--error); }

.btn--small { min-height: 40px; padding: 0 16px; }
.btn--block { width: 100%; }

.btn:disabled,
.btn[aria-busy="true"] { cursor: progress; opacity: .55; }
.btn:disabled:hover { color: var(--fg); border-color: var(--line); }
.btn--solid:disabled:hover { color: var(--bg); border-color: var(--fg); }
.btn:disabled:hover::before { transform: skewX(var(--slant)) scaleX(0); }

/* ───────────────────────── toast ───────────────────────── */
.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 300;
  max-width: 420px;
  margin: 0 auto;
  padding: 14px 18px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity .25s var(--ease), transform .25s var(--ease), visibility 0s linear .25s;
}
.toast.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.toast--error { border-color: var(--error); color: var(--error); }

/* ───────────────────────── dialog ───────────────────────── */
.dialog {
  width: min(100% - 32px, 440px);
  max-width: none;
  padding: 0;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--fg);
}
.dialog::backdrop { background: rgba(0, 0, 0, .78); }
.dialog__form { display: grid; gap: 16px; padding: clamp(24px, 6vw, 36px); }
.dialog__title { font-weight: 500; font-size: 22px; line-height: 1.2; letter-spacing: -.02em; overflow-wrap: anywhere; }
.dialog__text { color: var(--fg-2); }
.dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* ───────────────────────── page list (as the site's services rows) ───────────────────────── */
.btn--compact { min-height: 36px; padding: 0 12px; font-size: 11px; }
.btn[aria-disabled="true"] { opacity: .55; pointer-events: none; }

.list {
  margin: clamp(28px, 4vw, 48px) 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
  counter-reset: item;
}
.page[aria-busy="true"] .list { opacity: .6; transition: opacity .2s; }

.item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) minmax(0, auto);
  grid-template-areas:
    "num main meta"
    "num actions actions";
  align-items: start;
  gap: 16px 24px;
  padding: clamp(20px, 2.6vw, 30px) 0;
  border-bottom: 1px solid var(--line);
  counter-increment: item;
}
.item::before {
  content: counter(item, decimal-leading-zero);
  grid-area: num;
  padding-top: .55em;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-3);
  transition: color .3s;
}
.item:hover::before, .item:focus-within::before { color: var(--fg); }

.item__main { grid-area: main; display: grid; gap: 8px; min-width: 0; }
.item__title {
  font-size: clamp(20px, 2.6vw, 30px);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -.03em;
  overflow-wrap: anywhere;
}
.item__url { color: var(--fg-2); overflow-wrap: anywhere; }
.item__copy { margin-top: 4px; min-height: 40px; }

.item__meta {
  grid-area: meta;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 6px 18px;
  min-width: 0;
  padding-top: .45em;
  color: var(--fg-2);
}
.item__status { display: inline-flex; align-items: center; gap: 8px; color: var(--fg-3); }
/* the slash motif as a status mark: solid when live, outlined when hidden */
.item__status::before {
  content: "";
  width: 4px;
  height: 14px;
  border: 1px solid currentColor;
  transform: skewX(var(--slant));
}
.item__status.is-on { color: var(--fg); }
.item__status.is-on::before { background: currentColor; }
.item__lock { display: inline-flex; align-items: center; gap: 6px; color: var(--fg); }
.item__lock-icon { width: 11px; height: 13px; flex: none; }

.item__actions {
  grid-area: actions;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.list-state { margin-top: clamp(28px, 4vw, 48px); }
.list-state--error {
  display: grid;
  justify-items: start;
  gap: 12px;
  padding: 24px;
  border: 1px solid var(--error);
}
.list-state__title { font-weight: 500; }
.list-state__text { color: var(--error); }

.empty {
  position: relative;
  display: grid;
  justify-items: start;
  gap: 14px;
  margin-top: clamp(28px, 4vw, 48px);
  padding: clamp(28px, 5vw, 48px);
  border: 1px solid var(--line);
  overflow: hidden;
  isolation: isolate;
}
.empty::after {
  content: "";
  position: absolute;
  right: 24px;
  top: -40px;
  z-index: -1;
  width: 90px;
  height: 250px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='416 266 168 468'%3E%3Cpolygon points='542,266 584,266 458,734 416,734' fill='%23fff' fill-opacity='.07'/%3E%3C/svg%3E") no-repeat center / contain;
  pointer-events: none;
}
.empty__title { font-weight: 500; font-size: clamp(24px, 4vw, 32px); letter-spacing: -.03em; line-height: 1.1; }
.empty__text { max-width: 48ch; color: var(--fg-2); }
.empty .btn { margin-top: 8px; }

/* ───────────────────────── editor ───────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.page--wide { max-width: 1600px; }

.editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 40px;
  margin-top: clamp(28px, 4vw, 48px);
}
.editor__form { min-width: 0; }
.editor__fields {
  display: grid;
  gap: 28px;
  min-width: 0;
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.editor__fields:disabled { opacity: .6; }

.field__hint {
  max-width: 72ch;
  line-height: 1.6;
}
.field__warning {
  padding-left: 12px;
  border-left: 2px solid var(--fg);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--fg);
  overflow-wrap: anywhere;
}
.field__warning:empty { display: none; }

/* slug: the fixed pages-origin prefix glued to the input */
.slug-row {
  display: grid;
  grid-template-columns: minmax(0, max-content) minmax(10ch, 1fr);
  min-width: 0;
}
.slug-row__prefix {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 48px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-right: 0;
  background: var(--ghost);
  color: var(--fg-2);
  overflow-wrap: anywhere;
}
.slug-row__prefix:empty { display: none; }
.slug-row .field__input { min-width: 0; }

/* the slanted slash as the checkmark */
.check {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 44px;
}
.check__box {
  appearance: none;
  display: grid;
  place-content: center;
  flex: none;
  width: 24px;
  height: 24px;
  margin: 0;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  transition: border-color .2s;
}
.check__box::before {
  content: "";
  width: 5px;
  height: 16px;
  background: var(--fg);
  transform: skewX(var(--slant)) scaleY(0);
  transition: transform .25s var(--ease);
}
.check__box:hover { border-color: var(--fg-2); }
.check__box:checked { border-color: var(--fg); }
.check__box:checked::before { transform: skewX(var(--slant)) scaleY(1); }
.check__label { cursor: pointer; }

.pw-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--line);
}
.pw-status__text {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 12px;
}
.pw-status__text::before {
  content: "";
  width: 4px;
  height: 14px;
  background: currentColor;
  transform: skewX(var(--slant));
}

.field__code {
  min-height: 50vh;
  padding: 14px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
  resize: vertical;
}

/* code area: line-number gutter glued to the textarea (same font metrics, scroll synced in JS) */
.code {
  --code-size: 13px;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  min-width: 0;
}
.code .field__code { font-size: var(--code-size); }
.code__gutter {
  position: relative;
  width: calc(var(--gutter-digits, 1) * 1ch + 22px);
  min-width: calc(2ch + 22px);
  border: 1px solid var(--line-strong);
  border-right: 0;
  background: var(--ghost);
  font-family: var(--mono);
  font-size: var(--code-size);
}
.code__numbers {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 14px 10px 48px 8px; /* bottom: room for the textarea's horizontal scrollbar */
  overflow: hidden;
  font: inherit;
  line-height: 1.65;
  text-align: right;
  white-space: pre;
  color: var(--fg-3);
  user-select: none;
  pointer-events: none;
}

/* drop zone: dashed 1px frame; while a file is dragged over it the slash motif lights up */
.dropzone {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 16px 18px;
  border: 1px dashed var(--line-strong);
  overflow: hidden;
  isolation: isolate;
  transition: border-color .2s, background-color .2s;
}
.dropzone__slash {
  flex: none;
  width: 9px;
  height: 24px;
  color: var(--fg-3);
  transition: color .2s, transform .3s var(--ease);
}
.dropzone__text { font-size: 15px; }
.dropzone__or { color: var(--fg-3); }
.dropzone__error {
  flex-basis: 100%;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--error);
}
.dropzone::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: repeating-linear-gradient(105deg, transparent 0 18px, var(--ghost) 18px 20px);
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}
.dropzone:hover { border-color: var(--fg-2); }
.dropzone.is-dragover { border-color: var(--fg); border-style: solid; }
.dropzone.is-dragover::after { opacity: 1; }
.dropzone:hover .dropzone__slash,
.dropzone.is-dragover .dropzone__slash { color: var(--fg); transform: scaleY(1.15); }

.editor__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.editor__state { color: var(--fg-2); }
.editor__state:empty { display: none; }
.editor__keys { margin-left: auto; }

/* preview panel: a thin frame, a mono caption and the sandboxed iframe */
.editor__preview {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 12px;
  min-width: 0;
  min-height: 50vh;
  padding: 16px;
  border: 1px solid var(--line);
  overflow: hidden;
  isolation: isolate;
}
.preview__caption { color: var(--fg-3); }
.preview__label { color: var(--fg-2); }
.preview__frame {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 40vh;
  border: 1px solid var(--line);
}
.preview__iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
  color-scheme: light;
}
.preview__error {
  padding-left: 12px;
  border-left: 2px solid var(--error);
  line-height: 1.5;
  color: var(--error);
}
.preview__hint { max-width: none; }
.editor__preview::after {
  content: "";
  position: absolute;
  right: 24px;
  bottom: -40px;
  z-index: -1;
  width: 110px;
  height: 306px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='416 266 168 468'%3E%3Cpolygon points='542,266 584,266 458,734 416,734' fill='%23fff' fill-opacity='.07'/%3E%3C/svg%3E") no-repeat center / contain;
  pointer-events: none;
}
.editor__preview-empty { padding: 24px; text-align: center; }

@media (min-width: 1024px) {
  .editor {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 48px;
    align-items: start;
  }
  .editor__preview {
    position: sticky;
    top: 88px;
    min-height: calc(100vh - 120px);
    min-height: calc(100dvh - 120px);
  }
  .editor__actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding-bottom: 20px;
    background: var(--bg);
  }
}

@media (max-width: 599px) {
  .slug-row { grid-template-columns: minmax(0, 1fr); }
  .slug-row__prefix {
    min-height: 0;
    padding: 8px 12px;
    border-right: 1px solid var(--line-strong);
    border-bottom: 0;
  }
}

@media (max-width: 767px) {
  .field__code { font-size: 16px; } /* no zoom-on-focus on iOS */
  .code { --code-size: 16px; }
  .preview__frame { min-height: 60vh; }
  .editor__keys { display: none; }
  .item {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "num" "main" "meta" "actions";
    gap: 12px;
  }
  .item::before { padding-top: 0; }
  .item__meta { justify-content: flex-start; padding-top: 0; }
}

@media (max-width: 479px) {
  .brand__sep, .brand__section { display: none; }
  .bar .btn--small { padding: 0 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
