/* ── Settings Page ─────────────────────────────────── */

/* Page layout */
.st-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: calc(100vh - 6rem);
  padding: 2.5rem 1rem 4rem;
}

/* Loading state */
.st-loading {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink-faint);
  padding-top: 6rem;
}

/* ── Card ──────────────────────────────────────────── */
.st-card {
  max-width: 680px;
  width: 100%;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 2.5rem;
  position: relative;
}

/* Teal accent line at top */
.st-card::before {
  content: "";
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  height: 3px;
  background: var(--teal);
  border-radius: 16px 16px 0 0;
  z-index: 1;
}

/* ── Section Label ─────────────────────────────────── */
.st-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--ink-faint);
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  margin-top: 0.25rem;
}

/* ── Heading ───────────────────────────────────────── */
.st-heading {
  font-family: "Darker Grotesque", sans-serif;
  font-weight: 800;
  font-size: 1.75rem;
  color: var(--ink);
  margin-bottom: 2rem;
  line-height: 1.2;
}

/* ── Sections ──────────────────────────────────────── */
.st-section {
  border: none;
  padding: 0;
  margin: 0 0 2rem;
}

.st-section__title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

/* ── Avatar ────────────────────────────────────────── */
.st-avatar-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.st-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.st-avatar:hover,
.st-avatar:focus-visible {
  border-color: var(--teal);
}

.st-avatar__placeholder {
  width: 36px;
  height: 36px;
  color: var(--ink-faint);
  transition: opacity 0.2s ease;
}

.st-avatar__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.st-avatar:hover .st-avatar__overlay,
.st-avatar:focus-visible .st-avatar__overlay {
  opacity: 1;
}

.st-avatar:hover .st-avatar__placeholder,
.st-avatar:focus-visible .st-avatar__placeholder {
  opacity: 0.3;
}

/* ── Form Fields ───────────────────────────────────── */
.st-field {
  margin-bottom: 1rem;
}

.st-field--other {
  margin-top: -0.5rem;
}

.st-field__label {
  display: block;
  font-family: "Darker Grotesque", sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink-dim);
  margin-bottom: 0.4rem;
}

.st-field__hint {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--ink-faint);
  margin-bottom: 0.75rem;
  margin-top: -0.25rem;
}

.st-field__input {
  width: 100%;
  font-family: "Darker Grotesque", sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  caret-color: var(--teal);
}

.st-field__input::placeholder {
  color: var(--ink-faint);
  font-weight: 500;
}

.st-field__input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(69, 216, 197, 0.08);
}

.st-field__input--disabled {
  color: var(--ink-faint);
  background: var(--bg-1);
  border-color: var(--line);
  cursor: not-allowed;
  opacity: 0.6;
}

.st-field__input.has-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 90, 90, 0.06);
}

.st-field__error {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--danger);
  min-height: 1rem;
  margin-top: 0.25rem;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.st-field__error.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Select ────────────────────────────────────────── */
.st-field__select {
  width: 100%;
  font-family: "Darker Grotesque", sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23818987' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-right: 2.5rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.st-field__select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(69, 216, 197, 0.08);
}

/* Style the select options for dark theme */
.st-field__select option {
  background: var(--bg-2);
  color: var(--ink);
}

/* ── Proficiency Cards ─────────────────────────────── */
.st-prof-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.st-prof-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.st-prof-card:hover {
  border-color: var(--line-hover);
}

.st-prof-card--selected {
  border-color: var(--teal);
  background: var(--teal-dim);
}

.st-prof-card__title {
  font-family: "Darker Grotesque", sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
}

.st-prof-card__sub {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--ink-faint);
  line-height: 1.4;
}

.st-prof-card--selected .st-prof-card__title {
  color: var(--teal);
}

/* ── AI Tool Pills ─────────────────────────────────── */
.st-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
}

.st-tool-pill {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--ink-dim);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.st-tool-pill:hover {
  border-color: var(--line-hover);
}

.st-tool-pill--selected {
  border-color: var(--teal);
  background: var(--teal-dim);
  color: var(--teal);
}

/* ── Toggle Switch ─────────────────────────────────── */
.st-toggle-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
}

.st-toggle-row__text {
  flex: 1;
}

.st-toggle-row__label {
  display: block;
  font-family: "Darker Grotesque", sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
  margin-bottom: 0.25rem;
}

.st-toggle-row__desc {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--ink-faint);
  line-height: 1.5;
}

.st-switch {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  cursor: pointer;
  margin-top: 0.15rem;
}

.st-switch__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.st-switch__track {
  width: 44px;
  height: 24px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  position: relative;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.st-switch__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--ink-faint);
  border-radius: 50%;
  transition: transform 0.2s ease, background 0.2s ease;
}

.st-switch__input:checked + .st-switch__track {
  background: var(--teal-dim);
  border-color: var(--teal);
}

.st-switch__input:checked + .st-switch__track .st-switch__thumb {
  transform: translateX(20px);
  background: var(--teal);
}

.st-switch__input:focus-visible + .st-switch__track {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 999px;
}

/* ── Account Section ───────────────────────────────── */
.st-divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 1rem 0;
}

.st-link-btn {
  display: inline-block;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--ink-dim);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem 0;
  transition: color 0.15s ease;
  text-align: left;
}

.st-link-btn:hover {
  color: var(--ink);
}

