/* ── Reset ─────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
html { background: var(--bg-0); overflow-x: hidden; }
body {
  background: var(--bg-0);
  color: var(--text-1);
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
  line-height: 1.5;
  opacity: 0;
}
body.is-ready { opacity: 1; transition: opacity 180ms ease-out; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; letter-spacing: inherit; }
input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
img, svg { display: block; max-width: 100%; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 999px; border: 2px solid var(--bg-0); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ── Page layout ─────────────────────────────────────────────────── */

.id-page {
  min-height: calc(100vh - 48px);
}
.id-page-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 32px;
}
.id-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 48px;
  align-items: start;
}
.id-left-nav {
  position: sticky;
  top: 48px;
}
.id-main { padding-top: 48px; }

/* Desktop: nav flotante arriba, bloque de edición centrado en página */
@media (min-width: 1101px) {
  .id-layout { display: block; }
  .id-left-nav {
    position: fixed;
    top: 96px;
    left: calc((100vw - 1100px) / 2);
    width: 200px;
  }
}
.id-left-nav__title {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin-bottom: 24px;
}
.id-left-nav__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.id-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  color: var(--text-3);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast);
  width: 100%;
  border: none;
  background: none;
  font-family: inherit;
  letter-spacing: inherit;
  text-align: left;
}
.id-nav-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.65;
}
.id-nav-item:hover { color: var(--text-1); background: var(--bg-hover); }
.id-nav-item:hover svg { opacity: 1; }
.id-nav-item.is-active { color: var(--text-1); font-weight: 600; }
.id-nav-item.is-active svg { opacity: 1; }
.id-nav-badge {
  margin-left: auto;
  background: var(--danger, #c0392b);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
.id-main { min-width: 0; }

/* ── Page content ────────────────────────────────────────────────── */

.id-content {
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding-bottom: 80px;
}

.id-section {
  margin-bottom: 52px;
  scroll-margin-top: 72px;
}

.id-section__head {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.id-section__title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -0.01em;
  margin-bottom: 3px;
}
.id-section__sub {
  font-size: 12.5px;
  color: var(--text-3);
}

/* ── Cards ───────────────────────────────────────────────────────── */

.id-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.id-card + .id-card { margin-top: 10px; }
.id-card__inner { padding: 20px 22px; }

/* ── Forms ───────────────────────────────────────────────────────── */

.form-row { margin-bottom: 16px; }
.form-row:last-child { margin-bottom: 0; }

.form-label {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-3);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input, .t-input {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg-0);
  border: 1px solid var(--border-mid);
  border-radius: var(--r-md);
  color: var(--text-1);
  font-size: 13.5px;
  transition: border-color 0.12s;
  outline: none;
}
.form-input:focus, .t-input:focus { border-color: var(--accent); }
.form-input:disabled, .t-input:disabled { opacity: 0.45; cursor: not-allowed; }
.form-input.is-error, .t-input.is-error { border-color: var(--accent); }

.form-hint { font-size: 11.5px; color: var(--text-4); margin-top: 4px; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .form-grid-2 { grid-template-columns: 1fr; } }

.form-group { margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }

.t-error-msg {
  font-size: 12px;
  color: var(--accent-text);
  margin-top: 5px;
  display: none;
}
.t-input-wrap.is-error .t-error-msg { display: block; }

/* Avatar row */
.avatar-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.avatar-preview {
  width: 60px; height: 60px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-3);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-2);
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ── Buttons ─────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border-mid);
  background: var(--bg-2);
  color: var(--text-1);
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
  text-decoration: none;
  line-height: 1.4;
  font-family: inherit;
  letter-spacing: inherit;
}
.btn:hover { background: var(--bg-3); border-color: var(--border-strong); }
.btn-primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: transparent; }
.btn-danger { background: oklch(0.40 0.14 25); border-color: transparent; color: #fff; }
.btn-danger:hover { background: oklch(0.46 0.14 25); }
.btn-ghost { background: none; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-2); border-color: var(--border); color: var(--text-1); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ── Alerts ──────────────────────────────────────────────────────── */

.alert {
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.alert-success { background: oklch(0.72 0.16 155 / 0.10); color: var(--green); border: 1px solid oklch(0.72 0.16 155 / 0.2); }
.alert-error   { background: var(--accent-soft); color: var(--accent-text); border: 1px solid var(--accent-border); }

/* ── Integration rows (Discord etc.) ────────────────────────────── */

.integration-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
}
.integration-row + .integration-row {
  border-top: 1px solid var(--border);
}
.integration-icon {
  width: 38px; height: 38px;
  border-radius: var(--r-lg);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ── Toggle switch ───────────────────────────────────────────────── */
.id-toggle { position: relative; display: inline-flex; flex-shrink: 0; cursor: pointer; }
.id-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.id-toggle__track {
  width: 42px; height: 24px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background .18s, border-color .18s;
  position: relative;
}
.id-toggle__track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text-3);
  transition: transform .18s, background .18s;
}
.id-toggle input:checked + .id-toggle__track { background: oklch(0.50 0.18 145); border-color: transparent; }
.id-toggle input:checked + .id-toggle__track::after { transform: translateX(18px); background: #fff; }

/* ── Apps grid ───────────────────────────────────────────────────── */

.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.app-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color var(--t-fast), background var(--t-fast);
  text-decoration: none;
  color: inherit;
}
.app-card--active:hover { border-color: var(--border-mid); background: var(--bg-2); }
.app-card--locked { opacity: 0.5; }
.app-card__icon {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  background: var(--bg-2);
  display: grid; place-items: center;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-2);
  overflow: hidden;
}
.app-card__icon img { width: 100%; height: 100%; object-fit: contain; }
.app-card__name { font-size: 13px; font-weight: 600; color: var(--text-1); }
.app-card__desc { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.badge-active {
  display: inline-block;
  font-size: 10.5px; padding: 1px 7px;
  background: oklch(0.72 0.16 155 / 0.10); color: var(--green);
  border: 1px solid oklch(0.72 0.16 155 / 0.2);
  border-radius: 999px; margin-top: 4px;
}
.badge-locked {
  display: inline-block;
  font-size: 10.5px; padding: 1px 7px;
  background: var(--bg-3); color: var(--text-4);
  border-radius: 999px; margin-top: 4px;
}

/* ── Friends tabs ────────────────────────────────────────────────── */

.friend-tab { position: relative; }
.friend-tab.is-active { background: var(--bg-3); color: var(--text-1); }
.friend-tab-badge { display:inline-flex;align-items:center;justify-content:center;min-width:18px;height:18px;padding:0 5px;border-radius:999px;background:var(--bg-3);color:var(--text-3);font-size:10.5px;font-weight:700;margin-left:5px;vertical-align:middle; }
.friend-tab-badge--red { background: var(--danger, #c0392b); color: #fff; }
.btn-link { background:none;border:none;color:var(--accent,#7c3aed);cursor:pointer;font-size:inherit;padding:0;text-decoration:underline; }

/* ── Text swap animation ─────────────────────────────────────────── */
:root {
  --text-swap-dur: 150ms;
  --text-swap-translate-y: 4px;
  --text-swap-blur: 2px;
  --text-swap-ease: ease-in-out;
}
.t-text-swap {
  display: inline-block;
  transform: translateY(0);
  filter: blur(0);
  opacity: 1;
  transition:
    transform var(--text-swap-dur) var(--text-swap-ease),
    filter    var(--text-swap-dur) var(--text-swap-ease),
    opacity   var(--text-swap-dur) var(--text-swap-ease);
  will-change: transform, filter, opacity;
}
.t-text-swap.is-exit {
  transform: translateY(calc(var(--text-swap-translate-y) * -1));
  filter: blur(var(--text-swap-blur));
  opacity: 0;
}
.t-text-swap.is-enter-start {
  transform: translateY(var(--text-swap-translate-y));
  filter: blur(var(--text-swap-blur));
  opacity: 0;
  transition: none;
}

/* ── Preferences rows ───────────────────────────────────────────── */

.pref-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
}
.pref-row + .pref-row {
  border-top: 1px solid var(--border);
}
.pref-row__icon {
  width: 32px; height: 32px;
  border-radius: var(--r-md, 8px);
  background: var(--bg-3);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
  flex-shrink: 0;
}
.pref-row__body { flex: 1; min-width: 0; }
.pref-row__label { font-size: 13.5px; font-weight: 600; color: var(--text-1); }
.pref-row__desc  { font-size: 12px; color: var(--text-3); margin-top: 2px; line-height: 1.45; }
.pref-row__action { flex-shrink: 0; }

/* ── Login page ──────────────────────────────────────────────────── */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 780px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  display: flex;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,.35);
}
.login-card-brand {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card-logo { width: 36px; height: 36px; object-fit: contain; }
.login-card-name { font-size: 15px; font-weight: 700; color: var(--text-1); margin-top: 4px; }
.login-card-sub  { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.login-card-form {
  flex: 1;
  padding: 40px 36px;
}
.login-title { font-size: 20px; font-weight: 700; color: var(--text-1); margin-bottom: 4px; letter-spacing: -0.01em; }
.login-sub   { font-size: 13px; color: var(--text-3); margin-bottom: 28px; }
.login-submit { width: 100%; margin-top: 6px; padding: 8px 16px; font-size: 13.5px; }

@media (max-width: 640px) {
  .login-shell { padding: 16px; }
  .login-card {
    flex-direction: column;
    max-width: 440px;
    border-radius: var(--r-lg);
  }
  .login-card-brand {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    align-items: center;
    padding: 16px 20px;
  }
  .login-card-form { padding: 26px 22px; }
  .login-title { font-size: 19px; }
}

/* ── Shake animation ─────────────────────────────────────────────── */

@keyframes _shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-6px); }
  40%     { transform: translateX(5px); }
  60%     { transform: translateX(-4px); }
  80%     { transform: translateX(3px); }
}
.is-shaking { animation: _shake calc(var(--shake-dur-a) * 2ms + var(--shake-dur-b) * 2ms) ease; }

/* ── Mobile responsive ───────────────────────────────────────────── */

@media (max-width: 768px) {

  .id-page-wrap { padding: 0 16px; }

  .id-layout {
    grid-template-columns: 1fr;
    gap: 0;
    padding-top: 0;
  }

  .id-left-nav {
    position: sticky;
    top: 48px;
    height: auto;
    display: block;
    z-index: 10;
    background: var(--bg-0);
    border-bottom: 1px solid var(--border);
    margin: 0;
    padding: 0;
  }

  .id-left-nav__title { display: none; }

  .id-left-nav__nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 4px;
    padding: 8px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .id-left-nav__nav::-webkit-scrollbar { display: none; }

  .id-nav-item {
    width: auto;
    flex-shrink: 0;
    white-space: nowrap;
    padding: 7px 12px;
    font-size: 12.5px;
    border-radius: 999px;
  }
  .id-nav-item svg { display: none; }
  .id-nav-item.is-active { background: var(--bg-hover); }
  .id-nav-badge { margin-left: 6px; }

  .id-main { padding-top: 20px; }

  .id-section { margin-bottom: 36px; scroll-margin-top: 120px; }

  .id-content { padding: 0 0 64px; }

  .id-card__inner { padding: 16px; }
  .integration-row { padding: 14px 16px; }

  #banner-preview { height: 90px !important; }
}

/* ── Error pages (404/403/500) - mismo diseño que Netline (mismos tokens) ── */

.error-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px;
}

.error-code {
  font-size: 140px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.06em;
  color: var(--bg-3);
  user-select: none;
  margin-bottom: 8px;
}

.error-msg {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-1);
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}

.error-sub {
  font-size: 13.5px;
  color: var(--text-3);
  max-width: 300px;
  line-height: 1.6;
  margin: 0 0 28px;
}
