:root {
  color-scheme: dark;
  --paper: #141423;
  --sheet: #1c1e31;
  --ink: #f5f2fe;
  --muted: #bbbcdb;
  --rule: #40415b;
  --blue: #b5bdff;
  --yellow: #ffe365;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; padding: 0 clamp(14px, 4vw, 40px) 48px; background: radial-gradient(ellipse at 12% 0, #292341, transparent 56%); }
button, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; }

.password-top, .password-layout { max-width: 1080px; margin: auto; }
.password-top {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 18px 0; border-bottom: 1px solid var(--rule);
}
.password-top a { text-decoration: none; color: var(--ink); }
.password-brand { font-weight: 850; font-size: .85rem; letter-spacing: .12em; }
.password-brand span, .password-heading h1 span { color: var(--blue); }
.password-top .password-back { font-weight: 650; padding: 8px 0; }
.password-back:hover { color: var(--blue); }

.password-heading { padding: clamp(24px, 4vw, 39px) 0 22px; }
.password-heading h1 {
  margin: 0;
  font-size: clamp(2.25rem, 6vw, 4.6rem);
  line-height: .98; letter-spacing: -.055em; font-weight: 850;
}
.password-heading p { margin: 13px 0 0; color: var(--muted); font-size: clamp(.92rem, 2vw, 1.12rem); }

.password-chapters {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--rule); border-radius: 11px; margin-bottom: 16px;
  overflow: hidden; background: var(--sheet);
}
.password-chapter {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: 8px; padding: 12px; color: var(--muted);
}
.password-chapter + .password-chapter { border-left: 1px solid var(--rule); }
.password-chapter.current { background: var(--yellow); color: #171627; }
.password-chapter.complete:not(.current) { color: var(--blue); }
.password-chapter > span, .password-chapter small, .password-count,
.password-active-index, .password-rule-number, #password-progress {
  font-family: Consolas, "Courier New", monospace; font-variant-numeric: tabular-nums;
}
.password-chapter > span, .password-chapter small { font-size: .78rem; white-space: nowrap; }

