/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Graphite dark ramp (unslop tokens) */
  --bg:        #141415;
  --deep:      #0f0f10;
  --surface:   #19191b;
  --raised:    #232325;
  --hairline:  rgba(237,237,237,0.08);
  --text-1:    #ededed;
  --text-2:    #a1a1a6;
  --text-3:    #85858b;
  --accent:    #3b82f6;
  --accent-fg: #ffffff;
  --positive:  #4cc38a;
  --negative:  #e5484d;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --ease:      cubic-bezier(0.22, 1, 0.36, 1);
  --font:      'Inter', system-ui, -apple-system, sans-serif;
  --mono:      'Geist Mono', 'SF Mono', 'Consolas', monospace;
}

html { font-size: 15px; line-height: 1.4; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

/* ── Header ────────────────────────────────────────── */
header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--hairline);
  height: 56px;
}
.logo {
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: start;
}
.logo svg { color: var(--text-3); }

/* ── Mode switcher (nested radius: 10 - 4 = 6) ─────── */
.mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--deep);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  justify-self: center;
}
.mode-tab {
  height: 28px;
  padding: 0 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 150ms var(--ease), color 150ms var(--ease);
}
.mode-tab:hover {
  color: var(--text-1);
}
.mode-tab.active {
  background: var(--raised);
  color: var(--text-1);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
.mode-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-self: end;
}
.header-note {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.header-note svg { flex-shrink: 0; }

/* ── Main ──────────────────────────────────────────── */
main {
  flex: 1;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.view-panel {
  animation: viewIn 220ms var(--ease);
}
@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
}

/* ── Quick mode ────────────────────────────────────── */
.quick-header {
  margin-bottom: 20px;
}
.quick-header h1 {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.quick-header p {
  font-size: 14px;
  color: var(--text-2);
}

.quick-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.quick-input-section {
  padding: 20px;
}
.quick-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.quick-label-row .field-label {
  margin-bottom: 0;
}
.quick-format-hint {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text-3);
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-wrap input {
  width: 100%;
  height: 44px;
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 0 76px 0 12px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text-1);
  transition: border-color 150ms var(--ease);
}
.input-wrap input:focus {
  outline: none;
  border-color: var(--accent);
}
.input-wrap input::placeholder {
  color: var(--text-3);
}
.input-wrap-actions {
  position: absolute;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.icon-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background 150ms var(--ease), color 150ms var(--ease);
}
.icon-btn:hover {
  background: rgba(237,237,237,0.06);
  color: var(--text-1);
}
.icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.quick-output {
  border-top: 1px solid var(--hairline);
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
}
.quick-output .token-ring {
  width: 56px;
  height: 56px;
}
.quick-output .token-ring svg {
  width: 56px;
  height: 56px;
}
.quick-output .token-code {
  font-size: 32px;
  line-height: 1.1;
}
.quick-output .token-code.placeholder {
  color: var(--text-3);
  cursor: default;
  user-select: none;
}
.quick-output .token-code.placeholder:hover {
  color: var(--text-3);
}
.quick-meta {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text-3);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}
.quick-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.quick-footer {
  border-top: 1px solid var(--hairline);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--deep);
}
.quick-ephemeral {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text-3);
}
.quick-save-btn {
  height: 28px;
  padding: 0 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

/* ── Empty state ───────────────────────────────────── */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 360px;
  text-align: center;
}
.empty-icon {
  width: 48px;
  height: 48px;
  color: var(--text-3);
  margin-bottom: 20px;
}
.empty h2 {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 8px;
}
.empty p {
  font-size: 14px;
  color: var(--text-2);
  max-width: 340px;
  margin-bottom: 24px;
  line-height: 1.5;
}
.empty-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Buttons ───────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-md);
  padding: 0 16px;
  height: 40px;
  transition: background 150ms var(--ease), opacity 150ms var(--ease), transform 100ms var(--ease);
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

.btn-primary {
  background: var(--text-1);
  color: var(--bg);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12);
}
.btn-primary:hover:not(:disabled) { background: #d4d4d4; }

.btn-secondary {
  background: var(--raised);
  color: var(--text-1);
  border: 1px solid var(--hairline);
}
.btn-secondary:hover:not(:disabled) { background: #2a2a2d; }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  padding: 0 8px;
  height: 32px;
}
.btn-ghost:hover:not(:disabled) { color: var(--text-1); }

.btn-danger {
  background: transparent;
  color: var(--negative);
  padding: 0 8px;
  height: 32px;
}
.btn-danger:hover { opacity: 0.8; }

.btn-danger-fill {
  background: var(--negative);
  color: #fff;
}
.btn-danger-fill:hover { background: #d03e43; }

/* ── Token list ────────────────────────────────────── */
.tokens { display: flex; flex-direction: column; gap: 8px; }

.token-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: background 150ms var(--ease);
  animation: cardIn 350ms var(--ease) both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px); }
}

.token-ring {
  position: relative;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
}
.token-ring svg {
  width: 52px;
  height: 52px;
  transform: rotate(-90deg);
}
.token-ring-bg { stroke: var(--raised); }
.token-ring-fg {
  stroke: var(--accent);
  transition: stroke-dashoffset 1s linear, stroke 300ms var(--ease);
}
.token-ring-fg.urgent { stroke: var(--negative); }
.token-ring-fg.idle { stroke: var(--raised); transition: none; }
.token-ring-time {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.token-info { flex: 1; min-width: 0; }
.token-issuer {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.token-code {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: color 150ms var(--ease);
  user-select: all;
}
.token-code:hover { color: var(--accent); }
.token-code.copied { color: var(--positive); }
.token-account {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text-3);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.token-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* ── Dialogs (overlay) ─────────────────────────────── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 200ms var(--ease);
}
.overlay.open { display: flex; }
@keyframes fadeIn { from { opacity: 0; } }

.dialog {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 440px;
  animation: dialogIn 300ms var(--ease);
}
@keyframes dialogIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
}

