* { margin: 0; padding: 0; box-sizing: border-box; }
*:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
:root {
  --bg: #0c0c0f; --card: #16161a; --card-border: rgba(255,255,255,0.05);
  --text: #ececf1; --text-dim: #a1a1aa; --text-muted: #71717a;
  --blue: #6366f1; --blue-light: #818cf8; --green: #34d399;
  --orange: #fb923c; --red: #f87171; --purple: #a78bfa;
  --cyan: #22d3ee; --pink: #f472b6; --card-hover: #1c1c22;
  --surface-2: #1c1c22; --border-hover: rgba(255,255,255,0.1);
  --noise-opacity: 0.03;
}
[data-theme="light"] {
  --bg: #f3f4f8; --card: #ffffff; --card-border: rgba(0,0,0,0.06);
  --text: #1a1c2b; --text-dim: #6b6f85; --text-muted: #9b9fb3;
  --blue: #6366f1; --blue-light: #818cf8; --green: #16a34a;
  --orange: #d97706; --red: #dc2626; --purple: #7c3aed;
  --cyan: #0891b2; --pink: #db2777; --card-hover: #f8f8fb;
  --surface-2: #eaebf0; --border-hover: rgba(0,0,0,0.12);
  --noise-opacity: 0.015;
}

html, body { overflow-x: hidden; }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(128,128,128,0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(128,128,128,0.5); }

body {
  font-family: 'DM Sans', -apple-system, sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.settings-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--card-border);
  background: var(--card);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.logo { display: flex; align-items: center; }
.header-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.back-link {
  font-size: 0.8rem; color: var(--text-dim); text-decoration: none;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--card-border);
  transition: all 0.2s;
}
.back-link:hover { border-color: var(--border-hover); color: var(--text); }

/* Theme toggle */
.theme-toggle {
  background: var(--card); border: 1px solid var(--card-border); border-radius: 10px;
  padding: 6px 10px; cursor: pointer; font-size: 1rem; line-height: 1;
  color: var(--text); transition: all 0.2s;
  min-width: 44px; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
}
.theme-toggle:hover { border-color: var(--blue); }

/* Main */
.settings-main {
  max-width: 600px; margin: 32px auto; padding: 0 20px;
}

/* Card */
.settings-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 16px; padding: 32px;
}
.section-title {
  font-size: 1.1rem; font-weight: 700; margin-bottom: 24px;
}

/* Fieldset reset */
fieldset { border: none; padding: 0; margin: 0; }
fieldset:disabled { opacity: 0.5; }

/* Form groups */
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block; font-size: 0.85rem; font-weight: 600;
  margin-bottom: 6px; color: var(--text-dim);
}
.form-input {
  width: 100%; padding: 12px 16px; border-radius: 10px;
  border: 1px solid var(--card-border); background: var(--bg);
  color: var(--text); font-size: 0.9rem; font-family: inherit;
  transition: border-color 0.2s; min-height: 44px;
}
.form-input:focus { border-color: var(--blue); outline: none; }
.form-input:focus:not(:focus-visible) { outline: none; }
.form-input::placeholder { color: var(--text-muted); }

/* Toggle row */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
}
.toggle-label { font-size: 0.95rem; font-weight: 600; color: var(--text); }

/* Toggle switch */
.toggle-switch {
  position: relative; display: inline-block; width: 48px; height: 26px; cursor: pointer;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: var(--card-border);
  border-radius: 26px; transition: all 0.3s;
}
.toggle-slider::before {
  content: ''; position: absolute; left: 3px; top: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--text-muted); transition: all 0.3s;
}
.toggle-switch input:checked + .toggle-slider { background: rgba(99,102,241,0.3); }
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px); background: var(--blue);
}

/* Checkbox row */
.checkbox-row {
  display: flex; flex-wrap: wrap; gap: 16px;
}
.checkbox-row label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.85rem; color: var(--text-dim); cursor: pointer;
}
.checkbox-row input[type="checkbox"] { min-width: 18px; min-height: 18px; accent-color: var(--blue); }

/* Buttons */
.btn-row {
  display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 28px; border-radius: 12px; font-size: 0.9rem; font-weight: 600;
  border: none; cursor: pointer; transition: all 0.2s; font-family: inherit;
  min-height: 44px;
}
.btn-primary {
  background: linear-gradient(135deg, #4f46e5, var(--blue)); color: #fff;
  box-shadow: 0 4px 14px rgba(99,102,241,0.3);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(99,102,241,0.4); filter: brightness(1.1); }
.btn-secondary {
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--card-border);
}
.btn-secondary:hover { border-color: var(--text-dim); color: var(--text); }

/* Status message */
.status-msg {
  padding: 12px; border-radius: 10px; font-size: 0.85rem;
  margin-top: 16px; border: 1px solid transparent;
}
.status-msg.success {
  background: rgba(34,197,94,0.06); border-color: rgba(34,197,94,0.15); color: var(--green);
}
.status-msg.error {
  background: rgba(239,68,68,0.06); border-color: rgba(239,68,68,0.15); color: var(--red);
}

/* Support card */
.support-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 16px; padding: 24px; margin-top: 24px; text-align: center;
}
.support-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; }
.support-text { font-size: 0.85rem; color: var(--text-dim); line-height: 1.5; }
.support-links {
  display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 16px;
}
.support-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border: 1px solid var(--card-border); border-radius: 10px;
  color: var(--text-dim); text-decoration: none; font-size: 0.85rem;
  transition: all 0.2s;
}
.support-link:hover { border-color: var(--border-hover); color: var(--text); }

/* Responsive */
@media (max-width: 640px) {
  .settings-header { padding: 12px 16px; }
  .settings-main { padding: 0 12px; margin-top: 20px; }
  .settings-card { padding: 24px 20px; }
  .btn-row { flex-direction: column; }
  .btn-row .btn { width: 100%; }
  .support-links { flex-direction: column; align-items: center; }
}
