:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #65717e;
  --line: #dfe5ea;
  --surface: #ffffff;
  --canvas: #f4f6f7;
  --brand: #12664f;
  --brand-dark: #0b4938;
  --soft: #e8f3ef;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(244, 246, 247, .89), rgba(244, 246, 247, .93)),
    url('/assets/lucentia-background.webp?v=2') center 44% / cover fixed no-repeat;
}
.shell { width: min(920px, calc(100% - 32px)); min-height: calc(100dvh - 64px); margin: 32px auto; display: flex; flex-direction: column; }
.access-gate { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.access-card { width: min(560px, 100%); padding: 26px; border: 1px solid rgba(223, 229, 234, .92); border-radius: 20px; background: rgba(255, 255, 255, .94); box-shadow: 0 18px 55px rgba(19, 31, 42, .12); backdrop-filter: blur(12px); }
.access-card h2 { margin-bottom: 6px; font-size: 1.45rem; }
.resident-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 22px 0 14px; }
.resident-fields label, .owner-field, .password-row label { display: grid; gap: 6px; color: var(--muted); font-size: .82rem; font-weight: 700; }
.resident-fields select, .owner-field input, .password-row input { width: 100%; height: 44px; padding: 0 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: white; font: inherit; }
.owner-field { margin-bottom: 14px; }
.wide { width: 100%; }
.terms-consent { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 8px 12px; margin: 0 2px 12px; font-size: .82rem; line-height: 1.35; }
.terms-consent label { display: flex; align-items: flex-start; gap: 8px; color: var(--ink); cursor: pointer; }
.terms-consent input { flex: none; width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--brand); }
.terms-link { align-self: start; padding: 0; border-radius: 0; color: var(--brand); background: transparent; font-size: .82rem; text-decoration: underline; }
.terms-link:hover { color: var(--brand-dark); background: transparent; }
#request-access:disabled { cursor: not-allowed; }
#submitted-panel h2 { margin-bottom: 12px; font-size: 1.2rem; overflow-wrap: anywhere; }
#submitted-panel .admin-contact { margin-top: 0; }
.admin-contact { margin: 13px 2px 0; padding: 11px 13px; border-radius: 10px; color: var(--muted); background: var(--soft); font-size: .86rem; line-height: 1.35; }
.admin-contact p { display: block; margin: 0; }
.admin-contact p + p { margin-top: 2px; }
.admin-contact #contact-intro { display: block; margin-bottom: 4px; color: var(--ink); }
.password-row { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 12px; margin-top: 18px; }
.password-row input { font-size: 1.15rem; letter-spacing: .24em; }
.access-notice { min-height: 2.6em; margin: 12px 2px 0; font-size: .84rem; line-height: 1.35; }
.terms-dialog { width: min(760px, calc(100% - 28px)); max-height: min(82dvh, 820px); padding: 0; border: 1px solid var(--line); border-radius: 18px; color: var(--ink); background: var(--surface); box-shadow: 0 24px 80px rgba(19, 31, 42, .25); }
.terms-dialog::backdrop { background: rgba(17, 28, 36, .58); backdrop-filter: blur(3px); }
.terms-dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.terms-dialog-header h2 { margin: 0; }
.terms-dialog-header button { padding: 8px 12px; }
.terms-scroll { max-height: calc(min(82dvh, 820px) - 70px); padding: 18px; overflow-y: auto; }
.terms-scroll h3 { margin: 0 0 14px; font-size: 1.05rem; }
.terms-scroll p { margin: 0 0 14px; line-height: 1.62; }
.terms-updated { color: var(--muted); font-size: .86rem; }
.admin-shell { width: min(1120px, calc(100% - 32px)); }
.hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(2rem, 5vw, 3.25rem); letter-spacing: -0.04em; white-space: nowrap; }
.title-suffix {
  display: inline-block;
  max-width: 0;
  overflow: hidden;
  color: #aeb4ba;
  vertical-align: bottom;
  white-space: nowrap;
  border-right: .055em solid currentColor;
  animation: type-suffix 3.15s steps(6, end) .4s 2 forwards, hide-caret .01s 6.82s forwards;
}
@keyframes type-suffix { to { max-width: 4em; } }
@keyframes hide-caret { to { border-right-color: transparent; } }
h2 { font-size: 1.1rem; }
.eyebrow { margin-bottom: 8px; color: var(--brand); font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.muted, .disclaimer { color: var(--muted); }
.messages { min-height: 300px; flex: 1; display: grid; align-content: end; gap: 14px; margin-bottom: 18px; overflow-y: auto; }
.message { max-width: 86%; padding: 16px 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 8px 24px rgba(19, 31, 42, .05); }
.message.user { justify-self: end; background: var(--soft); border-color: #c9dfd7; }
.message-body { margin-top: 6px; white-space: pre-wrap; line-height: 1.58; }
details { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
summary { cursor: pointer; color: var(--brand); font-weight: 700; }
blockquote { margin: 6px 0 12px; padding-left: 10px; border-left: 3px solid var(--line); color: var(--muted); }
.composer, .panel { padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 8px 24px rgba(19, 31, 42, .05); }
.composer textarea { width: 100%; resize: vertical; border: 0; outline: 0; font: inherit; line-height: 1.5; }
.composer-footer, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
button { border: 0; border-radius: 10px; padding: 11px 16px; color: white; background: var(--brand); font: inherit; font-weight: 750; cursor: pointer; }
button:hover { background: var(--brand-dark); }
button:disabled { opacity: .55; cursor: wait; }
button.secondary { color: var(--brand); background: var(--soft); }
.disclaimer { margin: 12px 4px; font-size: .86rem; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.panel { margin-bottom: 16px; }
.panel input { display: block; width: 100%; margin: 12px 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; }
.status { color: var(--brand); font-weight: 750; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
td:last-child { max-width: 320px; overflow-wrap: anywhere; }
.access-password-cell { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1rem; font-weight: 800; letter-spacing: .12em; white-space: nowrap; }
.question-cell { min-width: 300px; white-space: pre-wrap; line-height: 1.45; }
.empty-row { color: var(--muted); text-align: center; }
.notice { position: sticky; bottom: 16px; padding: 12px 16px; border-radius: 10px; background: var(--surface); }
.notice.success { color: #125f3f; background: #ddf5e9; }
.notice.error { color: #9b1c1c; background: #fee2e2; }
.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; }
@media (max-width: 680px) {
  body {
    height: 100dvh;
    overflow: hidden;
    background-position: 61% center;
    background-attachment: scroll;
  }
  .shell {
    width: min(100% - 24px, 520px);
    height: 100dvh;
    min-height: 0;
    margin: 0 auto;
    padding: 12px 0 8px;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
  }
  .access-gate { height: 100dvh; min-height: 0; padding: 12px; overflow-y: auto; }
  .access-card { padding: 18px; border-radius: 16px; }
  .access-card h2 { font-size: 1.2rem; }
  .resident-fields { gap: 8px; margin: 16px 0 10px; }
  .resident-fields select { padding: 0 7px; }
  .terms-consent { grid-template-columns: 1fr; margin-bottom: 10px; }
  .terms-link { justify-self: start; margin-left: 25px; }
  .password-row { grid-template-columns: 1fr; gap: 9px; margin-top: 13px; }
  .password-row button { width: 100%; }
  .hero { align-items: flex-start; flex-direction: row; gap: 10px; margin-bottom: 8px; }
  .hero > div { min-width: 0; }
  .eyebrow { margin-bottom: 3px; font-size: .72rem; }
  h1 { margin-bottom: 2px; font-size: clamp(2rem, 10.5vw, 2.7rem); }
  #welcome { margin-bottom: 0; font-size: .83rem; line-height: 1.25; }
  button.secondary { flex: none; padding: 8px 10px; font-size: .82rem; }
  .messages { min-height: 0; gap: 8px; margin-bottom: 8px; }
  .admin-grid { grid-template-columns: 1fr; }
  .admin-body { height: auto; min-height: 100dvh; overflow-y: auto; }
  .admin-shell { height: auto; min-height: 100dvh; display: flex; }
  .message { max-width: 96%; padding: 10px 12px; border-radius: 13px; font-size: .9rem; }
  .message-body { margin-top: 3px; line-height: 1.42; }
  .composer { padding: 10px 12px; border-radius: 14px; }
  .composer textarea { height: 48px; resize: none; font-size: .9rem; line-height: 1.35; }
  .composer-footer { gap: 8px; }
  .composer-footer button { padding: 8px 12px; font-size: .86rem; }
  .disclaimer { margin: 6px 2px 0; font-size: .68rem; line-height: 1.25; }
  .terms-dialog { max-height: 90dvh; }
  .terms-scroll { max-height: calc(90dvh - 62px); padding: 14px; }
}

@media (max-width: 680px) and (max-height: 700px) {
  .shell { padding-top: 8px; }
  .eyebrow { font-size: .66rem; }
  h1 { font-size: 1.9rem; }
  #welcome { font-size: .76rem; }
  .composer textarea { height: 38px; }
  .disclaimer { font-size: .62rem; }
}

@media (prefers-reduced-motion: reduce) {
  .title-suffix { max-width: 4em; border-right-color: transparent; animation: none; }
}
