/* ===========================================================================
   Dashboard: account and settings
   ---------------------------------------------------------------------------
   A menu, and one open panel at a time.

   Settings used to be a single scroll with every control on it at once, which
   reads as a wall and makes the dangerous things (close account) share weight
   with the trivial ones (theme). So: a menu of destinations, and a panel that
   replaces it when you pick one. Nothing is open until it is asked for.

   Inside the security panel the same idea applies one level down. One row per
   way into the account, in descending order of strength: an icon to find it
   by, a title carrying its state, one line of plain language, and exactly one
   control. Anything that is a record rather than a setting -- devices,
   activity -- folds away behind a summary, because it is only read when
   something has already gone wrong.
   =========================================================================== */

/* --- Menu ---------------------------------------------------------------- */

.acct-menu {
  display: flex;
  flex-direction: column;
}

.acct-menu__group {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: var(--space-5) 0 var(--space-2);
}

.acct-menu__group:first-child { padding-top: 0; }

.acct-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  width: 100%;
  padding: var(--space-4) var(--space-3);
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-fast, 120ms) var(--ease-out, ease);
}

.acct-item:hover { background: var(--surface-1); }
.acct-item:focus-visible { outline: 2px solid var(--accent-border); outline-offset: -2px; }

.acct-item + .acct-item { box-shadow: 0 -1px 0 var(--border-subtle); }

.acct-item__icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.acct-item__body { flex: 1 1 auto; min-width: 0; }

.acct-item__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-primary);
}

.acct-item__desc {
  margin-top: 1px;
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.acct-item__chevron {
  flex: 0 0 auto;
  color: var(--text-quaternary);
  font-size: var(--text-sm);
}

.acct-item--danger .acct-item__title { color: var(--danger); }
.acct-item--danger .acct-item__icon  { color: var(--danger); }

/* --- Panel --------------------------------------------------------------- */

.acct-back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-tertiary);
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
}

.acct-back:hover { background: var(--surface-1); color: var(--text-primary); }

.acct-panel[hidden] { display: none; }

.sec-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.sec-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.sec-status i { font-size: 0.9em; }

.sec-status[data-tone="ok"] {
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 40%, transparent);
  background: color-mix(in srgb, var(--success) 10%, transparent);
}

.sec-status[data-tone="warn"] {
  color: var(--warning);
  border-color: color-mix(in srgb, var(--warning) 40%, transparent);
  background: color-mix(in srgb, var(--warning) 10%, transparent);
}

/* --- The nudge, shown only while a password is the only way in ------------ */

.sec-nudge {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-top: var(--space-5);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--warning) 34%, transparent);
  background: color-mix(in srgb, var(--warning) 7%, transparent);
  font-size: var(--text-sm);
  line-height: 1.55;
}

.sec-nudge i {
  color: var(--warning);
  margin-top: 2px;
  flex: 0 0 auto;
}

/* --- Method rows --------------------------------------------------------- */

.sec-group {
  margin-top: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.sec-label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--space-1);
}

.sec-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--surface-1);
  transition: border-color var(--dur-med, 180ms) var(--ease-out, ease);
}

.sec-row:hover { border-color: var(--border); }

.sec-row__icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: var(--text-md);
}

.sec-row__body {
  flex: 1 1 auto;
  min-width: 0;
}

.sec-row__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
}

.sec-row__desc {
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--text-tertiary);
}

.sec-row__action {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-top: 2px;
}

.sec-pill {
  display: inline-block;
  padding: 1px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sec-pill--on {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 14%, transparent);
}

.sec-pill--off {
  color: var(--text-tertiary);
  background: var(--surface-2);
}

.sec-pill--warn {
  color: var(--warning);
  background: color-mix(in srgb, var(--warning) 14%, transparent);
}

/* --- Registered passkeys, nested inside their row ------------------------- */

.sec-keys {
  list-style: none;
  margin: var(--space-4) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sec-key {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--surface-2);
}

.sec-key__name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.sec-key__name i {
  color: var(--text-quaternary);
  font-size: 0.85em;
}

.sec-key__meta {
  margin-top: 1px;
  font-size: var(--text-xs);
  color: var(--text-quaternary);
}

.sec-empty {
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-quaternary);
}

/* --- Folded records ------------------------------------------------------ */

.sec-fold {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--surface-1);
  overflow: hidden;
}

.sec-fold + .sec-fold { margin-top: var(--space-3); }

.sec-fold__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.sec-fold__head::-webkit-details-marker { display: none; }

.sec-fold__head:hover { background: var(--surface-2); }

.sec-fold__chevron {
  color: var(--text-quaternary);
  font-size: var(--text-sm);
  transition: transform var(--dur-med, 180ms) var(--ease-out, ease);
}

.sec-fold[open] .sec-fold__chevron { transform: rotate(90deg); }

.sec-fold__title {
  flex: 1 1 auto;
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-primary);
}

.sec-fold__count {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

.sec-fold__body {
  padding: 0 var(--space-5) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-4);
}

/* --- Rows inside a fold -------------------------------------------------- */

.sec-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  font-size: var(--text-sm);
}

.sec-line + .sec-line { border-top: 1px solid var(--border-subtle); }

.sec-line__when {
  color: var(--text-quaternary);
  font-size: var(--text-xs);
  white-space: nowrap;
}

.sec-line__mark {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--text-quaternary);
}

.sec-line__mark[data-tone="warn"] { background: var(--warning); }

/* --- Backup codes -------------------------------------------------------- */

.sec-codes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  letter-spacing: 0.08em;
  text-align: center;
}

.sec-qr {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 216px;
}

.sec-qr svg {
  width: 196px;
  height: 196px;
  background: #fff;
  padding: 10px;
  border-radius: var(--radius-md);
}

.sec-secret {
  display: block;
  margin-top: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  letter-spacing: 0.08em;
  word-break: break-all;
  color: var(--text-primary);
}

.sec-skeleton {
  height: 74px;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--surface-1) 25%, var(--surface-2) 50%, var(--surface-1) 75%);
  background-size: 200% 100%;
  animation: sec-shimmer 1.4s linear infinite;
}

@keyframes sec-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .sec-skeleton { animation: none; }
  .sec-fold__chevron { transition: none; }
}

@media (max-width: 620px) {
  .sec-row {
    flex-wrap: wrap;
    padding: var(--space-4);
  }

  .sec-row__action {
    flex-basis: 100%;
    padding-left: calc(38px + var(--space-4));
  }

  .sec-row__action .btn { width: 100%; justify-content: center; }

  .sec-codes { grid-template-columns: 1fr; }
}
