/* Base layout shared by every theme. Themes restyle freely in themes/N/theme.css,
   usually by overriding the custom properties below and the .mb-* classes.
   Keep: [hidden] rule, .mb-hp hiding, focus outlines, reduced-motion handling. */

:root {
  --mb-bg: #f4f4f2;
  --mb-fg: #1c1c1f;
  --mb-muted: #55555d;
  --mb-card: #ffffff;
  --mb-border: #d4d4d8;
  --mb-input-bg: #ffffff;
  --mb-accent: #2b55c9;
  --mb-accent-fg: #ffffff;
  --mb-link: #2449b0;
  --mb-error: #b42318;
  --mb-focus: #2b55c9;
  --mb-radius: 12px;
  --mb-gap: 16px;
  --mb-font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mb-font-heading: var(--mb-font);
  --mb-font-mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --mb-cat-suggestion: #1f7a4d;
  --mb-cat-complaint: #b4471f;
  --mb-cat-confession: #7a3fb0;
  --mb-cat-bug: #a11d3a;
  --mb-cat-other: #4a5568;
  color-scheme: light;
}

[hidden] { display: none !important; }

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--mb-bg);
  color: var(--mb-fg);
  font-family: var(--mb-font);
  font-size: 17px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Full-page decoration layer (behind content) and animation layer (above content). */
.mb-scene { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.mb-fx { position: fixed; inset: 0; z-index: 50; pointer-events: none; overflow: hidden; }

.mb-app {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px 24px;
  display: flex;
  flex-direction: column;
  gap: var(--mb-gap);
}

.mb-header { text-align: center; padding: 8px 0; }
.mb-kicker { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--mb-muted); }
.mb-title { margin: 4px 0 8px; font-family: var(--mb-font-heading); font-size: clamp(32px, 8vw, 48px); line-height: 1.1; }
.mb-sub { margin: 0 auto; max-width: 44ch; color: var(--mb-muted); }

.mb-card {
  position: relative;
  background: var(--mb-card);
  border: 1px solid var(--mb-border);
  border-radius: var(--mb-radius);
  padding: 20px;
}

.mb-h2 { margin: 0 0 12px; font-family: var(--mb-font-heading); font-size: 22px; line-height: 1.25; }
.mb-h2:focus { outline: none; }
.mb-h3 { margin: 16px 0 8px; font-size: 17px; }
.mb-text { margin: 0; }

.mb-form { display: flex; flex-direction: column; gap: 18px; }
.mb-field { display: flex; flex-direction: column; }
.mb-label { display: block; margin: 0 0 8px; padding: 0; font-weight: 600; }

.mb-cats { margin: 0; padding: 0; border: 0; min-width: 0; }
.mb-cat-list { display: flex; flex-wrap: wrap; gap: 8px; }
.mb-cat { position: relative; display: inline-flex; }
.mb-cat input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.mb-cat-name {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--mb-border);
  border-radius: 999px;
  background: var(--mb-card);
  cursor: pointer;
  user-select: none;
}
.mb-cat input:checked + .mb-cat-name { background: var(--mb-accent); border-color: var(--mb-accent); color: var(--mb-accent-fg); }
.mb-cat input:focus-visible + .mb-cat-name { outline: 3px solid var(--mb-focus); outline-offset: 2px; }

.mb-textarea, .mb-input {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  color: var(--mb-fg);
  background: var(--mb-input-bg);
  border: 1px solid var(--mb-border);
  border-radius: calc(var(--mb-radius) - 4px);
}
.mb-textarea { min-height: 170px; resize: vertical; }
.mb-input { font-family: var(--mb-font-mono); letter-spacing: 0.04em; text-transform: uppercase; }
.mb-input::placeholder { letter-spacing: 0.04em; }

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

.mb-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; }
.mb-hint, .mb-counter { margin: 0; font-size: 14px; color: var(--mb-muted); }
.mb-counter { font-variant-numeric: tabular-nums; }
.mb-counter.is-near { font-weight: 600; }
.mb-counter.is-over { color: var(--mb-error); font-weight: 700; }

/* Honeypot: hidden from people and screen readers, visible to naive bots. */
.mb-hp { position: absolute !important; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

.mb-error { margin: 0; color: var(--mb-error); font-weight: 600; }

.mb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 20px;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  color: var(--mb-fg);
  background: var(--mb-card);
  border: 1px solid var(--mb-border);
  border-radius: calc(var(--mb-radius) - 4px);
  cursor: pointer;
}
.mb-btn-primary { color: var(--mb-accent-fg); background: var(--mb-accent); border-color: var(--mb-accent); }
.mb-btn-ghost { background: transparent; }
.mb-btn-small { min-height: 44px; padding: 8px 14px; }
.mb-btn:disabled { opacity: 0.65; cursor: progress; }
#send-btn, #lookup-btn { width: 100%; }

.mb-code-box { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 16px 0 4px; }
.mb-code {
  padding: 10px 14px;
  font-family: var(--mb-font-mono);
  font-size: clamp(20px, 6vw, 28px);
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 2px dashed var(--mb-border);
  border-radius: 8px;
  overflow-wrap: anywhere;
  user-select: all;
}
.mb-copy-status { min-height: 1.5em; }
.mb-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }

.mb-list { margin: 0; padding-left: 20px; }
.mb-list li + li { margin-top: 4px; }
.mb-note { margin: 12px 0 0; font-size: 15px; font-style: italic; color: var(--mb-muted); }

.mb-nav { text-align: center; }
.mb-link { color: var(--mb-link); text-underline-offset: 3px; }

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

.mb-thread-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 12px; }
.mb-badge {
  display: inline-block;
  padding: 4px 12px;
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  background: var(--mb-cat-other);
  border-radius: 999px;
}
.mb-badge[data-cat="suggestion"] { background: var(--mb-cat-suggestion); }
.mb-badge[data-cat="complaint"] { background: var(--mb-cat-complaint); }
.mb-badge[data-cat="confession"] { background: var(--mb-cat-confession); }
.mb-badge[data-cat="bug"] { background: var(--mb-cat-bug); }
.mb-time { font-size: 14px; color: var(--mb-muted); }

.mb-msg { margin: 0; padding: 14px 16px; border: 1px solid var(--mb-border); border-radius: calc(var(--mb-radius) - 4px); background: var(--mb-card); }
.mb-msg-who { margin: 0 0 4px; font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--mb-muted); }
.mb-msg-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.mb-msg-host .mb-time { display: block; margin-bottom: 6px; }
.mb-replies { display: flex; flex-direction: column; gap: 12px; margin: 12px 0 0; padding: 0; list-style: none; }
.mb-empty { margin: 12px 0 0; color: var(--mb-muted); }

.mb-footer {
  position: relative;
  z-index: 1;
  padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  text-align: center;
  font-size: 14px;
  color: var(--mb-muted);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Comfortable tap area for text links. */
.mb-nav .mb-link { display: inline-block; padding: 10px 4px; }