.st-link-btn--danger {
  color: var(--danger);
}

.st-link-btn--danger:hover {
  color: #FFB8B8;
}

/* ── Password change form ──────────────────────────── */
.st-pw-form {
  margin-top: 0.75rem;
  padding: 1rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.st-pw-form .st-field {
  margin-bottom: 0.75rem;
}

.st-pw-input-wrap {
  position: relative;
}

.st-pw-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

/* ── Buttons ───────────────────────────────────────── */
.st-btn {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.8rem;
  border-radius: 6px;
  border: none;
  padding: 0.55rem 1.25rem;
  cursor: pointer;
  transition: filter 0.15s ease, opacity 0.2s ease, transform 0.1s ease;
  white-space: nowrap;
}

.st-btn--sm {
  background: var(--teal);
  color: var(--bg-0);
}

.st-btn--sm:hover {
  filter: brightness(0.9);
}

.st-btn--sm:active {
  transform: scale(0.97);
}

.st-btn--ghost {
  background: transparent;
  color: var(--ink-faint);
  border: 1px solid var(--line);
}

.st-btn--ghost:hover {
  color: var(--ink);
  border-color: var(--line-hover);
}

.st-btn--danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(255, 120, 120, 0.25);
}

.st-btn--danger:hover {
  background: rgba(255, 90, 90, 0.12);
}

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

/* ── Form Message ──────────────────────────────────── */
.st-form-msg {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.55;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-top: 1rem;
  display: none;
}

.st-form-msg--success {
  display: block;
  color: var(--teal);
  background: var(--teal-dim);
  border: 1px solid var(--teal-line);
}

.st-form-msg--error {
  display: block;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
}

/* ── Footer / Save Button ──────────────────────────── */
.st-footer {
  display: flex;
  align-items: center;
  margin-top: 1.5rem;
}

.st-submit {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  color: var(--bg-0);
  background: var(--teal);
  border: none;
  border-radius: 6px;
  padding: 0.7rem 1.75rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: filter 0.15s ease, opacity 0.25s ease, transform 0.1s ease;
  white-space: nowrap;
}

.st-submit:hover:not(:disabled) {
  filter: brightness(0.9);
}

.st-submit:active:not(:disabled) {
  transform: scale(0.97);
}

.st-submit:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.st-chevron-icon {
  display: flex;
  align-items: center;
}

/* ── Delete Confirmation Modal ─────────────────────── */
.st-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.st-modal {
  max-width: 420px;
  width: 100%;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 2rem;
  animation: st-modal-enter 0.2s ease;
}

@keyframes st-modal-enter {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.st-modal__title {
  font-family: "Darker Grotesque", sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--ink);
  margin-bottom: 0.75rem;
}

.st-modal__desc {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--ink-faint);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.st-modal__actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ── Reduced Motion ────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .st-modal { animation: none; }
  .st-field__input,
  .st-field__select,
  .st-switch__track,
  .st-switch__thumb,
  .st-avatar,
  .st-avatar__overlay,
  .st-avatar__placeholder,
  .st-prof-card,
  .st-tool-pill {
    transition: none;
  }
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 600px) {
  .st-page {
    padding: 1rem;
    padding-top: 1.5rem;
  }

  .st-card {
    padding: 1.5rem;
    border-radius: 12px;
  }

  .st-heading {
    font-size: 1.4rem;
  }

  .st-prof-cards {
    grid-template-columns: 1fr;
  }

  .st-submit {
    width: 100%;
    justify-content: center;
  }

  .st-toggle-row {
    gap: 1rem;
  }

  .st-modal {
    padding: 1.5rem;
  }

  .st-modal__actions {
    flex-direction: column;
  }

  .st-modal__actions .st-btn {
    width: 100%;
    text-align: center;
  }

  .st-pw-actions {
    flex-direction: column;
  }

  .st-pw-actions .st-btn {
    width: 100%;
    text-align: center;
  }
}

/* ── Avatar Editor ─────────────────────────── */
.st-avatar-editor {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.st-avatar-preview {
  width: 120px;
  height: 120px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--bg-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.st-avatar-preview svg {
  width: 100%;
  height: 100%;
}

.st-avatar-options {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.st-avatar-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.st-avatar-row__label {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.st-avatar-row__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.st-avatar-pill {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-dim);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.st-avatar-pill:hover {
  border-color: var(--ink-faint);
}

.st-avatar-pill.active {
  border-color: var(--teal);
  background: var(--teal-dim);
  color: var(--teal);
}

.st-avatar-row__colors {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.st-avatar-color {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.st-avatar-color:hover {
  transform: scale(1.15);
}

.st-avatar-color.active {
  border-color: var(--ink);
  transform: scale(1.15);
}

.st-avatar-randomise {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--ink-faint);
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  align-self: flex-start;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.st-avatar-randomise:hover {
  border-color: var(--teal);
  color: var(--teal);
}

@media (max-width: 600px) {
  .st-avatar-editor {
    flex-direction: column;
    align-items: center;
  }

  .st-avatar-preview {
    width: 96px;
    height: 96px;
  }
}

@media (max-width: 380px) {
  .st-card {
    padding: 1.25rem;
  }

  .st-heading {
    font-size: 1.25rem;
  }

  .st-modal {
    padding: 1.25rem;
  }
}
