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

:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface-hover: #222240;
  --border: #2a2a4a;
  --text: #e4e4f0;
  --text-muted: #8888aa;
  --primary: #6c63ff;
  --primary-hover: #5a52e0;
  --success: #4ade80;
  --error: #f87171;
  --radius: 12px;
  --radius-sm: 8px;
}

html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
  line-height: 1.5;
}

.container {
  width: 100%;
  max-width: 520px;
  text-align: center;
}

header {
  margin-bottom: 2rem;
}

h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  background: linear-gradient(135deg, var(--primary), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

/* Form */
#shorten-form {
  margin-bottom: 1.5rem;
}

.input-group {
  display: flex;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.35rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
}

#url-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 1rem;
  padding: 0.65rem 0.75rem;
}

#url-input::placeholder {
  color: var(--text-muted);
}

#submit-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
  min-width: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

#submit-btn:hover {
  background: var(--primary-hover);
}

#submit-btn:active {
  transform: scale(0.97);
}

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

#btn-spinner {
  font-size: 1.1rem;
}

.hidden {
  display: none !important;
}

/* Error */
.error {
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 0.5rem;
  text-align: left;
  padding-left: 0.25rem;
}

/* Result Box */
.result-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: left;
  animation: fadeSlideIn 0.3s ease-out;
}

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

.result-label {
  color: var(--success);
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.result-actions {
  display: flex;
  gap: 0.5rem;
}

#short-url {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--primary);
  font-size: 0.95rem;
  padding: 0.6rem 0.75rem;
  font-weight: 500;
  cursor: text;
}

#copy-btn {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  white-space: nowrap;
}

#copy-btn:hover {
  background: var(--border);
  border-color: var(--text-muted);
}

#copy-btn.copied {
  background: rgba(74, 222, 128, 0.15);
  border-color: var(--success);
  color: var(--success);
}

.original-label {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  word-break: break-all;
}

.original-label .label {
  font-weight: 500;
}

#original-url {
  color: var(--text);
}

/* Footer */
footer {
  margin-top: 2.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  z-index: 100;
  animation: toastIn 0.3s ease-out;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Responsive */
@media (max-width: 480px) {
  .input-group {
    flex-direction: column;
    background: transparent;
    border: none;
    padding: 0;
    gap: 0.5rem;
  }

  .input-group:focus-within {
    box-shadow: none;
  }

  #url-input {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
  }

  #submit-btn {
    width: 100%;
    padding: 0.75rem;
  }

  .result-actions {
    flex-direction: column;
  }

  #copy-btn {
    width: 100%;
    text-align: center;
  }
}
