/* Hermeneia — standalone account pages
   Palette and type are taken from the app shell: warm paper, sage sidebar,
   ink-brown accents and the Georgia / Songti editorial serif. */

:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: #302d28;
  background: #f8f5ef;

  --paper: #f8f5ef;
  --sheet: #fffdf8;
  --sage: #ece9df;
  --sage-line: #d8d2c2;
  --ink: #302d28;
  --ink-soft: #544e43;
  --muted: #6f6659;
  --faint: #756c5e;
  --line: #ddd5c6;
  --line-strong: #cfc4b1;
  --brown: #8a5138;
  --brown-deep: #6f3f2b;
  --focus: #b5835e;
  --danger: #a14039;
  --success: #57664a;

  --serif: Georgia, "Noto Serif SC", "Source Han Serif SC", "Songti SC",
    SimSun, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;

  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background-color: var(--paper);
  background-image:
    linear-gradient(to right, rgba(122, 104, 78, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(122, 104, 78, 0.05) 1px, transparent 1px);
  background-size: 32px 32px;
  background-attachment: fixed;
  line-height: 1.7;
}

::selection {
  background: #e7d8c5;
  color: var(--ink);
}

a {
  color: var(--brown);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

a:focus-visible,
button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

/* ---------------------------------------------------------------------------
   Two-material shell: sage intro panel + paper form sheet
   --------------------------------------------------------------------------- */

.auth-shell {
  display: grid;
  grid-template-columns: minmax(360px, 43%) minmax(0, 1fr);
  min-height: 100dvh;
  background:
    linear-gradient(
      90deg,
      #efede3 0%,
      #eae7db 43%,
      #d8d2c2 43%,
      #d8d2c2 calc(43% + 1px),
      transparent calc(43% + 1px)
    );
}

.auth-aside {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100dvh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  padding: 38px clamp(32px, 4.6vw, 74px) 36px;
}

.aside-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: #463b2e;
  text-decoration: none;
}

.brand svg {
  width: 34px;
  height: 38px;
  flex: none;
  color: #986247;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-family: Georgia, serif;
  font-size: 25px;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: #3b3228;
}

.brand-tag {
  margin-top: 7px;
  font-family: var(--serif);
  font-size: 10px;
  line-height: 1.5;
  letter-spacing: 0.06em;
  color: #6b6152;
}

.aside-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.5;
  color: #665c4d;
  white-space: nowrap;
}

.dot {
  width: 5px;
  height: 5px;
  flex: none;
  border-radius: 50%;
  background: #7f8d70;
}

.aside-body {
  margin: auto 0;
  padding: 48px 0 40px;
  max-width: 25em;
}

.aside-title {
  margin: 0 0 18px;
  font-family: var(--serif);
  font-size: clamp(29px, 2.5vw, 38px);
  font-weight: 500;
  line-height: 1.55;
  letter-spacing: 0;
  color: #332e26;
}

.aside-lede {
  margin: 0;
  font-family: var(--serif);
  font-size: 15px;
  line-height: 2;
  color: #5f5749;
}

.steps {
  list-style: none;
  margin: 42px 0 0;
  padding: 0;
  border-top: 1px solid rgba(84, 74, 58, 0.18);
}

.steps li {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 2px 14px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(84, 74, 58, 0.13);
}

.steps .num {
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.7;
  color: var(--brown);
}

.steps strong {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: 0.02em;
  color: #3b342a;
}

.steps p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.8;
  color: #6c6355;
}

.aside-foot {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding-top: 10px;
  font-size: 11px;
  line-height: 1.6;
  color: #6b6152;
}

/* ---------------------------------------------------------------------------
   Paper side
   --------------------------------------------------------------------------- */

.auth-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 30px clamp(24px, 4.6vw, 68px) 48px;
}

.auth-content {
  width: 100%;
  max-width: 560px;
  margin: auto;
  padding: 40px 0;
}

.auth-title {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: clamp(32px, 3vw, 41px);
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.01em;
  color: #2f2b24;
}

.auth-lede {
  max-width: 34em;
  margin: 0 0 38px;
  font-size: 14.5px;
  line-height: 1.9;
  color: #6f6659;
}

.auth-back {
  font-size: 12.5px;
  line-height: 1.6;
  color: #6b6152;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
}

.auth-back:hover {
  color: var(--ink);
  border-bottom-color: var(--line-strong);
}