.password-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); align-items: start; gap: 16px; }
.password-work, .password-vault { border: 1px solid var(--rule); border-radius: 15px; min-width: 0; }
.password-work { background: var(--sheet); padding: clamp(16px, 3vw, 32px); }
.password-live {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start;
  gap: 14px; margin-bottom: 22px; padding-bottom: 22px; border-bottom: 1px solid var(--rule);
}
.password-active-index {
  display: grid; place-items: center; min-width: 43px; min-height: 43px;
  border-radius: 8px; font-weight: 800; background: var(--yellow); color: #171627;
}
.password-live[data-rule="-1"] .password-active-index { background: var(--blue); color: #161a41; }
.password-live h2 { margin: 0 0 5px; font-size: clamp(1.32rem, 2.8vw, 1.85rem); line-height: 1.13; letter-spacing: -.04em; }
.password-current-rule { margin: 0; overflow-wrap: anywhere; }
summary { cursor: pointer; font-weight: 650; }
.password-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.password-line label { font-weight: 750; }
.password-count { display: inline-flex; align-items: baseline; gap: 6px; color: var(--muted); font-size: .76rem; white-space: nowrap; }
.password-count strong { display: inline-block; color: var(--yellow); font-size: 1.4rem; line-height: 1; }
textarea {
  display: block; width: 100%; min-height: 86px; padding: 12px 14px; resize: vertical;
  color: var(--ink); background: #111222; border: 1px solid #6f7090; border-radius: 8px;
  font: 1.06rem/1.55 Consolas, "Courier New", monospace; overflow-wrap: anywhere;
}
textarea::placeholder { color: #a4a5c2; }
.password-keys { display: flex; flex-wrap: wrap; gap: 6px; margin-block: 9px; }
.password-keys button {
  min-width: 36px; min-height: 38px; padding: 2px 8px; border: 1px solid #66678a;
  border-bottom-width: 2px; border-radius: 6px; background: var(--sheet); color: var(--blue);
}
.password-keys button:hover { background: #393d68; border-color: var(--blue); }
.password-keys button:active { transform: translateY(1px); }
.password-note { margin: 12px 0 16px; color: var(--muted); font-size: .81rem; line-height: 1.45; }
.password-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; }
.password-actions button { min-height: 43px; padding: 8px 14px; border-radius: 7px; font-weight: 720; }
.password-primary { border: 1px solid var(--yellow); background: var(--yellow); color: #201a29; }
.password-primary:not(:disabled):hover { background: #fff0a4; }
.password-primary:disabled { border-color: var(--rule); background: #2b2b43; color: #b8b7cf; }
.password-subtle { border: 1px solid transparent; background: transparent; color: var(--blue); }
.password-subtle:hover { border-color: #777aa4; background: #2a2d49; }

.password-side { min-width: 0; display: grid; gap: 12px; }
.password-chart {
  display: block; width: min(100%, 360px); height: auto; margin: 12px 0 0;
  border: 1px solid #535b86; border-radius: 8px;
}

.password-vault {
  display: grid; grid-template-columns: 92px minmax(0, 1fr); min-height: 88px; overflow: hidden;
  align-self: stretch; background: #263acc; border-color: #2539bf; color: white;
}
.password-vault picture { position: relative; min-width: 0; }
.password-vault img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.password-vault-status {
  display: grid; grid-template-columns: 1fr auto; align-content: center; align-items: baseline; gap: 9px;
  padding: 11px 14px; background: #272453;
}
#password-progress { color: #f4f1ff; font-size: .88rem; }
#password-meter {
  width: 100%; height: 6px; grid-column: 1 / -1; border: 0; border-radius: 6px;
  overflow: hidden; accent-color: var(--yellow); background: #4f5cb7;
}
#password-meter::-webkit-progress-bar { background: #4f5cb7; }
#password-meter::-webkit-progress-value { background: var(--yellow); }
#password-meter::-moz-progress-bar { background: var(--yellow); }
.password-vault[data-state="open"] .password-vault-status { background: var(--yellow); color: #171627; }
.password-vault[data-state="open"] #password-progress { color: #171627; }
.password-vault[data-state="open"] #password-meter { accent-color: var(--blue); }
.password-vault[data-state="open"] #password-meter::-webkit-progress-value { background: var(--blue); }
.password-vault[data-state="open"] #password-meter::-moz-progress-bar { background: var(--blue); }

.password-rules { padding: 0 14px; border: 1px solid var(--rule); border-radius: 12px; background: var(--sheet); }
.password-rules > h2 { margin: 0; padding: 13px 0; color: var(--ink); font-size: 1rem; }
.password-list { list-style: none; padding: 0 4px 0 0; margin: 0; border-top: 1px solid var(--rule); max-height: 390px; overflow: auto; }
.password-list li { padding: 10px 4px; }
.password-list li:not(.passed) > div { color: var(--ink); }
.password-list li + li { border-top: 1px solid var(--rule); }
.password-list li > div { display: flex; align-items: baseline; gap: 9px; }
.password-list h3 { margin: 0; font-size: .96rem; flex: 1; }
.password-rule-number { color: var(--blue); font-size: .83rem; }
.password-rule-state { color: #ffafbb; font-size: .76rem; text-align: right; }
.passed .password-rule-state { color: #a8e3ab; }
.password-list p { margin: 6px 0 0; color: var(--muted); font-size: .9rem; line-height: 1.4; }
.password-list .passed > p { display: none; }
.password-announcement { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

dialog {
  width: min(425px, calc(100% - 28px)); max-width: none; padding: 22px;
  border: 1px solid var(--rule); border-radius: 15px; background: var(--sheet); color: var(--ink);
}
dialog::backdrop { background: #161b3cb8; }
dialog h2 { margin: 0; letter-spacing: -.04em; }
dialog p { margin: 8px 0 18px; color: var(--muted); }
.password-exit { display: inline-flex; align-items: center; min-height: 43px; padding: 8px 14px; border-radius: 7px; font-weight: 720; text-decoration: none; }
.password-victory-art { overflow: hidden; border-radius: 8px; margin-bottom: 16px; }
.password-victory-art img { display: block; width: 100%; height: auto; aspect-ratio: 16/9; object-fit: cover; }
@media (prefers-reduced-motion: no-preference) {
  dialog[open] { animation: arrive 180ms ease-out; }
  @keyframes arrive { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
  dialog[open] .password-victory-art img { animation: vault-open 560ms cubic-bezier(.22,1,.36,1) both; }
  @keyframes vault-open { from { opacity: .53; transform: scale(1.13); } to { opacity: 1; transform: none; } }
}
@media (min-width: 900px) {
  .password-live:has(.password-chart:not([hidden])) > div {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 14px; align-content: start;
  }
  .password-live:has(.password-chart:not([hidden])) > div > :not(canvas) { grid-column: 1; }
  .password-live .password-chart { grid-column: 2; grid-row: 1 / span 4; margin: 0; }
}
@media (max-width: 700px) {
  .password-grid { grid-template-columns: 1fr; gap: 12px; }
  .password-chapter { grid-template-columns: minmax(0, 1fr); gap: 4px; padding: 8px; font-size: .82rem; }
  .password-chapter > span { display: none; }
  .password-heading { padding-bottom: 17px; }
  .password-vault { grid-template-columns: 82px minmax(0, 1fr); }
  .password-live { gap: 10px; margin-bottom: 15px; padding-bottom: 15px; }
}
