:root {
  color-scheme: light;
  --bg: #f4f4ef;
  --paper: #fffdf7;
  --paper-soft: rgba(255, 253, 247, 0.64);
  --paper-strong: #ffffff;
  --ink: #151515;
  --muted: #66645d;
  --faint: #8b887e;
  --line: rgba(21, 21, 21, 0.1);
  --line-strong: rgba(21, 21, 21, 0.16);
  --accent: #176b63;
  --accent-strong: #0e4f49;
  --accent-soft: rgba(23, 107, 99, 0.12);
  --blue: #295bdb;
  --success: #176b33;
  --warning: #a06119;
  --focus: rgba(41, 91, 219, 0.42);
  --radius-outer: 18px;
  --radius-middle: 12px;
  --radius-inner: 8px;
  --shadow-surface:
    0 0 0 1px rgba(21, 21, 21, 0.07),
    0 1px 2px rgba(21, 21, 21, 0.05),
    0 14px 34px rgba(21, 21, 21, 0.055);
  --shadow-control:
    0 0 0 1px rgba(21, 21, 21, 0.07),
    0 1px 2px rgba(21, 21, 21, 0.05);
  font-family: "Avenir Next", Avenir, ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  min-width: 320px;
  height: 100svh;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--bg);
}

p,
label,
button {
  text-wrap: pretty;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

#security-field {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  opacity: 1;
  pointer-events: none;
}

#security-field canvas {
  display: block;
}

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  height: 100svh;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.generator {
  display: grid;
  grid-template-areas:
    "header"
    "output"
    "controls";
  grid-template-rows: auto auto 1fr;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0 auto;
  overflow: hidden;
}

.app-header {
  grid-area: header;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  min-height: 76px;
  padding: max(14px, env(safe-area-inset-top)) 20px 12px;
}

.brand {
  display: grid;
  gap: 7px;
  justify-items: center;
  min-width: 0;
}

.eyebrow,
.status {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.48);
  color: var(--accent-strong);
  font-weight: 650;
  box-shadow: var(--shadow-control);
}

.eyebrow svg {
  width: 0.95rem;
  height: 0.95rem;
}

h1 {
  margin: 0;
  font-size: clamp(1.42rem, 7vw, 2.1rem);
  font-weight: 760;
  letter-spacing: 0;
  line-height: 1.02;
  text-align: center;
  text-wrap: balance;
}

.icon-button,
.primary-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  color: var(--ink);
  transition-property: background-color, box-shadow, opacity, transform, color;
  transition-duration: 180ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.output-panel {
  grid-area: output;
  display: grid;
  grid-template-rows: auto auto;
  align-content: start;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  padding: 12px 20px 18px;
}

.section-label,
.options legend {
  color: var(--faint);
  font-size: 0.76rem;
  font-weight: 760;
  letter-spacing: 0.075em;
  line-height: 1;
  text-transform: uppercase;
}

.output-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: start;
  gap: 12px;
  min-height: 0;
  overflow: visible;
  border-bottom: 1px solid rgba(21, 21, 21, 0.12);
}

.password {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  width: 100%;
  min-width: 0;
  padding: 8px 0 14px;
  overflow: visible;
  overflow-wrap: anywhere;
  word-break: break-word;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #101210;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", ui-monospace, monospace;
  font-size: 1.08rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.42;
}

.password.is-refreshing {
  animation: password-refresh 220ms cubic-bezier(0.2, 0, 0, 1);
}

.password-character {
  display: inline-block;
  opacity: 0;
  filter: blur(4px);
  transform: translateY(10px) rotateX(-35deg);
  transform-origin: 50% 70%;
  animation: password-character-enter 520ms cubic-bezier(0.2, 0, 0, 1) forwards;
  animation-delay: calc(var(--character-index) * 18ms);
}

.icon-button {
  align-self: start;
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  margin-top: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.42);
  color: var(--accent-strong);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-control);
}

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

