:root {
  --bg: #000000;
  --surface: #0d0d0d;
  --surface-2: #161616;
  --border: rgba(255, 255, 255, 0.14);
  --text: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.55);
  --success: #34d399;
  --danger: #ef4444;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Instrument Serif', serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-tap-highlight-color: transparent;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------------- Liquid glass ---------------- */

.liquid-glass {
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: none;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: hidden;
}

.liquid-glass::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.2px;
  background: linear-gradient(180deg,
    rgba(255,255,255,0.4) 0%, rgba(255,255,255,0.12) 20%,
    rgba(255,255,255,0) 40%, rgba(255,255,255,0) 60%,
    rgba(255,255,255,0.12) 80%, rgba(255,255,255,0.4) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* ---------------- Topbar ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
}

.brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.brand-accent {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 19px;
}

.status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6);
  animation: pulse-warn 1.4s infinite;
}

.status-dot.connected {
  background: var(--success);
  animation: pulse-ok 2s infinite;
}

@keyframes pulse-warn {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.55); }
  70% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

@keyframes pulse-ok {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

/* ---------------- Tabs ---------------- */

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
}

.tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 8px 12px;
  cursor: pointer;
  position: relative;
}

.tab.active { color: var(--text); }

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 10%;
  right: 10%;
  height: 2px;
  background: #fff;
  border-radius: 2px;
}

/* ---------------- Content / Panels ---------------- */

.content {
  flex: 1;
  padding: 18px;
  padding-bottom: 40px;
}

.panel { display: none; }
.panel.active { display: block; animation: fade-in 0.25s ease; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------- Keys ---------------- */

.scan-line {
  position: relative;
  height: 1px;
  background: var(--border);
  margin-bottom: 18px;
  overflow: hidden;
}

.scan-line::before {
  content: '';
  position: absolute;
  top: 0; left: -30%;
  width: 30%; height: 100%;
  background: linear-gradient(90deg, transparent, #fff, transparent);
  animation: scan 1.6s linear infinite;
}

.scan-line.idle::before { animation: none; opacity: 0; }

@keyframes scan {
  0% { left: -30%; }
  100% { left: 100%; }
}

.keys-list { display: flex; flex-direction: column; gap: 10px; }

.key-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.key-card-value {
  flex: 1;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-all;
  overflow-wrap: anywhere;
}

.key-copy-btn {
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.key-copy-btn.copied {
  background: rgba(52, 211, 153, 0.12);
  border-color: var(--success);
  color: var(--success);
}

.empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
}

.empty-glyph {
  font-family: var(--serif);
  font-style: italic;
  font-size: 40px;
  color: rgba(255,255,255,0.3);
  margin-bottom: 8px;
}

.empty.hidden { display: none; }

.btn-refresh {
  width: 100%;
  margin-top: 16px;
  background: none;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  border-radius: 12px;
  padding: 11px;
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
}

/* ---------------- Guide ---------------- */

.platform-select {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.platform-btn {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 12px;
  padding: 10px 4px;
  font-family: var(--sans);
  font-size: 12.5px;
  cursor: pointer;
}

.platform-btn.active {
  color: var(--text);
  border-color: rgba(255,255,255,0.4);
  background: rgba(255, 255, 255, 0.06);
}

.guide-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
}

.guide-app-title {
  font-family: var(--serif);
  font-style: italic;
  font-size: 19px;
  font-weight: 400;
  color: var(--text);
  margin: 0 0 6px;
}

.guide-app-title:not(:first-child) { margin-top: 22px; }

.guide-link {
  display: inline-block;
  font-size: 12.5px;
  color: var(--success);
  text-decoration: none;
  margin-bottom: 10px;
  word-break: break-all;
}

.guide-steps {
  margin: 0;
  padding-left: 18px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text);
}

.guide-steps li { margin-bottom: 4px; }

.proxy-card {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  text-align: center;
}

.proxy-card-title {
  font-family: var(--serif);
  font-style: italic;
  font-size: 20px;
  margin-bottom: 4px;
}

.proxy-card-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* ---------------- Complaint ---------------- */

.field-label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  padding: 12px;
  resize: vertical;
  margin-bottom: 12px;
}

.textarea:focus {
  outline: none;
  border-color: rgba(255,255,255,0.4);
}

.complaint-status {
  margin-top: 10px;
  font-size: 13px;
  min-height: 18px;
}

.complaint-status.ok { color: var(--success); }
.complaint-status.err { color: var(--danger); }

/* ---------------- Buttons ---------------- */

.btn-primary {
  display: block;
  width: 100%;
  text-align: center;
  background: #ffffff;
  color: #000000;
  border: none;
  border-radius: 999px;
  padding: 13px;
  font-family: var(--sans);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.1s;
}

.btn-primary:active { opacity: 0.85; transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }
