/* Northern Makers brand: tokens from the website's colors_and_type.css.
   Sharp corners and no shadows throughout, with a timber accent. */
:root {
  --nm-black: #1a1a18;
  --nm-white: #f5f2ed;
  --nm-grey-100: #f0ece7;
  --nm-grey-200: #e8e4de;
  --nm-grey-300: #d4cfc8;
  --nm-grey-500: #8c8880;
  --nm-grey-600: #5c5954;
  --nm-grey-700: #3a3835;
  --nm-timber: #c4956a;
  --nm-timber-dark: #a07040;

  --bg: var(--nm-white);
  --card: #fbf9f6;
  --ink: var(--nm-black);
  --muted: var(--nm-grey-600);
  --line: var(--nm-grey-300);
  --subtle: var(--nm-grey-100);
  --accent: var(--nm-black);
  --accent-ink: var(--nm-white);
  --timber: var(--nm-timber-dark);
  --ok: #3f6b4a;
  --warn: var(--nm-timber-dark);
  --bad: #a2332b;

  --font-heading: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-body: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--nm-black);
    --card: #22211f;
    --ink: var(--nm-white);
    --muted: var(--nm-grey-500);
    --line: var(--nm-grey-700);
    --subtle: #2a2927;
    --accent: var(--nm-white);
    --accent-ink: var(--nm-black);
    --timber: var(--nm-timber);
    --ok: #86b894;
    --warn: var(--nm-timber);
    --bad: #e58a80;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font-body);
  padding-bottom: env(safe-area-inset-bottom);
}
[hidden] { display: none !important; }
h1, h2 { font-family: var(--font-heading); font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.stack > * + * { margin-top: 14px; }
.stack-sm > * + * { margin-top: 8px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }

/* ---------- header / brand ---------- */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; min-width: 0; }
/* Logos are drawn with CSS masks so they take the text colour in light and dark mode. */
.brand-mark, .wordmark {
  display: block; background: currentColor;
  -webkit-mask: var(--src) no-repeat center / contain;
  mask: var(--src) no-repeat center / contain;
}
.brand-mark { --src: url(/assets/NM_LOGO.svg); width: 30px; height: 30px; flex: none; }
.brand-mark.large { width: 72px; height: 72px; margin: 0 auto 8px; }
.brand-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.wordmark { --src: url(/assets/NM_WORDMARK.svg); width: 150px; height: 12px; }
.brand-sub { font: 500 11px/1 var(--font-heading); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }

main { max-width: 560px; margin: 0 auto; padding: 16px; }
#signed-out, #denied { padding-top: 18vh; }

/* ---------- controls ---------- */
button {
  font: 500 14px/1 var(--font-heading);
  min-height: 44px; padding: 0 16px;
  border-radius: 0; border: 1px solid var(--line);
  background: transparent; color: var(--ink);
  cursor: pointer;
  transition: border-color .15s, background-color .15s, color .15s;
}
button:hover { border-color: var(--ink); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover { background: var(--timber); border-color: var(--timber); color: #fff; }
button.danger { color: var(--bad); }
button.danger:hover { border-color: var(--bad); }
button.small { min-height: 36px; font-size: 13px; padding: 0 12px; }
button.icon { min-height: 40px; width: 40px; padding: 0; display: grid; place-items: center; border: 0; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--timber); outline-offset: 2px;
}

input, textarea, select {
  font: 16px/1.45 var(--font-body); /* 16px stops iOS zooming */
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 0;
  background: var(--bg); color: var(--ink);
}
input:focus, textarea:focus, select:focus { border-color: var(--ink); outline: none; }
textarea { resize: vertical; min-height: 140px; }
label { display: block; font-size: 13px; color: var(--muted); }
label > input, label > textarea, label > select { margin-top: 4px; color: var(--ink); }
fieldset { border: 1px solid var(--line); border-radius: 0; padding: 12px; margin: 14px 0 0; }
legend { font-size: 13px; color: var(--muted); padding: 0 4px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

.switch { display: flex; gap: 10px; align-items: center; color: var(--ink); font-size: 15px; }
.switch input { width: 20px; height: 20px; margin: 0; accent-color: var(--nm-black); }

.banner { background: var(--subtle); border-left: 3px solid var(--timber); padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }

/* ---------- tabs ---------- */
.tabs { display: flex; margin-bottom: 16px; border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  min-height: 42px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  padding: 0 14px; white-space: nowrap; color: var(--muted);
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs button:hover { color: var(--ink); }
.count:empty { display: none; }
.count { font-variant-numeric: tabular-nums; color: var(--timber); margin-left: 2px; }

/* ---------- posts ---------- */
.post { background: var(--card); border: 1px solid var(--line); margin-bottom: 20px; }
.post.busy { opacity: .6; pointer-events: none; }
.post-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px; }
.post-head strong { font: 600 14px/1.3 var(--font-heading); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip {
  font: 500 11px/1 var(--font-heading); letter-spacing: .08em; text-transform: uppercase;
  padding: 5px 8px; border: 1px solid currentColor; white-space: nowrap; color: var(--muted);
}
.chip.approved, .chip.published { color: var(--ok); }
.chip.failed { color: var(--bad); }
.chip.pending, .chip.publishing { color: var(--warn); }

.carousel { position: relative; background: #000; }
.slides { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.slides::-webkit-scrollbar { display: none; }
.slides img { flex: 0 0 100%; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; scroll-snap-align: center; display: block; }
.dots { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; pointer-events: none; }
.dots i { width: 6px; height: 6px; background: rgba(255,255,255,.45); }
.dots i.on { background: #fff; }
.slide-count { position: absolute; top: 10px; right: 10px; background: rgba(26,26,24,.7); color: #fff; font: 500 12px/1 var(--font-heading); padding: 5px 8px; }

.post-body { padding: 14px; }
.post-body > * + * { margin-top: 12px; }
.meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }
.meta .over { color: var(--bad); font-weight: 600; }
details summary { cursor: pointer; font-size: 13px; color: var(--muted); min-height: 32px; display: flex; align-items: center; }
details textarea { min-height: 70px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .wide { grid-column: 1 / -1; }
.error { color: var(--bad); font-size: 14px; white-space: pre-wrap; }
.readonly-caption { white-space: pre-wrap; font-size: 15px; }
.link { color: inherit; text-decoration-color: var(--timber); text-underline-offset: 3px; }

/* ---------- settings sheet ---------- */
dialog {
  width: min(560px, 100vw); max-width: 100vw; max-height: 92vh;
  margin: auto auto 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  border: 0; border-top: 1px solid var(--line); border-radius: 0;
  background: var(--card); color: var(--ink);
}
@media (min-width: 600px) { dialog { margin: auto; border: 1px solid var(--line); } }
dialog::backdrop { background: rgba(20, 19, 17, 0.55); }
.slot-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.slot-row button { min-height: 44px; }
.tool-output { font-size: 13px; background: var(--bg); border: 1px solid var(--line); padding: 12px; overflow-x: auto; margin-top: 12px; }
.tool-output table { border-collapse: collapse; width: 100%; }
.tool-output td, .tool-output th { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tool-output img { width: 100%; max-width: 270px; display: block; margin-top: 8px; }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 528px; margin: 0 auto; z-index: 20;
  background: var(--ink); color: var(--bg);
  padding: 12px 14px; font-size: 14px;
}
#toast.bad { background: var(--bad); color: #fff; }
