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

:root {
  --bg: #0c0a09;
  --surface: #1c1917;
  --surface-hover: #292524;
  --border: #3a3532;
  --text: #fafaf9;
  --text-muted: #a8a29e;
  --accent: #f59e0b;
  --accent-dim: #b45309;
  --success: #65a30d;
  --danger: #dc2626;
  --radius: 14px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.5), 0 8px 10px -6px rgba(0,0,0,0.4);
}

html {
  font-size: 16px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrapper {
  width: 100%;
  max-width: 480px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-lg);
}

.logo {
  text-align: center;
  margin-bottom: clamp(1.25rem, 4vw, 2rem);
}

h1 {
  font-size: clamp(1.25rem, 4.5vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--text);
}

.subtitle {
  color: var(--text-muted);
  font-size: clamp(0.8rem, 2.5vw, 0.9rem);
  margin-top: 0.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

input[type="text"],
input[type="url"] {
  width: 100%;
  padding: 0.9rem 1rem;
  background: #171412;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

@media (pointer: coarse) {
  input[type="text"],
  input[type="url"] {
    font-size: 16px;
    padding: 1rem 1rem;
  }
}

input[type="text"]:hover,
input[type="url"]:hover {
  border-color: #57534e;
}

input[type="text"]:focus,
input[type="url"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12);
}

input[type="text"]::placeholder,
input[type="url"]::placeholder {
  color: #57534e;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.9rem 1.75rem;
  min-height: 48px;
  border: none;
  border-radius: 10px;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
  text-decoration: none;
  letter-spacing: -0.01em;
  -webkit-appearance: none;
  appearance: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: var(--accent);
  color: #0c0a09;
  width: 100%;
}

.btn-primary:hover {
  background: #eab308;
}

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

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

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

.btn-secondary:hover {
  background: #3a3532;
  border-color: #57534e;
}

.btn-danger {
  background: rgba(220, 38, 38, 0.1);
  color: #fca5a5;
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: 10px;
}

.btn-danger:hover {
  background: rgba(220, 38, 38, 0.18);
  border-color: rgba(220, 38, 38, 0.3);
}

.btn-sm {
  padding: 0.65rem 1rem;
  font-size: 0.8rem;
}

.btn-group {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.result-box {
  margin-top: 1.5rem;
  padding: clamp(1rem, 3vw, 1.25rem);
  background: #171412;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: none;
}

.result-box.visible {
  display: block;
  animation: fadeIn 0.2s ease;
}

.result-box.success {
  border-color: rgba(101, 163, 13, 0.25);
}

.result-box.error {
  border-color: rgba(220, 38, 38, 0.25);
}

.result-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.result-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.result-content a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  font-size: clamp(0.85rem, 2.5vw, 0.95rem);
  word-break: break-all;
  padding: 0.25rem 0;
}

.result-content a:hover {
  color: #fbbf24;
}

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

.copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.copy-btn.copied {
  border-color: var(--success);
  color: var(--success);
}

.copy-btn svg {
  width: 16px;
  height: 16px;
}

.divider {
  height: 1px;
  background: #292524;
  margin: 1.5rem 0;
}

.db-section {
  margin-top: 0.5rem;
}

.db-stats {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.stat {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stat-value {
  font-weight: 700;
  color: var(--accent);
  font-size: 1.1rem;
}

.db-display {
  margin-top: 1rem;
  padding: 1rem;
  background: #0c0a09;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 320px;
  overflow-y: auto;
  font-size: 0.75rem;
  font-family: 'Consolas', 'Monaco', monospace;
  line-height: 1.5;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-all;
  display: none;
}

.db-display.visible {
  display: block;
  animation: fadeIn 0.2s ease;
}

.spinner {
  display: none;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(12, 10, 9, 0.15);
  border-top-color: #0c0a09;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.btn.loading .spinner {
  display: inline-block;
}

.btn.loading .btn-text {
  display: none;
}

.back-link {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.back-link a {
  color: var(--accent);
  text-decoration: none;
}

.back-link a:hover {
  text-decoration: underline;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 600px) {
  body {
    padding: 0.75rem;
  }

  .card {
    padding: 1.5rem 1rem;
    border-radius: 12px;
  }

  .btn-primary {
    padding: 1rem 1.75rem;
  }

  .result-box {
    margin-top: 1rem;
  }

  .result-content {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .copy-btn {
    width: 100%;
    height: 44px;
  }

  .copy-btn svg {
    width: 18px;
    height: 18px;
  }

  .db-display {
    max-height: 240px;
    font-size: 0.7rem;
  }

  .db-stats {
    flex-direction: column;
    gap: 0.5rem;
  }

  .divider {
    margin: 1rem 0;
  }
}

@media (max-width: 380px) {
  .card {
    padding: 1.25rem 0.85rem;
    border-radius: 10px;
  }

  .logo {
    margin-bottom: 1rem;
  }

  input[type="text"],
  input[type="url"] {
    padding: 0.8rem 0.85rem;
    font-size: 0.9rem;
  }

  .btn-primary {
    padding: 0.85rem 1.5rem;
    font-size: 0.85rem;
  }
}

@media (min-width: 768px) {
  body {
    padding: 2rem;
  }

  .card {
    padding: 3rem 2.5rem;
  }
}

@media (min-width: 1024px) {
  .card {
    padding: 3.5rem 3rem;
  }
}