.dialog h3 {
  font-size: 17px;
  font-weight: 500;
  margin-bottom: 20px;
}

.field { margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 8px;
}
.label-optional {
  color: var(--text-3);
  font-weight: 400;
}
.field input {
  width: 100%;
  height: 40px;
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 0 12px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text-1);
  transition: border-color 150ms var(--ease);
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
}
.field input::placeholder { color: var(--text-3); }

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

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

.field-error {
  font-size: 12px;
  color: var(--negative);
  margin-top: 4px;
  display: none;
}
.field-error.show { display: block; }

/* ── Custom select ─────────────────────────────────── */
.select {
  position: relative;
}
.select-trigger {
  width: 100%;
  height: 40px;
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 0 36px 0 12px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text-1);
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms var(--ease);
  display: flex;
  align-items: center;
}
.select-trigger:focus {
  outline: none;
  border-color: var(--accent);
}
.select-trigger::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--text-3);
  border-bottom: 1.5px solid var(--text-3);
  transform: translateY(-65%) rotate(45deg);
  transition: transform 200ms var(--ease);
}
.select.open .select-trigger::after {
  transform: translateY(-25%) rotate(-135deg);
}
.select.open .select-trigger {
  border-color: var(--accent);
}

.select-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 4px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  animation: menuIn 180ms var(--ease);
}
.select.open .select-menu { display: block; }
@keyframes menuIn {
  from { opacity: 0; transform: translateY(-4px); }
}

.select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text-1);
  cursor: pointer;
  transition: background 120ms var(--ease);
}
.select-option:hover,
.select-option.active {
  background: var(--raised);
}
.select-option .check-icon {
  width: 16px;
  height: 16px;
  color: var(--accent);
  flex-shrink: 0;
  opacity: 0;
}
.select-option.active .check-icon {
  opacity: 1;
}

/* ── Recommended badge (inside dropdown) ───────────── */
.badge-rec {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 500;
  color: var(--positive);
  border: 1px solid rgba(76,195,138,0.25);
  border-radius: 4px;
  padding: 0 4px;
  line-height: 16px;
  white-space: nowrap;
  margin-left: auto;
}
.badge-rec svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

/* ── Smooth Accordion for Optional Section ─────────── */
.optional-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: 12px 0;
  margin-bottom: 4px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  transition: color 150ms var(--ease);
}
.optional-toggle:hover { color: var(--text-1); }
.optional-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.optional-toggle .chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  transition: transform 260ms var(--ease);
  color: var(--text-3);
}
.optional-toggle.expanded .chevron {
  transform: rotate(90deg);
}
.optional-hint {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  font-weight: 400;
  margin-left: auto;
  transition: color 150ms var(--ease);
}

.optional-wrapper {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 280ms var(--ease), opacity 220ms var(--ease);
  opacity: 0;
}
.optional-wrapper.open {
  grid-template-rows: 1fr;
  opacity: 1;
}
.optional-inner {
  overflow: hidden;
  min-height: 0;
}
.optional-body {
  padding: 4px 0 8px;
}
.optional-divider {
  height: 1px;
  background: var(--hairline);
  margin: 8px 0 4px;
}

/* ── Confirm dialog ────────────────────────────────── */
.confirm-body {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: 4px;
}
.confirm-name {
  font-family: var(--mono);
  color: var(--text-1);
  font-weight: 500;
}
.confirm-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: rgba(229,72,77,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: var(--negative);
}

/* ── Passkey dialog ────────────────────────────────── */
.passkey-icon-badge {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: rgba(59,130,246,0.1);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.passkey-desc {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: 16px;
}
.passkey-box {
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.passkey-box-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
  display: flex;
  align-items: center;
  gap: 8px;
}
.passkey-box-note {
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.4;
}

/* ── Toolbar ───────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.toolbar h2 {
  font-size: 17px;
  font-weight: 500;
}
.toolbar-actions { display: flex; gap: 8px; align-items: center; }

/* ── Export/Import ─────────────────────────────────── */
.export-area {
  width: 100%;
  min-height: 120px;
  background: var(--raised);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-1);
  resize: vertical;
}

/* ── Footer ────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--text-3);
  border-top: 1px solid var(--hairline);
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 720px) {
  header {
    display: flex;
    justify-content: space-between;
    padding: 0 16px;
  }
  .header-actions {
    display: none;
  }
}

@media (max-width: 480px) {
  main { padding: 20px 16px 48px; }
  .mode-tab { padding: 0 8px; font-size: 12px; }
  .token-code { font-size: 24px; }
  .quick-output { flex-wrap: wrap; padding: 20px 16px; }
  .quick-output .token-code { font-size: 26px; }
  .quick-actions { width: 100%; }
  .quick-actions .btn { flex: 1; }
  .quick-footer { flex-direction: column; align-items: flex-start; gap: 8px; }
  .token-ring { width: 44px; height: 44px; }
  .token-ring svg { width: 44px; height: 44px; }
  .quick-output .token-ring { width: 48px; height: 48px; }
  .quick-output .token-ring svg { width: 48px; height: 48px; }
  .token-card { padding: 16px; }
  .field-row { grid-template-columns: 1fr; }
  .empty-actions { flex-direction: column; width: 100%; }
  .empty-actions .btn { width: 100%; }
}