/* ---------------------------------------------------------------------------
   Form
   --------------------------------------------------------------------------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin: 0;
}

.field {
  min-width: 0;
}

.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.02em;
  color: #3d362c;
  cursor: pointer;
}

.count {
  font-size: 11px;
  line-height: 1.5;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.count[data-state="near"],
.count[data-state="over"] {
  color: var(--danger);
}

.count[data-state="over"] {
  font-weight: 600;
}

.input {
  display: block;
  width: 100%;
  height: 50px;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--sheet);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.4;
  box-shadow: 0 1px 2px rgba(80, 60, 40, 0.03);
  transition: border-color 0.15s ease, box-shadow 0.15s ease,
    background-color 0.15s ease;
}

.input:hover {
  border-color: #c2b5a2;
}

.input:focus {
  outline: none;
  border-color: #a97a58;
  box-shadow: 0 0 0 3px rgba(181, 131, 94, 0.18),
    0 1px 2px rgba(80, 60, 40, 0.04);
}

.input:disabled {
  color: #8c8273;
  background: #f2eee4;
  cursor: not-allowed;
}

input::placeholder,
textarea::placeholder {
  color: #766c5e;
  opacity: 1;
}

input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--sheet) inset;
  -webkit-text-fill-color: var(--ink);
  transition: background-color 9999s ease-out;
}

/* The note is the centrepiece: a sheet of graph paper, not a browser textarea. */

.field--note {
  margin-top: 2px;
}

.field--note .field-head {
  margin-bottom: 10px;
}

.field--note label {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0;
  color: #332e26;
}

.note-box {
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--sheet);
  box-shadow: 0 1px 2px rgba(80, 60, 40, 0.03);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.note-box:hover {
  border-color: #c2b5a2;
}

.note-box:focus-within {
  border-color: #a97a58;
  box-shadow: 0 0 0 3px rgba(181, 131, 94, 0.18),
    0 1px 2px rgba(80, 60, 40, 0.04);
}

