.profile-gate {
  box-sizing: border-box;
  min-height: 100dvh;
  margin: 0;
  padding: 22px 14px;
  display: grid;
  place-items: center;
  background: #080e10;
  color: #eee1c8;
  font-family: Arial, Helvetica, sans-serif;
  color-scheme: dark;
}
.profile-gate::before {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(#040b0e8f, #050b0fc9), url('/assets/realm.jpg') center / cover;
  pointer-events: none;
}
.profile-panel {
  position: relative;
  box-sizing: border-box;
  width: min(100%, 510px);
  padding: clamp(16px, 5vw, 34px);
  border: 1px solid #b79a65a1;
  border-radius: 22px;
  background: linear-gradient(155deg, #142024f2, #081014ed);
  box-shadow: 0 24px 80px #0009, inset 0 1px #c4a67126;
  text-align: center;
}
.profile-monogram {
  display: block;
  width: clamp(70px, 16vw, 100px);
  height: auto;
  margin: 0 auto 12px;
  filter: drop-shadow(0 0 12px #e5b65058);
}
.profile-panel h1, .pin-panel h2 {
  margin: 0;
  color: #f1dbaf;
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 400;
}
.profile-panel h1 { font-size: clamp(24px, 6vw, 32px); }
.profile-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 4px;
  margin-top: 23px;
}
.profile-card {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 8px;
  min-width: 0;
  padding: 3px 2px;
  border: 0;
  background: none;
  color: #d8caaf;
  font: inherit;
  cursor: pointer;
}
.profile-name { overflow-wrap: anywhere; font-size: 13px; line-height: 1.2; }
.profile-avatar {
  --avatar-light: #dcb774;
  --avatar-dark: #172529;
  position: relative;
  display: inline-grid;
  flex: none;
  place-items: center;
  box-sizing: border-box;
  width: clamp(46px, 12vw, 68px);
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid #cbaa6b7a;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 24%, #9d764050, transparent 70%), var(--avatar-dark);
  box-shadow: inset 0 0 0 3px #12191d99;
  color: var(--avatar-light);
}
.profile-avatar[data-emblem="oak"] { --avatar-light:#e4c182; --avatar-dark:#28342c; }
.profile-avatar[data-emblem="crown"] { --avatar-light:#f3cc79; --avatar-dark:#342c23; }
.profile-avatar[data-emblem="leaf"] { --avatar-light:#bcceac; --avatar-dark:#1b3330; }
.profile-avatar[data-emblem="compass"] { --avatar-light:#a8c9d4; --avatar-dark:#1a2e36; }
.profile-avatar[data-emblem="book"] { --avatar-light:#e2aa88; --avatar-dark:#35271f; }
.profile-avatar[data-emblem="star"] { --avatar-light:#ded0ed; --avatar-dark:#2a2638; }
.profile-avatar svg { display:block; width:52%; height:52%; }
.profile-glyph { display:grid; position:absolute; inset:0; place-items:center; }
.profile-avatar img { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; }
.profile-card:hover .profile-avatar, .profile-card[aria-pressed="true"] .profile-avatar {
  border-color: #f5d38c;
  box-shadow: 0 0 0 3px #c8a46833, 0 0 19px #d4ac4e34;
}
.profile-card[aria-pressed="true"] { color:#f5d99b; }
.profile-card .profile-avatar.profile-failed {
  border-color: #fa8a7d;
  box-shadow: 0 0 0 3px #e2504847, 0 0 18px #f05b5666;
  animation: profile-shake .38s ease-out;
}
.profile-failed::after { content:""; position:absolute; inset:0; background:#e141424a; }
@keyframes profile-shake {
  0%, 100% { transform: translateX(0); }
  17% { transform: translateX(-8px); }
  34% { transform: translateX(7px); }
  52% { transform: translateX(-5px); }
  70% { transform: translateX(3px); }
  85% { transform: translateX(-2px); }
}
.profile-add .profile-avatar {
  border-style: dashed;
  background:#131d21;
  font: 30px / 1 Georgia, serif;
}
.pin-panel {
  margin: 21px auto 0;
  padding-top: 18px;
  border-top: 1px solid #bea16b4d;
}
.pin-panel h2 { font-size: 18px; overflow-wrap:anywhere; }
.pin-dots { display:flex; justify-content:center; gap:13px; margin:16px 0; }
.pin-dots i { width:9px; height:9px; border:1px solid #cbb183; border-radius:50%; }
.pin-dots .filled { background:#edca82; box-shadow:0 0 10px #f6bd5c50; }
.pin-pad {
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:7px;
  width:min(100%,280px);
  margin:auto;
}
.pin-pad button, .profile-primary, .profile-secondary {
  min-height:44px;
  padding:8px 13px;
  border:1px solid #b99b665f;
  border-radius:9px;
  background:linear-gradient(165deg,#233034,#101b21);
  color:#eddbb8;
  font:inherit;
  cursor:pointer;
}
.pin-pad button { font-size:20px; font-variant-numeric:tabular-nums; }
.pin-pad button[data-pin-action] { font-size:17px; color:#aa9d83; }
.pin-pad button:hover, .profile-secondary:hover { background:#283437; border-color:#d6b680; }
.profile-gate :is(button,input):focus-visible, .profile-fields :is(button,input):focus-visible {
  outline:2px solid #f2cd85;
  outline-offset:3px;
}
.profile-feedback { color:#f5a79b; font-size:13px; line-height:1.4; }
.profile-feedback:empty { display:none; }
.profile-visually-hidden, .emblem-option input {
  position:absolute;
  width:1px;
  height:1px;
  margin:-1px;
  overflow:hidden;
  clip-path:inset(50%);
  white-space:nowrap;
}
.profile-fields { display:grid; gap:12px; margin:18px 0 0; text-align:left; }
.profile-fields label:not(.emblem-option) { display:grid; gap:6px; font-size:13px; }
.profile-fields input:not([type="radio"]), .account-dialog input:not([type="radio"]) {
  box-sizing:border-box;
  width:100%;
  min-width:0;
  min-height:43px;
  padding:9px 10px;
  color:#f0e4c9;
  background:#081317;
  border:1px solid #b99b665f;
  border-radius:6px;
  font:16px Arial, Helvetica, sans-serif;
}
.profile-fields input[type="file"] { font-size:13px; }
.profile-choices { display:grid; min-width:0; gap:10px; margin:0; border:1px solid #b99b6644; border-radius:8px; padding:10px; }
.profile-choices legend { padding:0 5px; font-size:13px; }
.profile-preview { justify-self:center; }
.emblem-list { display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); justify-items:center; gap:4px; }
.emblem-option { cursor:pointer; }
.emblem-option .profile-avatar { width:clamp(27px,7vw,44px); }
.emblem-option input:checked + .profile-avatar { outline:2px solid #f2cd85; outline-offset:2px; }
.emblem-option input:focus-visible + .profile-avatar { outline:2px dashed #f2cd85; outline-offset:2px; }
.profile-remove-photo { justify-self:start; }
.profile-actions { display:flex; flex-wrap:wrap; gap:8px; }
.profile-primary { background:linear-gradient(145deg,#ecd09a,#be965a); color:#191912; font-weight:700; }
.profile-primary:hover { background:#efd097; }
.profile-gate [hidden], .account-dialog [hidden] { display:none!important; }
.profile-gate button:disabled, .account-dialog button:disabled { cursor:wait; opacity:.6; }

body.chronicle-readonly :is(#editMode,#editFromStory,#editToolbar,#importBackup,#restoreSnapshots) { display:none!important; }
.account-dialog {
  box-sizing:border-box;
  width:min(650px,calc(100vw - 24px));
  max-height:calc(100dvh - 24px);
  overflow:auto;
  padding:clamp(15px,4vw,27px);
  color:#eadfc7;
  background:#101819;
  border:1px solid #a88b55;
  border-radius:14px;
}
.account-dialog::backdrop { background:#000a; }
.account-dialog h2 { margin:0 36px 16px 0; font:26px Georgia,serif; }
.account-dialog .account-close { position:absolute; right:10px; top:9px; font-size:22px; }
.account-dialog :is(button,summary) { min-height:40px; cursor:pointer; }
.account-dialog #account-content { display:grid; gap:10px; }
.account-dialog .account-user { border:1px solid #a88b555c; border-radius:10px; padding:9px 11px; }
.account-dialog .account-user summary { display:flex; align-items:center; gap:9px; list-style:none; }
.account-user summary::-webkit-details-marker { display:none; }
.account-user summary::after { content:"⌄"; margin-left:auto; color:#e4bf7d; }
.account-user[open] summary::after { transform:rotate(180deg); }
.account-dialog .account-identity { display:flex; align-items:center; gap:10px; min-width:0; }
.account-identity .profile-avatar { width:38px; }
.account-identity div { min-width:0; overflow-wrap:anywhere; }
.account-identity small { display:block; margin-top:3px; color:#b5a58d; font-size:12px; }
.account-dialog .account-actions { display:flex; flex-wrap:wrap; gap:7px; margin-top:10px; }
.account-dialog .account-permission {
  display:inline-flex;
  align-items:center;
  gap:6px;
  border-radius:18px;
  border:1px solid #a88b55;
  padding:5px 12px;
}
.account-permission::before { content:""; width:10px; height:10px; border-radius:50%; background:#788582; }
.account-permission[aria-checked="true"]::before { background:#e8c27a; box-shadow:0 0 7px #ecc77b88; }
.account-dialog .account-feedback { color:#f0c595; font-size:13px; line-height:1.35; margin:0 0 8px; }
.account-feedback:empty { display:none; }
.account-dialog .new-pin { display:flex; flex-wrap:wrap; align-items:center; gap:9px; margin:0 0 12px; }
.new-pin output { color:#f3d598; font:700 23px/1.3 monospace; letter-spacing:.14em; user-select:all; }
/* Continue the existing chronicle opening while the browser navigates. */
.login-wave { position:fixed; z-index:5; inset:0; display:grid; place-items:center; background:#020608; }
.login-wave svg { width:min(82vw,1040px); overflow:visible; }
.login-wave path { fill:none; }
.wave-bed { stroke:#b79b67; stroke-opacity:.22; stroke-width:2; }
.wave-trace { stroke:#ffcf70; stroke-width:4; stroke-linecap:round; stroke-dasharray:1000; animation:trace-login 3.3s ease both; filter:drop-shadow(0 0 8px #e8a843); }
@keyframes trace-login { from { stroke-dashoffset:1000; } to { stroke-dashoffset:0; } }
@media (prefers-reduced-motion:reduce) {
  .profile-card .profile-avatar.profile-failed, .wave-trace { animation:none; }
}
