:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #697386;
  --line: #dfe5ee;
  --brand: #3856d8;
  --brand-dark: #263fbb;
  --surface: rgba(255, 255, 255, 0.94);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 2%, rgba(128, 143, 255, 0.2), transparent 31rem),
    radial-gradient(circle at 94% 9%, rgba(55, 201, 174, 0.14), transparent 27rem),
    #f4f7fb;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; }
button, input { font: inherit; }
button, label[for="avatar-input"] { -webkit-tap-highlight-color: transparent; }

.settings-topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 68px;
  padding: 0.75rem max(1rem, calc((100vw - 1080px) / 2));
  color: #fff;
  background: rgba(22, 31, 51, 0.94);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(14px);
}

.settings-brand,
.settings-nav {
  display: flex;
  align-items: center;
}

.settings-brand {
  gap: 0.65rem;
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 60px;
  height: 34px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 7px;
  background: #000;
  box-shadow: 0 5px 14px rgba(0,0,0,.24);
}
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: cover; }

.settings-nav { gap: 1rem; }
.settings-nav a,
.text-button {
  color: #eef1ff;
  background: none;
  border: 0;
  padding: 0.35rem 0;
  text-decoration: none;
  cursor: pointer;
}
.settings-nav a:hover,
.text-button:hover { color: #aab8ff; }

.settings-shell {
  width: min(1080px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3rem 0 4rem;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.settings-shell.is-ready { opacity: 1; transform: none; }

.settings-intro {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  margin-bottom: 1.8rem;
}

.intro-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(56, 86, 216, 0.16);
  border-radius: 17px;
  background: linear-gradient(145deg, #fff, #edf0ff);
  box-shadow: 0 14px 35px rgba(58, 77, 137, 0.15);
}
.intro-icon svg { width: 28px; fill: var(--brand); }

.eyebrow,
.section-kicker {
  margin: 0 0 0.3rem;
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0.38rem; font-size: clamp(2rem, 5vw, 3.2rem); letter-spacing: -0.055em; }
h2 { margin-bottom: 0.35rem; font-size: 1.35rem; letter-spacing: -0.025em; }

.account-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  color: var(--muted);
}

.plan-badge,
.privacy-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
}
.plan-badge { padding: 0.35rem 0.68rem; color: #516076; background: #e7ecf4; }
.plan-badge.is-pro { color: #155d4b; background: #d9f7ed; }
.privacy-chip { padding: 0.3rem 0.58rem; color: #3c4fbe; background: #edf0ff; }

.page-message {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid #f0d49a;
  border-radius: 12px;
  color: #704d09;
  background: #fff7e5;
}

.settings-grid { display: grid; gap: 1rem; }

.settings-card {
  padding: clamp(1.2rem, 3.5vw, 1.8rem);
  border: 1px solid rgba(205, 214, 228, 0.92);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(51, 64, 97, 0.07);
}

.settings-card:focus-within { border-color: rgba(56, 86, 216, 0.42); }

.card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.card-heading p:not(.section-kicker) { margin-bottom: 0; color: var(--muted); line-height: 1.55; }

.avatar-editor { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.avatar-preview {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 84px;
  height: 84px;
  overflow: hidden;
  border: 3px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg, hsl(var(--avatar-hue, 232) 75% 60%), hsl(calc(var(--avatar-hue, 232) + 48) 72% 42%));
  box-shadow: 0 0 0 1px #d9e0eb, 0 12px 28px rgba(53, 70, 116, 0.18);
  font-size: 2rem;
  font-weight: 850;
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-copy strong { display: block; margin-bottom: 0.2rem; }
.avatar-copy p { margin-bottom: 0.75rem; color: var(--muted); font-size: 0.86rem; }

.button-row,
.input-action-row { display: flex; align-items: center; flex-wrap: wrap; gap: 0.65rem; }
.input-action-row input { flex: 1 1 260px; }

.settings-form { padding-top: 1rem; border-top: 1px solid var(--line); }
.settings-form label,
.danger-card > label { display: block; margin-bottom: 0.4rem; font-size: 0.9rem; font-weight: 750; }
.field-summary,
.field-help { color: var(--muted); font-size: 0.82rem; }
.field-summary { margin-bottom: 0.65rem; }
.field-help { margin: 0.55rem 0 0; }
.field-status { min-height: 1.2em; margin: 0.7rem 0 0; color: var(--muted); font-size: 0.84rem; }
.field-status.is-success { color: #157356; }
.field-status.is-error { color: #bc3147; }

input {
  min-height: 45px;
  padding: 0.7rem 0.82rem;
  border: 1px solid #cdd5e1;
  border-radius: 11px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(56, 86, 216, 0.13); }

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 43px;
  padding: 0.66rem 1rem;
  border-radius: 11px;
  font-weight: 780;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
}
.primary-button { border: 1px solid var(--brand); color: #fff; background: var(--brand); }
.primary-button:hover { background: var(--brand-dark); transform: translateY(-1px); }
.secondary-button { border: 1px solid #cbd4e3; color: #344057; background: #f8faff; }
.secondary-button:hover { background: #eef2f8; }
.ghost-button { border: 0; color: #657086; background: transparent; }
.ghost-button:hover { color: #b3273e; background: #fff0f2; }
.danger-button { border: 1px solid #c9374f; color: #fff; background: #c9374f; }
.danger-button:hover:not(:disabled) { background: #a7273c; transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: 0.5; }
.link-button { text-decoration: none; }

.stacked-form { display: grid; gap: 0.65rem; }
.stacked-form label:not(:first-child) { margin-top: 0.35rem; }
.stacked-form .field-status { margin-top: 0; }

.security-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #16745a;
  background: #dcf8ee;
  font-weight: 900;
}

.billing-card { background: linear-gradient(132deg, rgba(255,255,255,.96), rgba(239,242,255,.96)); }
.billing-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid rgba(56, 86, 216, 0.14);
  border-radius: 14px;
  background: rgba(255,255,255,.7);
}
.billing-summary p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.86rem; }

.danger-card { border-color: #f0c8ce; background: rgba(255, 250, 251, 0.95); }
.danger-card .section-kicker,
.danger-card h2 { color: #a9233b; }

.settings-footer {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1.5rem;
  color: #7a8495;
  font-size: 0.82rem;
}
.settings-footer a { text-decoration: none; }
.settings-footer a:hover { color: var(--brand); }

[hidden] { display: none !important; }

@media (min-width: 850px) {
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .profile-card,
  .danger-card { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  .settings-topbar { align-items: flex-start; }
  .settings-brand > span:last-child { display: none; }
  .settings-nav { gap: 0.7rem; font-size: 0.88rem; }
  .settings-shell { width: min(100% - 1rem, 1080px); padding-top: 2rem; }
  .settings-intro { align-items: flex-start; }
  .intro-icon { width: 48px; height: 48px; border-radius: 14px; }
  .intro-icon svg { width: 24px; }
  .avatar-editor { align-items: flex-start; }
  .avatar-preview { width: 70px; height: 70px; }
  .input-action-row { align-items: stretch; }
  .input-action-row input,
  .input-action-row button { width: 100%; }
}
