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

/* Honeypot field - hidden from humans */
.hp-field {
  position: absolute;
  left: -9999px;
  top: -9999px;
  opacity: 0;
  height: 0;
  width: 0;
  z-index: -1;
}

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #64748b;
  --success: #22c55e;
  --danger: #dc2626;
  --warning: #f59e0b;
  --background: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--background);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
}

.logo img {
  height: 40px;
  width: auto;
}

.header nav {
  display: flex;
  gap: 12px;
  align-items: center;
}

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

/* Main */
.main {
  flex: 1;
  padding: 40px 20px;
}

.container {
  max-width: 800px;
  margin: 0 auto;
}

/* Hero */
.hero {
  text-align: center;
  margin-bottom: 32px;
}

.hero h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.hero p {
  font-size: 1.1rem;
  color: var(--text-muted);
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  margin-bottom: 32px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

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

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

.btn-secondary {
  background-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background-color: #cbd5e1;
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.85rem;
}

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

.btn-danger:hover {
  background-color: #b91c1c;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}

.tab {
  padding: 12px 20px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s ease;
}

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

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Forms */
.input-group {
  display: flex;
  gap: 12px;
}

.input-group input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  transition: border-color 0.2s ease;
}

.input-group input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Results */
.result {
  margin-top: 24px;
  padding: 20px;
  background-color: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: var(--radius);
}

.result-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.result-display {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.result-display a {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--primary);
  word-break: break-all;
}

.original-url {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 12px;
  word-break: break-all;
}

/* QR Code Result */
.qr-result {
  text-align: center;
}

.qr-result img {
  max-width: 200px;
  margin-bottom: 16px;
  border-radius: var(--radius);
}

.qr-url {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  word-break: break-all;
}

/* Shorten Tab Result */
.result-shorten {
  margin-top: 24px;
  padding: 20px;
  background-color: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: var(--radius);
}

.result-field {
  margin-bottom: 16px;
}

.result-field:last-of-type {
  margin-bottom: 20px;
}

.result-value {
  font-size: 0.95rem;
  color: var(--text);
  word-break: break-all;
}

.result-value a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.result-value a:hover {
  text-decoration: underline;
}

.result-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* QR Tab Result */
.result-qrcode {
  margin-top: 24px;
  padding: 20px;
  background-color: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: var(--radius);
}

.qr-image-row {
  text-align: center;
  margin-bottom: 16px;
}

.qr-image-row img {
  width: 180px;
  height: 180px;
  border-radius: var(--radius);
  background: white;
  padding: 8px;
}

.qr-download-row {
  text-align: center;
  margin-bottom: 20px;
}

.qr-info {
  border-top: 1px solid #86efac;
  padding-top: 16px;
}

.qr-info-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
  gap: 4px;
}

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

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

.qr-info-value {
  font-size: 0.85rem;
  color: var(--text);
  word-break: break-all;
}

.qr-info-short {
  display: flex;
  align-items: center;
  gap: 8px;
}

a.qr-info-value {
  color: var(--primary);
  text-decoration: none;
}

a.qr-info-value:hover {
  text-decoration: underline;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.pagination-btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.pagination-btn:hover {
  background: var(--background);
  border-color: var(--primary);
}

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

/* QR Modal */
.qr-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.qr-modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-lg);
}

.qr-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

.qr-modal-close:hover {
  color: var(--text);
}

.qr-modal-content img {
  max-width: 100%;
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.qr-modal-content p {
  font-size: 0.85rem;
  color: var(--text-muted);
  word-break: break-all;
  margin-bottom: 16px;
}

/* Error */
.error {
  margin-top: 20px;
  padding: 16px;
  background-color: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 0.9rem;
}

/* Features */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
  margin-top: 16px;
}

.feature {
  text-align: center;
  padding: 24px;
}

.feature h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

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

/* Section */
.section {
  margin-bottom: 32px;
}

.section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

.hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* History Section */
#history-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* List Items */
.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--background);
  border-radius: var(--radius);
  gap: 12px;
}

.list-item-info {
  flex: 1;
  min-width: 0;
}

.list-item-info a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  display: block;
  word-break: break-all;
}

.list-item-info a:hover {
  text-decoration: underline;
}

.list-item-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.list-item-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* API Key Display */
.new-key-display {
  margin: 24px 0;
  padding: 20px;
  background-color: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: var(--radius);
}

.new-key-display h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.new-key-display .warning {
  color: #92400e;
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.key-value {
  display: flex;
  align-items: center;
  gap: 12px;
  background: white;
  padding: 12px;
  border-radius: var(--radius);
  flex-wrap: wrap;
}

.key-value code {
  flex: 1;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  font-size: 0.9rem;
  word-break: break-all;
}

/* API Docs */
.api-docs pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 16px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.85rem;
}

.api-docs code {
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
}

/* Footer */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 20px;
  text-align: center;
}

.footer p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Loading & Empty States */
.loading {
  color: var(--text-muted);
  font-style: italic;
  padding: 20px;
  text-align: center;
}

.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 40px 20px;
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .header-content {
    padding: 12px 16px;
  }

  .logo img {
    height: 32px;
  }

  .header nav {
    gap: 8px;
  }

  .btn {
    padding: 8px 14px;
    font-size: 0.85rem;
  }

  .main {
    padding: 24px 16px;
  }

  .hero h1 {
    font-size: 1.5rem;
  }

  .hero p {
    font-size: 1rem;
  }

  .card {
    padding: 16px;
  }

  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab {
    padding: 10px 16px;
    font-size: 0.9rem;
  }

  .input-group {
    flex-direction: column;
  }

  .input-group input {
    width: 100%;
  }

  .input-group .btn {
    width: 100%;
  }

  .features {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .feature {
    padding: 16px;
  }

  .list-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .list-item-actions {
    width: 100%;
    margin-top: 12px;
  }

  .list-item-actions .btn {
    flex: 1;
  }

  .key-value {
    flex-direction: column;
    align-items: stretch;
  }

  .result-display {
    flex-direction: column;
    align-items: flex-start;
  }

  .result-actions {
    width: 100%;
  }

  .result-actions .btn {
    flex: 1;
  }

  .qr-image-row img {
    width: 150px;
    height: 150px;
  }

  .pagination {
    flex-wrap: wrap;
  }

  .user-name {
    display: none;
  }
}

@media (max-width: 400px) {
  .header nav .btn {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .logo img {
    height: 28px;
  }
}
