/* Hardware Hunter — Account surface (DESIGN.md "The Market Instrument").
   Scoped under .public-account; relies on the public.css console palette. */

.public-account {
  --account-width: 860px;
  --panel-pad: clamp(1.1rem, 2.5vw, 1.6rem);
}

.account-shell {
  width: 100%;
  max-width: var(--account-width);
  margin: 0 auto;
  padding: var(--public-gutter) var(--public-gutter) 4rem;
  flex: 1 0 auto;
}

/* ── Hero ─────────────────────────────────────────────────────────────────── */

.account-kicker {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber-dim);
  margin: 0 0 0.5rem;
}

.account-shell > h1 {
  font-family: var(--font-heading);
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.025em;
  margin: 0;
}

.account-lede {
  color: var(--text-secondary);
  margin: 0.6rem 0 0;
  max-width: 52ch;
}

/* ── Panels ───────────────────────────────────────────────────────────────── */

.account-panel {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--radius-lg);
  padding: var(--panel-pad);
  margin-top: var(--spacing-section, 1.75rem);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.panel-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 0.7rem;
  margin-bottom: 1.1rem;
}

/* Contextual "Learn more" link into the matching docs page. Mono/uppercase to
   rhyme with the docs surface it points at; right-aligned in the panel head. */
.panel-doclink {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  text-decoration: none;
  font: 650 0.66rem/1 var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.panel-doclink:hover,
.panel-doclink:focus-visible {
  color: var(--amber);
}

.panel-doclink span {
  transition: transform 0.15s ease;
}

.panel-doclink:hover span {
  transform: translateX(2px);
}

@media (prefers-reduced-motion: reduce) {
  .panel-doclink span {
    transition: none;
  }
}

.panel-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--bezel-highlight);
  border-radius: 9px;
  background: var(--groove);
  color: var(--amber);
  flex: 0 0 auto;
}

.panel-icon svg {
  width: 16px;
  height: 16px;
}

.panel-head h2 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -0.015em;
  margin: 0;
}

.panel-sub {
  color: var(--text-muted);
  font-size: 0.94rem;
  line-height: 1.48;
  margin: 0 0 1.25rem;
  max-width: 60ch;
}

/* ── Fields ───────────────────────────────────────────────────────────────── */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.field label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.field input,
.field select {
  background: var(--groove);
  border: 1px solid var(--bezel-highlight);
  border-radius: 9px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.94rem;
  line-height: 1.48;
  padding: 0.85rem 1rem;
  min-height: 44px;
  width: 100%;
  box-sizing: border-box;
}

.field input[readonly] {
  color: var(--text-secondary);
  cursor: default;
}

.field input:focus,
.field select:focus,
.field input:focus-visible {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 2px rgba(255, 176, 32, 0.28);
}

.field input[readonly]:focus {
  border-color: var(--bezel-highlight);
  box-shadow: none;
}

.field input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 560px) {
  .field-row { grid-template-columns: 1fr; }
}

.field-help {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.5;
  margin-top: 0.35rem;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.94rem;
  line-height: 1;
  border-radius: 9px;
  min-height: 44px;
  padding: 0 1.15rem;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.btn:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--amber);
  color: var(--groove);
}

.btn-primary:hover {
  background: var(--accent-hover, #ffc04d);
  box-shadow: 0 0 0 1px var(--amber), 0 8px 24px -12px rgba(255, 176, 32, 0.45);
}

/* Light mode: dark text on the amber fill, deeper amber hover. */
html[data-theme="light"] .public-account .btn-primary {
  color: #1a1205;
}

html[data-theme="light"] .public-account .btn-primary:hover {
  background: #a8530a;
  box-shadow: 0 0 0 1px var(--amber), 0 8px 24px -12px rgba(194, 98, 10, 0.4);
}

.btn-ghost {
  background: transparent;
  border-color: var(--bezel-highlight);
  color: var(--text-primary);
}

.btn-ghost:hover {
  background: var(--surface-2);
}

.btn-danger {
  background: transparent;
  border-color: rgba(255, 91, 91, 0.4);
  color: var(--signal-red);
}

.btn-danger:hover {
  background: rgba(255, 91, 91, 0.1);
}

.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-sm {
  min-height: 44px;
  padding: 0 0.9rem;
  font-size: 0.88rem;
}

/* ── Badges ───────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-amber  { color: var(--amber); border-color: rgba(255, 176, 32, 0.4); }
.badge-green  { color: var(--green); border-color: rgba(65, 221, 139, 0.4); }
.badge-red    { color: var(--signal-red); border-color: rgba(255, 91, 91, 0.4); }
.badge-muted  { color: var(--text-secondary); border-color: var(--bezel-highlight); background: var(--groove); }

/* ── API key readout ──────────────────────────────────────────────────────── */

.api-key-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--groove);
  border: 1px solid var(--bezel-highlight);
  border-radius: 9px;
  padding: 0.55rem 0.6rem 0.55rem 1rem;
  overflow: hidden;
}

.api-key-value {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.api-key-value.masked {
  color: var(--text-muted);
  letter-spacing: 0.32em;
  user-select: none;
}

/* Scanline reveal: a single amber sweep across the readout as the key
   appears. Instrument-flavoured, respects reduced motion. */
@keyframes key-scan {
  0%   { transform: translateX(-120%); opacity: 0; }
  8%   { opacity: 1; }
  55%  { opacity: 1; }
  100% { transform: translateX(140%); opacity: 0; }
}

.api-key-scan {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 176, 32, 0.22), transparent);
  transform: translateX(-120%);
}