.note-field {
  position: relative;
  height: 250px;
  overflow: hidden;
  background-color: var(--sheet);
  background-image:
    linear-gradient(to right, rgba(122, 104, 78, 0.055) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(122, 104, 78, 0.055) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* Text fades into the paper at the bottom while there is more to scroll;
   the scrollbar itself is hidden. Removed once the end is reached. */
.note-field::after {
  content: "";
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: 0;
  left: 0;
  height: 56px;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(255, 253, 248, 0) 0%,
    rgba(255, 253, 248, 0.86) 58%,
    #fffdf8 100%
  );
  opacity: 1;
  transition: opacity 0.16s ease;
}

.note-field.is-at-end::after {
  opacity: 0;
}

.note-box textarea {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 14px 18px;
  border: 0;
  border-radius: 0;
  resize: none;
  outline: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  line-height: 32px;
  overflow-y: auto;
  overflow-wrap: anywhere;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.note-box textarea::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.note-box textarea::placeholder {
  color: transparent;
}

.note-ghost {
  position: absolute;
  z-index: 0;
  top: 14px;
  right: 18px;
  left: 18px;
  pointer-events: none;
  color: #766c5e;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 32px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  will-change: transform;
}

.note-field textarea:not(:placeholder-shown) + .note-ghost {
  display: none;
}

.note-box textarea:disabled {
  color: #8c8273;
}

.note-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 16px;
  border-top: 1px solid #e7e0d3;
  background: rgba(248, 245, 239, 0.6);
}

.note-hint {
  font-size: 12.5px;
  line-height: 1.7;
  color: #5f5749;
}

/* Submit */

.submit {
  display: block;
  width: 100%;
  height: 52px;
  margin: 4px 0 0;
  padding: 0 20px;
  border: 1px solid var(--brown);
  border-radius: 8px;
  background: var(--brown);
  color: #fffaf4;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    transform 0.1s ease;
}

.submit:hover {
  background: var(--brown-deep);
  border-color: var(--brown-deep);
}

.submit:active {
  transform: translateY(1px);
}

.submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.status {
  min-height: 1.6em;
  margin: -8px 0 0;
  font-size: 13px;
  line-height: 1.8;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.status.is-error {
  color: var(--danger);
}

.status.is-success {
  color: var(--success);
}

.fineprint {
  margin: 26px 0 0;
  font-size: 11.5px;
  line-height: 1.9;
  color: var(--faint);
}

.fineprint--rule {
  margin-top: 38px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

/* ---------------------------------------------------------------------------
   Login-specific pieces
   --------------------------------------------------------------------------- */

.reset {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.reset summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: max-content;
  max-width: 100%;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--brown);
  cursor: pointer;
  list-style: none;
}

.reset summary::-webkit-details-marker {
  display: none;
}

.reset summary::after {
  content: "＋";
  font-size: 12px;
  line-height: 1;
  color: #a98d72;
}

.reset[open] summary {
  margin-bottom: 18px;
}

.reset[open] summary::after {
  content: "－";
}

.reset .form {
  gap: 18px;
}

.apply-entry {
  margin: 26px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.8;
  color: var(--muted);
}

.apply-entry a {
  color: var(--brown);
  text-underline-offset: 4px;
}

/* ---------------------------------------------------------------------------
   Simple link-landing pages (email confirmation, account action)
   --------------------------------------------------------------------------- */

.simple-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: 30px clamp(24px, 5vw, 64px) 44px;
}

.simple-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.simple-main {
  width: 100%;
  max-width: 520px;
  margin: auto;
  padding: 48px 0;
}

.simple-main .auth-title {
  font-size: clamp(28px, 4vw, 34px);
}

.simple-main .auth-lede {
  margin-bottom: 30px;
}

.simple-main .form {
  margin-top: 4px;
}

.simple-links {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 30px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.simple-links a {
  color: var(--brown);
  text-underline-offset: 4px;
}

.simple-links span {
  color: var(--line-strong);
}

.simple-back {
  display: inline-block;
  margin-top: 30px;
  font-size: 12.5px;
}

/* ---------------------------------------------------------------------------
   Research consent gate on the application page
   --------------------------------------------------------------------------- */

body.consent-open {
  overflow: hidden;
}

.consent {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(48, 45, 40, 0.55);
  backdrop-filter: blur(4px);
}

.consent[hidden] {
  display: none;
}

.consent-panel {
  width: min(620px, 100%);
  max-height: min(88dvh, 820px);
  overflow: auto;
  padding: 34px 38px 30px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 0 24px 80px rgba(48, 45, 40, 0.24);
}

.consent-title {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 500;
  line-height: 1.45;
  color: #2f2b24;
}

.consent-lede {
  margin: 0 0 22px;
  font-size: 14px;
  line-height: 1.9;
  color: var(--muted);
}

.consent-body {
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.consent-body section {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.consent-body section:last-child {
  border-bottom: 0;
}

.consent-body h3 {
  margin: 0 0 7px;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.6;
  color: #332e26;
}

.consent-body p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.95;
  color: var(--muted);
}

.consent-foot {
  margin: 20px 0 0;
  font-size: 12px;
  line-height: 1.8;
  color: var(--faint);
}

.consent-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
  margin-top: 20px;
}

.consent-reject {
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}

.consent-reject:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.consent-accept {
  width: auto;
  min-width: 160px;
  height: 46px;
  padding: 0 22px;
  font-size: 14px;
}

/* ---------------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------------- */

@media (max-width: 880px) {
  .auth-shell {
    display: block;
    background: none;
  }

  .auth-aside {
    position: static;
    height: auto;
    overflow: visible;
    background: linear-gradient(180deg, #efede3 0%, #eae7db 100%);
    border-bottom: 1px solid var(--sage-line);
    padding: 26px 24px 24px;
  }

  .brand svg {
    width: 30px;
    height: 34px;
  }

  .brand-name {
    font-size: 22px;
  }

  .aside-body {
    max-width: none;
    margin: 0;
    padding: 26px 0 0;
  }

  .aside-title {
    font-size: clamp(27px, 7vw, 32px);
    margin-bottom: 8px;
  }

  .aside-lede {
    font-size: 13.5px;
    line-height: 1.9;
  }

  .steps {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin-top: 18px;
    border-top: 0;
  }

  .steps li {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 0;
    border-bottom: 0;
  }

  .steps strong {
    margin: 0;
    font-size: 11.5px;
    font-weight: 500;
  }

  .steps p {
    display: none;
  }

  .steps .num {
    font-size: 11.5px;
  }

  .aside-foot {
    display: none;
  }

  .auth-panel {
    display: block;
    padding: 26px 24px 42px;
  }

  .auth-content {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .auth-title {
    font-size: 32px;
  }

  .auth-lede {
    margin-bottom: 30px;
    font-size: 14px;
  }

  .form {
    gap: 20px;
  }

  .note-field {
    height: 220px;
  }

  .note-box textarea {
    padding: 12px 15px;
  }

  .note-ghost {
    top: 12px;
    right: 15px;
    left: 15px;
  }

  .note-field::after {
    height: 48px;
  }

  .note-foot {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
    padding: 10px 15px;
  }

  .note-foot .count {
    align-self: flex-end;
  }

  .submit {
    height: 50px;
  }

  .simple-shell {
    padding: 22px 24px 36px;
  }

  .simple-main {
    padding: 32px 0;
  }

  .simple-main .auth-title {
    font-size: 29px;
  }

  .consent {
    align-items: flex-end;
    padding: 16px;
  }

  .consent-panel {
    max-height: 88dvh;
    padding: 24px 22px 22px;
  }

  .consent-title {
    font-size: 23px;
  }

  .consent-body p {
    font-size: 13px;
  }

  .consent-actions {
    gap: 14px;
  }

  .consent-accept {
    min-width: 0;
    flex: 1;
    padding: 0 18px;
  }
}

@media (max-width: 380px) {
  .aside-badge {
    display: none;
  }

  .steps {
    gap: 5px 14px;
  }

  .field-head {
    gap: 10px;
  }
}

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