:root {
  --bg: #f7f3ea;
  --panel: #fffaf2;
  --panel-soft: #f1eadf;
  --ink: #28231d;
  --muted: #746b60;
  --line: #ded3c2;
  --section-line: #e7ddd0;
  --accent: #7f6245;
  --button: #28231d;
  --button-ink: #fffaf2;
  --button-hover: #3b332a;
  --danger: #a43d32;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  scrollbar-gutter: stable;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

* {
  scrollbar-width: thin;
  scrollbar-color: #4fb4d8 rgba(79, 180, 216, 0.12);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: rgba(79, 180, 216, 0.12);
}

*::-webkit-scrollbar-thumb {
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background: #4fb4d8;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  touch-action: manipulation;
}

button,
input,
select,
textarea {
  font: inherit;
  font-size: 16px;
  touch-action: manipulation;
}

a {
  color: inherit;
}

.material-symbols-outlined {
  display: inline-block;
  flex: 0 0 auto;
  width: 1em;
  overflow: hidden;
  font-family: "Material Symbols Outlined";
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
  direction: ltr;
  vertical-align: middle;
  font-feature-settings: "liga";
  -webkit-font-feature-settings: "liga";
}

.public-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 72px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.public-brand {
  display: flex;
  align-items: center;
}

.public-brand img {
  width: 150px;
  max-height: 42px;
  object-fit: contain;
}

.public-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  min-width: 0;
}

.public-nav a,
.nav-list a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 5px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.public-nav a:hover,
.public-nav a[aria-current="page"],
.nav-list a:hover,
.nav-list a[aria-current="page"] {
  background: color-mix(in srgb, var(--accent) 16%, var(--panel));
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.mobile-nav-button {
  display: none;
}

.scripta-hero {
  display: grid;
  height: clamp(300px, 46vh, 520px);
  place-items: center;
  background:
    linear-gradient(rgba(238, 231, 218, 0.48), rgba(238, 231, 218, 0.48)),
    url("https://images.unsplash.com/photo-1611079829529-fe31a9531295?q=80&w=1170&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D") center center / cover no-repeat;
}

.scripta-hero img {
  width: min(300px, 76vw);
  height: auto;
}

.page-main {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 18px 16px 56px;
}

.intro-panel,
.privacy-notice,
.scripta-form {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.intro-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 340px);
  gap: 20px;
  align-items: start;
  padding: 22px;
}

.intro-copy {
  max-width: 640px;
}

.intro-preview {
  display: grid;
  gap: 10px;
  margin: 0;
}

.intro-preview span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.intro-preview img {
  width: 100%;
  max-height: 460px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.markdown-body {
  line-height: 1.65;
}

.markdown-body p:first-child,
.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child {
  margin-top: 0;
}

.privacy-notice {
  margin: 14px 0;
  padding: 16px 18px;
  color: var(--danger);
  font-size: 14px;
}

.scripta-form {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.profile-box {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--section-line);
  border-radius: 6px;
  background: var(--panel-soft);
}

.profile-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

.help {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid var(--button);
  border-radius: 5px;
  background: var(--button);
  color: var(--button-ink);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: var(--button-hover);
}

.button.secondary {
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
}

.button.secondary:hover {
  background: var(--panel-soft);
}

.form-actions {
  display: grid;
  gap: 10px;
  padding-top: 8px;
}

.danger-link {
  justify-self: center;
  border: 0;
  background: transparent;
  color: var(--danger);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

dialog {
  position: fixed;
  inset: 0;
  width: min(380px, calc(100vw - 32px));
  max-height: min(680px, calc(100dvh - 32px));
  margin: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  overflow: auto;
  scrollbar-gutter: stable;
}

.dialog-close-form {
  position: absolute;
  top: 10px;
  right: 10px;
  margin: 0;
}

.dialog-close {
  width: 34px;
  height: 34px;
}

dialog .nav-list {
  display: grid;
  gap: 6px;
  padding-top: 38px;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#printArea {
  display: none;
}

@media (max-width: 900px) {
  .public-topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 76px;
    padding: 14px 20px;
  }

  .public-nav {
    display: none;
  }

  .mobile-nav-button {
    display: inline-grid;
  }

  .scripta-hero {
    height: clamp(240px, 38vh, 360px);
  }

  .page-main {
    padding: 8px 8px 32px;
  }

  .profile-controls {
    grid-template-columns: 1fr;
  }

  .scripta-form {
    padding: 16px;
  }

  .intro-panel {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 18px 16px;
  }

  .intro-copy {
    max-width: none;
  }

  .intro-preview img {
    max-height: none;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  html,
  body {
    width: 210mm;
    height: 297mm;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;
    background: white;
  }

  body > *:not(#printArea) {
    display: none !important;
  }

  #printArea {
    display: block !important;
    width: 210mm;
    height: 297mm;
    padding: 13mm 17mm;
    box-sizing: border-box;
    font-family: serif;
    background: white;
  }

  .vaultDocument {
    width: 100%;
    height: 271mm;
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
  }

  .vaultHeader {
    text-align: center;
    margin-bottom: 6mm;
  }

  .vaultLogo {
    width: 175mm;
    max-height: 28mm;
    object-fit: contain;
    display: block;
    margin: 0 auto 3mm auto;
  }

  .vaultTitle {
    font-size: 10pt;
    font-weight: bold;
    line-height: 1.1;
  }

  .vaultSubtitle {
    font-size: 9pt;
    color: #555;
    margin-top: 1.5mm;
  }

  .vaultDataBox {
    border-top: 1px solid #aaa;
    border-bottom: 1px solid #aaa;
    padding: 4mm 0;
    margin-bottom: 5mm;
  }

  .vaultDataGrid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5mm 10mm;
    font-size: 9pt;
    line-height: 1.25;
  }

  .vaultMiniLabel,
  .vaultChoiceTitle {
    font-size: 7.2pt;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #555;
    font-weight: bold;
  }

  .vaultMiniValue {
    font-size: 9.5pt;
    font-weight: bold;
    color: #111;
  }

  .vaultChoices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5mm;
    margin: 5mm 0;
  }

  .vaultChoice {
    border: 1px solid #bbb;
    padding: 3.5mm;
    font-size: 9.5pt;
    line-height: 1.35;
    min-height: 18mm;
    box-sizing: border-box;
  }

  .vaultChoiceText {
    font-weight: bold;
    margin-top: 1.5mm;
  }

  .vaultMessage {
    margin-top: 4mm;
    padding-top: 4mm;
    border-top: 1px solid #aaa;
    font-size: 9.7pt;
    line-height: 1.42;
    white-space: pre-line;
  }

  .vaultMessageTitle {
    font-size: 8pt;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: bold;
    margin-bottom: 3mm;
  }

  .vaultDate {
    position: absolute;
    left: 0;
    bottom: 31mm;
    font-size: 8.5pt;
    color: #555;
  }

  .vaultSignature {
    position: absolute;
    right: 0;
    bottom: 22mm;
    width: 70mm;
    font-size: 9pt;
    text-align: center;
  }

  .vaultFooter {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    font-size: 7pt;
    color: #555;
    text-align: center;
    line-height: 1.35;
  }
}
