/* =========================================================================
   2FA codes (TOTP) — generator + key vault
   ========================================================================= */

.totp-tool {
  height: 100%;
  overflow-y: auto;
  padding: 28px max(40px, calc((100% - 920px) / 2)) 64px;
}

/* ---------- header ---------- */
.totp-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.totp-head h1 {
  margin: 0;
  font-size: 22px; font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-hi);
}
.totp-head p {
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-muted);
  max-width: 620px;
  text-wrap: pretty;
}

/* ---------- section heads ---------- */
.totp-results { margin-bottom: 28px; }
.totp-results-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px;
}
.totp-results-head h2 {
  margin: 0;
  font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
}
.totp-sec-icon { font-size: 18px; color: var(--color-primary); }
.totp-count {
  font-size: 11px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(var(--primary-rgb, 127,13,242), 0.12);
  color: var(--color-primary);
}
.totp-saveall { font-size: 12px; padding: 6px 12px; }

/* ---------- input card ---------- */
.totp-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 28px;
}
.totp-card-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700;
  color: var(--text-hi);
  margin-bottom: 12px;
}
.totp-card-title > .material-symbols-outlined { font-size: 18px; color: var(--text-muted); }

.totp-input {
  width: 100%;
  min-height: 120px;
  padding: 14px 16px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-hi);
  resize: vertical;
  outline: none;
  transition: border-color 120ms;
}
.totp-input:focus { border-color: var(--color-primary); }
.totp-input::placeholder { color: var(--text-faint); }

.totp-input-foot {
  display: flex; align-items: center; gap: 16px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.totp-hint {
  flex: 1; min-width: 220px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-faint);
  text-wrap: pretty;
}
.totp-hint code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  padding: 1px 5px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--text-muted);
}

/* ---------- code grid ---------- */
.totp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.totp-code-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex; flex-direction: column;
  gap: 12px;
  transition: border-color 200ms;
}
.totp-code-card.is-urgent { border-color: rgba(248,113,113,0.45); }
.totp-code-card.is-error  { border-color: rgba(248,113,113,0.3); }

.totp-code-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px;
}
.totp-code-info { min-width: 0; }
.totp-code-label {
  font-size: 13.5px; font-weight: 600;
  color: var(--text-hi);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.totp-code-key {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 3px;
  font-size: 11px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}
.totp-code-key .material-symbols-outlined { font-size: 12px; }

.totp-code-actions {
  display: flex; align-items: center; gap: 2px;
  flex-shrink: 0;
}
.totp-saved-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 600;
  color: #34d399;
}
.totp-saved-tag .material-symbols-outlined { font-size: 13px; }

.totp-code-bottom {
  display: flex; align-items: center; gap: 12px;
}

/* big code button (click to copy) */
.totp-code-value {
  flex: 1;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 120ms, background 120ms;
}
.totp-code-value:hover {
  border-color: rgba(var(--primary-rgb, 127,13,242), 0.45);
  background: rgba(var(--primary-rgb, 127,13,242), 0.04);
}
.totp-code-digits {
  font-size: 28px; font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  color: var(--text-hi);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  line-height: 1;
}
.totp-code-digits.is-hidden {
  color: var(--text-muted);
  letter-spacing: 0.12em;
}
.totp-code-copy {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}
.totp-code-copy .material-symbols-outlined { font-size: 14px; }
.totp-code-value:hover .totp-code-copy { color: var(--color-primary); }

.totp-code-err {
  flex: 1;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 12px;
  font-size: 12.5px;
  color: #f87171;
}
.totp-code-err .material-symbols-outlined { font-size: 16px; }

/* countdown ring */
.totp-ring {
  position: relative;
  width: 32px; height: 32px;
  flex-shrink: 0;
  display: grid; place-items: center;
}
.totp-ring svg { position: absolute; inset: 0; }
.totp-ring-track {
  fill: none;
  stroke: var(--color-border);
  stroke-width: 3;
}
.totp-ring-fill {
  fill: none;
  stroke: var(--color-primary);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke 300ms;
}
.totp-ring.is-urgent .totp-ring-fill { stroke: #f87171; }
.totp-ring-num {
  position: relative;
  font-size: 11px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}
.totp-ring.is-urgent .totp-ring-num { color: #f87171; }

/* empty state */
.totp-empty {
  background: var(--color-surface);
  border: 1.5px dashed var(--color-border);
  border-radius: 14px;
  padding: 40px 24px;
}

@media (max-width: 560px) {
  .totp-tool { padding: 22px 18px 48px; }
  .totp-grid { grid-template-columns: 1fr; }
}

/* =========================================================================
   Home widget — 2FA codes
   ========================================================================= */
.w-totp { display: flex; flex-direction: column; gap: 6px; }
.w-totp-row {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: border-color 120ms, background 120ms;
}
.w-totp-row:hover {
  border-color: rgba(var(--primary-rgb, 127,13,242), 0.45);
  background: rgba(var(--primary-rgb, 127,13,242), 0.04);
}
.w-totp-row.is-error { cursor: default; }
.w-totp-label {
  flex: 1; min-width: 0;
  font-size: 12.5px; font-weight: 600;
  color: var(--text-hi);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.w-totp-code {
  font-size: 17px; font-weight: 700;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  color: var(--text-hi);
}
.w-totp-row.is-urgent .w-totp-code { color: #f87171; }
.w-totp-err {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; color: #f87171;
}
.w-totp-err .material-symbols-outlined { font-size: 14px; }
.w-totp-ring {
  position: relative; width: 24px; height: 24px;
  display: grid; place-items: center; flex-shrink: 0;
}
.w-totp-ring svg { position: absolute; inset: 0; }
.w-totp-ring-track { fill: none; stroke: var(--color-border); stroke-width: 2.5; }
.w-totp-ring-fill {
  fill: none; stroke: var(--color-primary); stroke-width: 2.5; stroke-linecap: round;
  transition: stroke-dashoffset 1s linear;
}
.w-totp-row.is-urgent .w-totp-ring-fill { stroke: #f87171; }
.w-totp-ring-num {
  position: relative; font-size: 9px; font-weight: 700;
  font-variant-numeric: tabular-nums; color: var(--text-muted);
}
.w-totp-copy { font-size: 15px; color: var(--text-faint); flex-shrink: 0; }
.w-totp-row:hover .w-totp-copy { color: var(--color-primary); }
.w-totp-more {
  margin-top: 2px;
  padding: 6px;
  font-size: 11.5px; font-weight: 600;
  color: var(--text-muted);
  background: none; border: none; cursor: pointer;
  border-radius: 8px;
}
.w-totp-more:hover { color: var(--color-primary); background: var(--color-bg); }
.w-totp-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.w-totp-open { font-size: 12px; }