.icon-button:active,
.primary-button:active {
  transform: scale(0.96);
}

.copy-state {
  grid-area: 1 / 1;
  display: inline-grid;
  place-items: center;
  transition-property: opacity, filter, scale;
  transition-duration: 260ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.copy-state-success,
.icon-button.is-copied .copy-state-default {
  opacity: 0;
  filter: blur(4px);
  scale: 0.25;
}

.copy-state-default,
.icon-button.is-copied .copy-state-success {
  opacity: 1;
  filter: blur(0);
  scale: 1;
}

.controls-panel {
  grid-area: controls;
  display: grid;
  align-content: start;
  gap: 16px;
  min-width: 0;
  min-height: 0;
  padding: 10px 20px calc(18px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 46%);
}

.control {
  display: grid;
  gap: 10px;
}

.control-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.96rem;
  font-weight: 640;
}

#length-value {
  color: var(--accent-strong);
}

.control-label output,
.strength-strip,
.status {
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  height: 42px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--accent) 0 var(--range-progress, 18%), rgba(21, 21, 21, 0.1) var(--range-progress, 18%) 100%);
}

input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--accent) 0 var(--range-progress, 18%), rgba(21, 21, 21, 0.1) var(--range-progress, 18%) 100%);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 24px;
  height: 24px;
  margin-top: -9px;
  border: 5px solid var(--paper-strong);
  border-radius: 50%;
  background: var(--accent);
  box-shadow:
    0 0 0 1px rgba(21, 21, 21, 0.1),
    0 5px 14px rgba(23, 107, 99, 0.26);
  transition-property: transform, box-shadow;
  transition-duration: 160ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 5px solid var(--paper-strong);
  border-radius: 50%;
  background: var(--accent);
  box-shadow:
    0 0 0 1px rgba(21, 21, 21, 0.1),
    0 5px 14px rgba(23, 107, 99, 0.26);
  transition-property: transform, box-shadow;
  transition-duration: 160ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

input[type="range"]:hover::-webkit-slider-thumb {
  transform: scale(1.08);
  box-shadow:
    0 0 0 1px rgba(21, 21, 21, 0.12),
    0 7px 20px rgba(23, 107, 99, 0.32);
}

input[type="range"]:hover::-moz-range-thumb {
  transform: scale(1.08);
  box-shadow:
    0 0 0 1px rgba(21, 21, 21, 0.12),
    0 7px 20px rgba(23, 107, 99, 0.32);
}

.strength-strip {
  display: flex;
  justify-content: center;
  gap: 5px;
  min-height: 44px;
  align-items: center;
  padding: 0 18px;
  border-radius: var(--radius-inner);
  background: var(--paper-soft);
  box-shadow: var(--shadow-control);
  backdrop-filter: blur(10px);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
  text-align: center;
}

