:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #64748b;
  --background: #1f2937;
  --surface: #374151;
  --text: #f3f4f6;
  --text-secondary: #d1d5db;
  --success: #10b981;
  --error: #ef4444;
  --border: #4b5563;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--background);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 1rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  text-align: center;
  padding: 2rem 0;
}

header h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.version {
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin-top: 0.25rem;
  opacity: 0.7;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: fadeIn 0.3s ease-in;
}

.screen.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--surface);
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid var(--border);
}

.card h2 {
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.info {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.input-group {
  margin-bottom: 1rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.checkbox-label span {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

input[type="text"] {
  width: 100%;
  padding: 0.75rem;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.2s;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
}

input[type="text"]::placeholder {
  color: var(--secondary);
}

.btn {
  width: 100%;
  padding: 0.875rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn:disabled:active {
  transform: none;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--background);
}

.btn-large {
  padding: 1.5rem;
  font-size: 1.1rem;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-xs {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  width: auto;
}

.btn-icon {
  font-size: 1.5rem;
}

.address-display {
  text-align: center;
}

.address-display label {
  display: block;
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.address-value {
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  padding: 0.75rem;
  background: var(--background);
  border-radius: 6px;
  margin-bottom: 1rem;
  word-break: break-all;
  color: var(--primary);
}

.scanner-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: black;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 1rem;
}

#scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.scanner-box {
  width: 280px;
  height: 280px;
  border: 4px solid var(--primary);
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    border-color: var(--primary);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6), 0 0 20px var(--primary);
  }
  50% {
    border-color: #818cf8;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6), 0 0 30px #818cf8;
  }
}

.scanner-hint {
  margin-top: 2rem;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  font-weight: 600;
  font-size: 1rem;
}

.scanner-hint-sub {
  margin-top: 0.5rem;
  color: rgba(255, 255, 255, 0.8);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  font-size: 0.875rem;
}

.request-details {
  background: var(--background);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.detail-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.detail-row:last-child {
  margin-bottom: 0;
}

.detail-row label {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
}

.domain-value {
  color: var(--primary);
  font-weight: 600;
  font-size: 1.1rem;
}

.url-display {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.url-value {
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  word-break: break-all;
  color: var(--text-secondary);
  background: var(--surface);
  padding: 0.5rem;
  border-radius: 4px;
  max-height: 80px;
  overflow-y: auto;
}

.debug-info {
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.debug-info pre {
  background: var(--background);
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.button-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--error);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  max-width: 90%;
  text-align: center;
  animation: slideUp 0.3s ease-out;
  cursor: pointer;
}

.toast.hidden {
  display: none;
}

.toast.success {
  background: var(--success);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translate(-50%, 20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--primary);
  color: white;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 2000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  animation: slideDown 0.3s ease-out;
}

.update-banner.hidden {
  display: none;
}

.update-banner p {
  margin: 0;
  font-weight: 600;
}

.update-banner button {
  padding: 0.5rem 1rem;
  background: white;
  color: var(--primary);
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}

.update-banner button:active {
  transform: scale(0.95);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-icon {
  font-size: 4rem;
  text-align: center;
  margin-bottom: 1rem;
}

.result-message {
  text-align: center;
  margin-bottom: 1.5rem;
}

.result-message h3 {
  margin-bottom: 0.5rem;
}

.result-message p {
  color: var(--text-secondary);
}

#scanner-canvas {
  display: none;
}

@media (max-width: 480px) {
  header h1 {
    font-size: 1.75rem;
  }

  .card {
    padding: 1.25rem;
  }
}
