:root {
  --brand-maroon: #A31F26;
  --brand-maroon-dark: #821A20;
  --brand-green: #4F6B5A;
  --brand-green-dark: #3E5648;
  --surface: #FAF8F5;
  --surface-panel: #D6D1CB;
  --ink: #3A3A3A;
  --ink-muted: #6B6B6B;
  --rule: rgba(58, 58, 58, 0.15);

  --font-serif: "Libre Baskerville", Georgia, "Times New Roman", serif;
  --font-body: "Inter", system-ui, sans-serif;

  --radius: 2px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-serif);
  color: var(--brand-maroon);
  margin: 0 0 0.5em;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.15rem; }

p { margin: 0 0 0.75em; }
p:last-child { margin-bottom: 0; }

a { color: var(--brand-maroon); text-underline-offset: 3px; }
a:hover, a:focus { color: var(--brand-green); }

img { display: block; max-width: 100%; }

.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;
}

.small-caps {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* gate/portal state toggle */
body.locked .portal { display: none; }
body.unlocked .gate { display: none; }

/* ------- gate ------- */
.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

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

.gate-logo {
  width: 80px;
  height: auto;
  margin: 0 auto 1rem;
}

.gate-card h1 {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
}

.gate-help {
  color: var(--ink-muted);
  font-size: 0.95rem;
  margin-bottom: 1.25rem;
}

#gate-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#gate-form input {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  min-height: 44px;
}
#gate-form input:focus {
  outline: 2px solid var(--brand-green);
  outline-offset: 0;
  border-color: var(--brand-green);
}

#gate-form button {
  appearance: none;
  font: inherit;
  font-weight: 500;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  padding: 0.75rem 1.25rem;
  background: var(--brand-maroon);
  color: var(--surface);
  border: 1px solid var(--brand-maroon);
  border-radius: var(--radius);
  cursor: pointer;
}
#gate-form button:hover,
#gate-form button:focus {
  background: var(--brand-maroon-dark);
  border-color: var(--brand-maroon-dark);
}

.gate-error {
  color: var(--brand-maroon);
  font-size: 0.9rem;
  margin: 0;
}

/* ------- portal ------- */
.portal {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  opacity: 0;
  animation: fadeIn 150ms ease-out forwards;
}

@keyframes fadeIn { to { opacity: 1; } }

.portal-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--rule);
  background: #fff;
}

.portal-logo {
  width: 44px;
  height: auto;
}

.portal-title { flex: 1; min-width: 0; }
.portal-title .small-caps { display: block; margin-bottom: 0.1rem; }
.portal-title h2 {
  font-size: 1.05rem;
  margin: 0;
  color: var(--ink);
}

.linklike {
  appearance: none;
  background: none;
  border: 0;
  padding: 0.25rem 0.5rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--brand-maroon);
  text-decoration: underline;
  cursor: pointer;
}
.linklike:hover, .linklike:focus { color: var(--brand-green); }

.portal-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.25rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* ------- preview pane ------- */
.pane-preview { width: 100%; }

.preview-frame {
  position: relative;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  height: min(calc(100vh - 14rem), 820px);
  min-height: 420px;
}

.preview-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: var(--surface);
}

.preview-fallback {
  position: absolute;
  inset: 0;
  padding: 2rem 1.5rem;
  color: var(--ink-muted);
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}

.pane-forms-intro {
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.95rem;
  margin: 0.25rem 0 0;
}

/* ------- forms pane ------- */
.pane-forms {
  display: block;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
}

.card {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.card > p {
  color: var(--ink-muted);
  font-size: 0.95rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.stack label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink);
}

.stack input[type="text"],
.stack input[type="password"],
.stack select,
.stack textarea {
  font: inherit;
  font-size: 1rem;
  font-weight: 400;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  min-height: 44px;
  width: 100%;
}

.stack textarea {
  resize: vertical;
  line-height: 1.5;
  min-height: 96px;
}

.stack input:focus,
.stack select:focus,
.stack textarea:focus {
  outline: 2px solid var(--brand-green);
  outline-offset: 0;
  border-color: var(--brand-green);
}

.stack input[type="file"] {
  padding: 0.4rem 0;
  border: 0;
  background: transparent;
  min-height: 0;
}

.form-help {
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--ink-muted);
}

button[type="submit"] {
  appearance: none;
  font: inherit;
  font-weight: 500;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  padding: 0.75rem 1.25rem;
  background: var(--brand-maroon);
  color: var(--surface);
  border: 1px solid var(--brand-maroon);
  border-radius: var(--radius);
  cursor: pointer;
  align-self: flex-start;
}
button[type="submit"]:hover,
button[type="submit"]:focus {
  background: var(--brand-maroon-dark);
  border-color: var(--brand-maroon-dark);
}
button[type="submit"]:disabled {
  opacity: 0.5;
  cursor: progress;
}

.form-status {
  margin: 0;
  font-size: 0.9rem;
  min-height: 1.2em;
}
.form-status[data-state="ok"] { color: var(--brand-green-dark); }
.form-status[data-state="error"] { color: var(--brand-maroon); }

/* ------- footer ------- */
.portal-footer {
  padding: 1rem 1.25rem 1.5rem;
  font-size: 0.85rem;
  color: var(--ink-muted);
  text-align: center;
}