.length-entry {
  width: 3ch;
  min-width: 44px;
  height: 32px;
  padding: 0 4px;
  border: 0;
  border-radius: 999px;
  appearance: textfield;
  background: transparent;
  color: var(--accent-strong);
  font: inherit;
  font-variant-numeric: tabular-nums;
  font-weight: 760;
  text-align: center;
  transition-property: background-color, box-shadow;
  transition-duration: 160ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.length-entry:hover,
.length-entry:focus {
  background: rgba(255, 255, 255, 0.5);
}

.length-entry::-webkit-inner-spin-button,
.length-entry::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

.options {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.options legend {
  margin-bottom: 4px;
}

.options label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 52px;
  gap: 16px;
  padding: 0 10px 0 14px;
  border-radius: var(--radius-inner);
  cursor: pointer;
  transition-property: background-color, color;
  transition-duration: 160ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.options label:hover {
  background: rgba(255, 255, 255, 0.42);
}

.options span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.options input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
}

.switch {
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: rgba(21, 21, 21, 0.13);
  box-shadow:
    inset 0 0 0 1px rgba(21, 21, 21, 0.09),
    0 1px 2px rgba(21, 21, 21, 0.08);
  transition-property: background-color, box-shadow, transform;
  transition-duration: 180ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow:
    0 1px 2px rgba(21, 21, 21, 0.12),
    0 3px 10px rgba(21, 21, 21, 0.18);
  transition-property: transform, box-shadow;
  transition-duration: 180ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.options input:checked + span + .switch {
  background: var(--accent);
  box-shadow:
    inset 0 0 0 1px rgba(14, 79, 73, 0.18),
    0 6px 18px rgba(23, 107, 99, 0.16);
}

.options input:checked + span + .switch::after {
  transform: translateX(18px);
}

.options label:hover .switch {
  box-shadow:
    inset 0 0 0 1px rgba(21, 21, 21, 0.14),
    0 3px 8px rgba(21, 21, 21, 0.12);
}

.options label:active .switch {
  transform: scale(0.96);
}

.actions {
  display: grid;
  gap: 10px;
  margin-top: 0;
}

.primary-button {
  grid-auto-flow: column;
  justify-content: center;
  width: 100%;
  min-height: 50px;
  gap: 10px;
  padding: 0 20px 0 22px;
  border-radius: var(--radius-inner);
  color: #ffffff;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent),
    var(--ink);
  font-weight: 760;
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(21, 21, 21, 0.2),
    0 12px 24px rgba(21, 21, 21, 0.16);
}

.primary-button:hover {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent),
    var(--accent-strong);
  box-shadow:
    0 0 0 1px rgba(14, 79, 73, 0.24),
    0 16px 32px rgba(14, 79, 73, 0.2);
}

.primary-button svg {
  transition-property: transform;
  transition-duration: 280ms;
  transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
}

.primary-button:hover svg {
  transform: rotate(28deg);
}

.status {
  min-height: 1.1rem;
  text-align: center;
  font-size: 0.8rem;
}

:focus-visible {
  outline: 0;
  box-shadow:
    0 0 0 3px var(--paper-strong),
    0 0 0 6px var(--focus);
}

.stagger-item {
  opacity: 0;
  filter: blur(4px);
  transform: translateY(12px);
  animation: enter 460ms cubic-bezier(0.2, 0, 0, 1) forwards;
}

.stagger-item:nth-child(1) {
  animation-delay: 0ms;
}

.stagger-item:nth-child(2) {
  animation-delay: 90ms;
}

.stagger-item:nth-child(3) {
  animation-delay: 180ms;
}

@keyframes enter {
  to {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0);
  }
}

@keyframes password-refresh {
  0% {
    opacity: 0.74;
    filter: blur(2px);
  }
  100% {
    opacity: 1;
    filter: blur(0);
  }
}

@keyframes password-character-enter {
  0% {
    opacity: 0;
    filter: blur(4px);
    transform: translateY(10px) rotateX(-35deg);
  }
  100% {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0) rotateX(0);
  }
}

