:root {
  --bg: #131416;
  --surface: #0e1a1d;
  --surface-elevated: #1e282a;
  --border: #253335;
  --border-medium: #415151;
  --text: #f3f3f3;
  --text-muted: #a4a8aa;
  --text-inactive: #8d8c8c;
  --primary: #91e6cb;
  --primary-hover: #59e0b5;
  --danger: #ff826b;
  --danger-strong: #e22905;
  --success: #6ad86a;
  --link: #6faeff;
  --focus-ring: rgba(145, 230, 203, 0.4);
  --radius: 8px;
  --btn-radius: 32px;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px;
}

.container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  margin-top: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.logo {
  text-align: center;
  margin-bottom: 8px;
}

.logo img {
  height: 28px;
  width: auto;
}

h1 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.subtitle {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 24px;
}

.warning-text {
  color: var(--danger);
}

/* Form styles */
.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

label .optional {
  color: var(--text-inactive);
  font-weight: 400;
}

.form-input,
select,
textarea {
  display: block;
  width: 100% !important;
  padding: 12px 14px !important;
  font-size: 16px !important;
  line-height: 1.5;
  color: var(--text) !important;
  background-color: var(--surface-elevated) !important;
  border: 1px solid var(--border-medium) !important;
  border-radius: var(--radius) !important;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
  -webkit-appearance: none !important;
  appearance: none !important;
  box-sizing: border-box !important;
}

/* Override browser autofill and credential manager styles */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--surface-elevated) inset;
  border: 1px solid var(--border-medium);
  font-size: 16px;
}

input::-webkit-credentials-auto-fill-button {
  visibility: hidden;
  position: absolute;
  right: 0;
}

input[type='password']::-ms-reveal,
input[type='password']::-ms-clear {
  display: none;
}

input[type='password']::-webkit-textfield-decoration-container {
  pointer-events: none;
}

input[type='password']::-webkit-password-toggle-button {
  display: none;
}

.form-input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.form-input.error,
select.error {
  border-color: var(--danger);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23A4A8AA' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.error-message {
  display: none;
  font-size: 13px;
  color: var(--danger);
  margin-top: 4px;
  align-items: center;
  gap: 4px;
}

.error-message.visible {
  display: flex;
}

.error-icon {
  flex-shrink: 0;
}

/* Error banner */
.error-banner {
  display: none;
  background-color: rgba(255, 130, 107, 0.1);
  border: 1px solid rgba(255, 130, 107, 0.3);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--danger);
  line-height: 1.5;
}

.error-banner.visible {
  display: block;
}

.success-banner {
  display: none;
  background-color: rgba(106, 216, 106, 0.1);
  border: 1px solid rgba(106, 216, 106, 0.3);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--success);
  line-height: 1.5;
}

.success-banner.visible {
  display: block;
}

/* Password toggle */
.password-wrapper {
  position: relative;
}

.password-wrapper .form-input {
  padding-right: 44px !important;
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.password-toggle:hover {
  color: var(--text);
}

.password-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.delete-warning {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.5;
}

.signed-in-text {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.5;
}

.signed-in-text strong {
  color: var(--text);
  word-break: break-all;
}

/* Hidden state */
.hidden {
  display: none;
}

/* Button centering */
.btn-center {
  display: flex;
  justify-content: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 500;
  border: none;
  border-radius: var(--btn-radius);
  cursor: pointer;
  transition:
    background-color 0.15s,
    opacity 0.15s;
  min-height: 48px;
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-card {
  background-color: var(--text);
  color: var(--bg);
  font-weight: 600;
  width: auto;
  min-width: 250px;
  padding: 14px 40px;
}

.btn-card:hover:not(:disabled) {
  background-color: #dddfe4;
}

.btn-danger {
  background-color: var(--danger-strong);
  color: #f3f3f3;
  width: auto;
  padding: 14px 40px;
}

.btn-danger:hover:not(:disabled) {
  background-color: #c42204;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Info panels */
.info-panel {
  background-color: rgba(145, 230, 203, 0.06);
  border: 1px solid rgba(145, 230, 203, 0.15);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 24px;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

.warning-panel {
  background-color: rgba(255, 130, 107, 0.08);
  border: 1px solid rgba(255, 130, 107, 0.2);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 24px;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

.warning-panel strong {
  color: var(--danger);
}

/* Status pages */
.status-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.status-heading {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 12px;
}

.status-text {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 20px;
  line-height: 1.6;
}

.link {
  color: var(--link);
  text-decoration: none;
}

.link:hover {
  text-decoration: underline;
}

.link:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Anchor-as-button reset */
a.btn {
  text-decoration: none;
}

/* Forgot password */
.forgot-password {
  text-align: right;
  margin-top: -12px;
  margin-bottom: 16px;
  font-size: 13px;
}

.forgot-password button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.form-instruction {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 20px;
}

.form-footer {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
}

.form-footer button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
}

.field-hint {
  font-size: 12px;
  color: var(--text-inactive);
  margin-top: 6px;
}

/* Footer */
.footer {
  margin-top: 32px;
  text-align: center;
  font-size: 13px;
  color: var(--text-inactive);
}

.footer a {
  color: var(--text-inactive);
  text-decoration: underline;
}

/* Accessibility: aria-live region */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Initially hidden elements (avoids inline style="display: none") */
.initially-hidden {
  display: none;
}

/* Responsive */
@media (max-width: 480px) {
  body {
    padding: 16px 12px;
  }

  .card {
    padding: 24px 16px;
  }

  h1 {
    font-size: 22px;
  }
}
