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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-y: scroll;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
    sans-serif;
  background-color: #020617;
  background-image: radial-gradient(circle at top, #1f2937, #020617 60%);
  background-repeat: no-repeat;
  background-position: top center;
  background-attachment: fixed;
  color: #e5e7eb;
}

body {
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.app {
  width: 100%;
  max-width: 960px;
  padding: 2rem 1.25rem 3rem;
  position: relative;
  z-index: 1;
}

.app__header {
  text-align: center;
  margin-bottom: 2rem;
}

.app__header h1 {
  margin: 0;
  font-size: 2.1rem;
  letter-spacing: 0.04em;
}

.app__subtitle {
  margin-top: 0.5rem;
  color: #9ca3af;
  font-size: 0.95rem;
}

.app__keys-row {
  display: block;
}

.card {
  background: rgba(17, 24, 39, 0.96);
  border-radius: 0.9rem;
  padding: 1.5rem 1.25rem 1.4rem;
  margin-bottom: 1.25rem;
  border: 1px solid rgba(55, 65, 81, 0.9);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.48);
}

.card--tight-footer {
  padding-bottom: 0.75rem;
}

.card--tight-top {
  padding-top: 0.9rem;
}

.card--tight-top .field-group:first-of-type {
  margin-top: 0.6rem;
}

#keyGenStatus {
  margin-bottom: 0;
}

.card__title {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.field-group {
  margin-bottom: 1rem;
}

.field-group--compact-bottom {
  margin-bottom: 0;
}

.field-group--actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.field-label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

.field-label--inline {
  display: flex;
  align-items: center;
}

.field-input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: 0.55rem;
  border: 1px solid rgba(55, 65, 81, 0.9);
  background: rgba(15, 23, 42, 0.95);
  color: #e5e7eb;
  font: inherit;
}

input[type='file'].field-input {
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: transparent;
  border-color: rgba(148, 163, 184, 0.9);
  cursor: pointer;
}

input[type='file'].field-input::file-selector-button {
  margin-right: 0.5rem;
  padding: 0.35rem 0.9rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #38bdf8, #4ade80);
  color: #020617;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

input[type='file'].field-input:hover::file-selector-button {
  filter: brightness(1.05);
}

.field-input:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.9);
}

.field-input--textarea {
  min-height: 260px;
  resize: vertical;
}

.field-help {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: #9ca3af;
}

#rememberPassphraseCheckbox {
  appearance: none;
  -webkit-appearance: none;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 0.3rem;
  border: 1px solid rgba(148, 163, 184, 0.9);
  background: transparent;
  display: inline-block;
  vertical-align: middle;
  margin-right: 0.4rem;
  cursor: pointer;
  position: relative;
}

#rememberPassphraseCheckbox:checked {
  background: linear-gradient(135deg, #38bdf8, #4ade80);
  border-color: transparent;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.9) inset;
}

#rememberPassphraseCheckbox::after {
  content: '';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: #020617;
}

#rememberPassphraseCheckbox:checked::after {
  content: '✓';
}

#rememberPassphraseCheckbox:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease,
    transform 0.08s ease;
}

.button:active {
  transform: translateY(1px) scale(0.99);
}

.button--primary {
  background: linear-gradient(135deg, #38bdf8, #4ade80);
  color: #020617;
  font-weight: 600;
  margin-top: 0.3rem;
}

#actionButton {
  min-width: 7.5rem;
}

.button--primary:hover {
  filter: brightness(1.05);
}

.button--ghost {
  background: transparent;
  border-color: rgba(148, 163, 184, 0.9);
  color: #e5e7eb;
}

.button--ghost:hover {
  border-color: #38bdf8;
}

.status {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: #9ca3af;
}

.status:empty {
  margin-top: 0;
  display: none;
}

.status--ok {
  color: #4ade80;
}

.status--error {
  color: #f97373;
}

.details {
  margin-top: 0.5rem;
}

.details summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: #9ca3af;
}

.key-preview {
  margin-top: 0.45rem;
  max-height: 180px;
  overflow: auto;
  padding: 0.6rem 0.75rem;
  border-radius: 0.55rem;
  background: rgba(15, 23, 42, 0.9);
  border: 1px dashed rgba(55, 65, 81, 0.9);
  font-size: 0.78rem;
  line-height: 1.3;
  white-space: pre-wrap;
  word-break: break-word;
}

.app__footer {
  margin-top: 1.4rem;
  text-align: center;
  font-size: 0.8rem;
  color: #6b7280;
  padding-bottom: 1.5rem;
  position: relative;
  background-color: #020617;
}

.app__footer-inner {
  position: relative;
  z-index: 1;
}

.app__footer-link {
  display: inline-block;
  margin-top: 0.35rem;
  color: inherit;
  text-decoration: underline;
}

.app__footer::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 5rem;
  pointer-events: none;
  z-index: 0;
  background: linear-gradient(to top, #020617 0%, rgba(2, 6, 23, 0) 100%);
}

@media (min-width: 768px) {
  .app {
    padding: 2.5rem 0 3.25rem;
  }

  .app__keys-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.25rem;
  }

  .app__keys-row .card {
    margin-bottom: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  .card {
    padding: 1.6rem 1.6rem 1.5rem;
  }

  .card--tight-footer {
    padding-bottom: 0.9rem;
  }

  .card--tight-top {
    padding-top: 1rem;
    padding-bottom: 1.5rem;
    margin-bottom: 1.25rem;
  }

  .app__header h1 {
    font-size: 2.3rem;
  }

  .name-label {
    margin-top: 1rem;
  }
}