@media (min-width: 760px) {
  .shell {
    align-items: stretch;
    padding: 0 44px;
  }

  .generator {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "header"
      "output"
      "controls";
    grid-template-rows: auto auto auto;
    align-content: start;
    row-gap: 0;
    width: min(100%, 1240px);
    height: 100svh;
  }

  .app-header {
    min-height: 132px;
    padding: 32px 0 10px;
  }

  h1 {
    font-size: 2.42rem;
  }

  .output-panel {
    grid-area: output;
    align-content: start;
    align-self: start;
    justify-self: center;
    width: min(100%, 720px);
    margin-top: clamp(34px, 10vh, 108px);
    padding: 0;
  }

  .output-panel .section-label {
    text-align: center;
  }

  .output-row {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    align-items: center;
    min-height: clamp(158px, 15vh, 188px);
  }

  .password {
    grid-column: 2;
    justify-content: center;
    padding: 14px 0 20px;
    font-size: clamp(1.52rem, 3vw, 2.12rem);
    text-align: center;
  }

  .output-row .icon-button {
    grid-column: 3;
    align-self: center;
  }

  .controls-panel {
    grid-area: controls;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 22px;
    justify-self: center;
    width: min(100%, 720px);
    margin: clamp(34px, 5vh, 58px) auto 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  .control {
    align-self: start;
    justify-self: stretch;
    gap: 12px;
    width: min(100%, 600px);
    margin: 0 auto;
  }

  .control-label {
    font-size: 0.9rem;
  }

  .strength-strip {
    min-height: 40px;
    padding: 0 16px;
    background: rgba(255, 255, 255, 0.38);
    font-size: 0.8rem;
  }

  .options {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    align-self: start;
    width: min(100%, 660px);
    margin: 4px auto 0;
  }

  .options legend {
    grid-column: 1 / -1;
    margin-bottom: 10px;
    text-align: center;
  }

  .options label {
    grid-template-columns: auto minmax(0, auto);
    justify-items: center;
    justify-content: center;
    align-items: center;
    min-height: 48px;
    gap: 8px;
    padding: 0 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.42);
    box-shadow: var(--shadow-control);
    text-align: center;
  }

  .options label:hover {
    background: rgba(255, 255, 255, 0.64);
  }

  .options label > span:first-of-type {
    font-size: 0.82rem;
    font-weight: 650;
    line-height: 1.15;
  }

  .switch {
    order: -1;
    width: 34px;
    height: 20px;
  }

  .switch::after {
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
  }

  .options input:checked + span + .switch::after {
    transform: translateX(14px);
  }

  .actions {
    align-self: start;
    justify-self: center;
    width: min(100%, 300px);
    gap: 8px;
    margin: 4px 0 0;
  }

  .primary-button {
    min-height: 48px;
  }
}

@media (min-width: 1080px) {
  .output-panel {
    width: min(100%, 760px);
  }

  .password {
    font-size: clamp(1.72rem, 2.5vw, 2.24rem);
  }
}

@media (min-width: 760px) and (max-width: 960px) {
  .shell {
    padding: 0 28px;
  }

  .output-panel,
  .controls-panel {
    width: min(100%, 720px);
  }

  .options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(100%, 460px);
  }
}

@media (max-height: 640px) {
  .shell {
    padding-top: 0;
    padding-bottom: 0;
  }

  .app-header {
    min-height: 66px;
    padding-bottom: 8px;
  }

  .brand {
    gap: 3px;
  }

  .output-panel {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .output-row {
    min-height: 0;
  }

  .password {
    padding-top: 8px;
    padding-bottom: 12px;
    font-size: 1rem;
    line-height: 1.25;
  }

  .controls-panel {
    gap: 10px;
    padding-top: 4px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 46%);
  }

  .control {
    gap: 6px;
  }

  input[type="range"] {
    height: 34px;
  }

  .strength-strip,
  .options label,
  .primary-button {
    min-height: 42px;
  }

  .status {
    min-height: 0.95rem;
    font-size: 0.78rem;
  }
}

@media (min-width: 760px) and (max-height: 640px) {
  .generator {
    row-gap: 0;
  }

  .app-header {
    min-height: 84px;
    padding-top: 16px;
  }

  .output-panel {
    margin-top: clamp(14px, 5vh, 34px);
    padding: 0;
  }

  .output-row {
    min-height: 126px;
  }

  .actions {
    margin-bottom: 0;
  }

  .controls-panel {
    gap: 10px;
    margin-top: 10px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  .options label {
    padding-top: 8px;
    padding-bottom: 8px;
  }
}

@media (max-width: 420px) {
  .shell {
    padding: 0;
  }

  .app-header {
    padding-left: 14px;
    padding-right: 14px;
  }

  .output-panel,
  .controls-panel {
    padding-left: 16px;
    padding-right: 16px;
  }

  .password {
    padding-left: 18px;
    padding-right: 14px;
  }
}

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

  #security-field {
    display: none;
  }
}