.api-key-box.revealing .api-key-scan {
  animation: key-scan 0.55s ease-out;
}

/* Copy lamp: tight confirmed-green glow, lit only when the copy succeeds. */
@keyframes lamp-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.copy-lamp {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 8px rgba(65, 221, 139, 0.8);
  flex: 0 0 auto;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.copy-lamp.lit {
  opacity: 1;
  animation: lamp-blink 0.9s ease-in-out 2;
}

.api-key-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.9rem;
  flex-wrap: wrap;
}

/* ── Diagnostic channel rows ──────────────────────────────────────────────── */

.channel-list {
  border-top: 1px solid var(--hair);
}

.channel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--hair);
}

.channel-info {
  min-width: 0;
  flex: 1 1 auto;
}

.channel-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--text-primary);
}

.channel-evidence {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.5;
  margin-top: 0.2rem;
}

.channel-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Sign-in methods (linked identities) */
.signin-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--hair);
}
.signin-label {
  flex: 1 1 auto;
  font-weight: 600;
  color: var(--text-primary);
}
.signin-state {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-family: var(--font-mono);
}

.channel-test-result {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  margin-top: 0.25rem;
  min-height: 1.1em;
}

/* Telegram deep-link connect */
.telegram-link-box {
  margin-top: 1rem;
  background: var(--surface-2);
  border: 1px solid var(--bezel-highlight);
  border-radius: 12px;
  padding: 1rem 1.1rem;
}

.telegram-link-box .deep-link {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--amber);
  word-break: break-all;
  margin-top: 0.4rem;
}

.telegram-link-box .expires {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 0.4rem 0 0;
}

/* ── Billing rows ─────────────────────────────────────────────────────────── */

.billing-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--hair);
}

.billing-label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.billing-value {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
}

.billing-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

/* ── Danger zone ──────────────────────────────────────────────────────────── */

.account-panel-danger {
  border-color: rgba(255, 91, 91, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 91, 91, 0.04);
}

.account-panel-danger .panel-icon {
  color: var(--signal-red);
  border-color: rgba(255, 91, 91, 0.4);
}

/* ── TOTP flow ────────────────────────────────────────────────────────────── */

.totp-setup-flow {
  margin-top: 1rem;
}

.totp-qr {
  width: 168px;
  height: 168px;
  background: #fff;
  border-radius: 9px;
  padding: 6px;
  margin: 0 0 1rem;
}

.totp-qr img { width: 100%; height: 100%; display: block; }

.totp-secret-box {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--groove);
  border: 1px solid var(--bezel-highlight);
  border-radius: 9px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
  word-break: break-all;
}

.backup-codes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
  margin: 0.8rem 0 1rem;
}

.backup-code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--groove);
  border: 1px solid var(--bezel-highlight);
  border-radius: 7px;
  padding: 0.5rem 0.6rem;
  text-align: center;
}

/* ── Messages + toast ─────────────────────────────────────────────────────── */

.msg {
  border-radius: 9px;
  padding: 0.7rem 0.9rem;
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0.6rem 0;
}

.msg-success { color: var(--green); background: rgba(65, 221, 139, 0.08); border: 1px solid rgba(65, 221, 139, 0.3); }
.msg-error   { color: var(--signal-red); background: rgba(255, 91, 91, 0.08); border: 1px solid rgba(255, 91, 91, 0.3); }

#toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 0.8rem);
  background: var(--bezel);
  border: 1px solid var(--bezel-highlight);
  border-radius: 999px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.6rem 1.1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 50;
}

#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.show.error { border-color: rgba(255, 91, 91, 0.5); color: var(--signal-red); }

/* ── Reduced motion ───────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .api-key-box.revealing .api-key-scan { animation: none; opacity: 0; }
  .copy-lamp.lit { animation: none; }
  #toast { transition: none; }
  .btn { transition: none; }
}

/* ── Toggle switch (channel enabled) ──────────────────────────────────────── */

.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  flex: 0 0 auto;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .slider {
  position: absolute;
  inset: 0;
  background: var(--bezel);
  border: 1px solid var(--bezel-highlight);
  border-radius: 999px;
  transition: background 0.15s ease;
}

.switch .slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  top: 2px;
  background: var(--text-muted);
  border-radius: 999px;
  transition: transform 0.15s ease, background 0.15s ease;
}

.switch input:checked + .slider { background: rgba(65, 221, 139, 0.2); border-color: rgba(65, 221, 139, 0.5); }
.switch input:checked + .slider::before { transform: translateX(16px); background: var(--green); }
.switch input:focus-visible + .slider { outline: 2px solid var(--amber); outline-offset: 2px; }

/* Agent handoff: the paste-to-your-agent block under API access. */
.agent-handoff {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--hair);
}

.agent-handoff-head {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.agent-handoff-sub {
  margin-bottom: 0.6rem;
}

.agent-handoff-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
}

.agent-paste {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--groove);
  border: 1px solid var(--bezel-highlight);
  border-radius: 9px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 0.55rem 0.75rem;
}

.agent-paste:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.agent-handoff-row .btn { flex: 0 0 auto; }
