:root {
  --text: #000;
  --background: #fff;
  --border: #000;
  --error: #dc2626;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #fff;
    --background: #000;
    --border: #fff;
    --error: #ef4444;
  }
}

[data-theme="dark"] {
  --text: #fff;
  --background: #000;
  --border: #fff;
  --error: #ef4444;
}

[data-theme="light"] {
  --text: #000;
  --background: #fff;
  --border: #000;
  --error: #dc2626;
}

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

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

.header-title {
  text-decoration: none;
  color: var(--text);
  transition: opacity 0.2s;
}

.header-title:hover {
  opacity: 0.7;
}

.header-buttons {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.github-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 9999px;
  transition: background-color 0.2s;
}

.github-link:hover {
  background-color: rgba(128, 128, 128, 0.1);
}

.github-icon, .theme-icon {
  width: 24px;
  height: 24px;
  display: block;
}

.github-icon[data-theme="dark"],
.theme-icon[data-theme="dark"] {
  display: none;
}

[data-theme="dark"] .github-icon[data-theme="light"],
[data-theme="dark"] .theme-icon[data-theme="light"] {
  display: none;
}

[data-theme="dark"] .github-icon[data-theme="dark"],
[data-theme="dark"] .theme-icon[data-theme="dark"] {
  display: block;
}

#themeToggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 9999px;
  cursor: pointer;
  transition: background-color 0.2s;
}

#themeToggle:hover {
  background-color: rgba(128, 128, 128, 0.1);
}

h1 {
  font-size: 1.5rem;
  font-weight: bold;
}

header {
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

form {
  width: 100%;
  max-width: 28rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

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

label {
  font-size: 0.875rem;
  font-weight: 500;
}

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

input[type="text"]:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--border);
}

.length-selector {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.length-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.random-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.range-container {
  opacity: 1;
  transition: opacity 0.2s;
}

.range-container.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  padding: 0 0.5rem;
  font-size: 0.75rem;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 2px;
  background: var(--border);
  outline: none;
  margin: 1rem 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  transition: transform 0.2s;
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  transition: transform 0.2s;
  border: none;
}

input[type="range"]::-webkit-slider-thumb:hover,
input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.1);
}

button {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--text);
  color: var(--background);
  cursor: pointer;
  transition: all 0.2s;
}

button:hover {
  opacity: 0.9;
}

button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.result {
  margin-top: 2rem;
  width: 100%;
  max-width: 28rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 1.25rem;
  animation: fadeIn 0.3s ease-out forwards;
  text-align: center;
}

.short-url-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.result a {
  color: var(--text);
  text-decoration: underline;
  transition: opacity 0.2s;
  font-size: 1.125rem;
}

.result a:hover {
  opacity: 0.8;
}

#copyButton {
  padding: 0.25rem;
  border-radius: 9999px;
  background: transparent;
  border: none;
  color: var(--text);
}

#copyButton:hover {
  background: rgba(128, 128, 128, 0.1);
}

.error {
  margin-top: 1rem;
  color: var(--error);
  font-size: 0.875rem;
  animation: fadeIn 0.3s ease-out forwards;
  padding: 0.75rem;
  border: 1px solid var(--error);
  border-radius: 0.375rem;
  background-color: rgba(220, 38, 38, 0.1);
}

footer {
  padding: 1rem 1.5rem;
  text-align: center;
  font-size: 0.875rem;
}

.hidden {
  display: none;
}

.custom-url-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.custom-url-input {
  display: none;
}

.custom-url-input.active {
  display: block;
  margin-top: 0.5rem;
}

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