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

:root {
  --bg: #f1f1f1;
  --surface: #fafafa;
  --border: #e4e2dd;
  --border-focus: #1a1a1a;
  --text-primary: #1a1a1a;
  --text-secondary: #767268;
  --text-muted: #252525;
  --accent: #181818;
  --accent-fg: #ffffff;
  --error-bg: #fdf2f2;
  --error-border: #e8c4c4;
  --error-text: #8f0a0a;
  --success-bg: #f2faf5;
  --success-border: #b8dfc6;
  --success-text: #0c612f;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.07), 0 1px 4px rgba(0,0,0,0.04);
  --radius: 10px;
  --radius-sm: 6px;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-weight: 400;
  min-height: 100vh;
  padding: 0 16px 80px;
}

/* ── Header ── */
header {
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.logo {
  font-family: 'DM Sans', sans-serif;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.logo-dot {
  width: 7px;
  height: 7px;
  background: var(--text-primary);
  border-radius: 50%;
  display: inline-block;
  margin-bottom: 4px;
}

.tagline {
  margin-top: 10px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: 0.01em;
}

/* ── GitHub link ── */
.github-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s, opacity 0.15s;
  opacity: 0.7;
}

.github-link:hover {
  opacity: 1;
  color: var(--text-primary);
}

.github-link img {
  width: 22px;
  height: 22px;
  filter: brightness(0);
  opacity: 0.55;
  transition: opacity 0.15s;
}

.github-link:hover img {
  opacity: 1;
}

.github-label {
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ── Layout ── */
main {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 20px 24px 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.card-number {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  padding: 3px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  line-height: 1.6;
}

.card-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
}

.card-body {
  padding: 20px 24px 24px;
}

/* ── Form ── */
.field {
  margin-bottom: 14px;
}

label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 7px;
}

input[type="text"],
select {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

input[type="text"]:focus,
select:focus {
  border-color: var(--border-focus);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(26,26,26,0.06);
}

input::placeholder { color: #a8a39c; }

.select-wrapper {
  position: relative;
}

.select-wrapper::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-muted);
  pointer-events: none;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ── Button ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 22px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  width: 100%;
  margin-top: 6px;
}

.btn-primary:hover:not(:disabled) { opacity: 0.85; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 7px 13px;
  font-size: 0.78rem;
}

.btn-ghost:hover:not(:disabled) { background: var(--bg); }

.btn-ghost.copied {
  color: var(--success-text);
  border-color: var(--success-border);
  background: var(--success-bg);
}

/* Spinner */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: none;
}

.btn-primary.loading .spinner { display: block; }
.btn-primary.loading .btn-label { opacity: 0.6; }

.btn-ghost .spinner {
  border-color: rgba(0,0,0,0.15);
  border-top-color: var(--text-secondary);
}

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

/* ── Result / Error / Info boxes ── */
.result-box {
  margin-top: 16px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  animation: fadeSlideIn 0.2s ease;
}

.error-box {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  margin-top: 14px;
  animation: fadeSlideIn 0.2s ease;
}

.error-label {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--error-text);
  opacity: 0.7;
  margin-bottom: 4px;
}

.error-message {
  font-size: 0.875rem;
  color: var(--error-text);
}

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

/* ── Short URL result ── */
.short-url-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 16px;
  animation: fadeSlideIn 0.2s ease;
}

.short-url-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.short-url-link {
  font-family: 'DM Mono', monospace;
  font-size: 0.85rem;
  color: var(--text-primary);
  text-decoration: none;
  word-break: break-all;
}

.short-url-link:hover { text-decoration: underline; }

.short-url-meta {
  padding: 10px 16px;
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.meta-dot {
  width: 3px;
  height: 3px;
  background: var(--text-muted);
  border-radius: 50%;
}

/* ── Lookup result card ── */
.lookup-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 16px;
  animation: fadeSlideIn 0.2s ease;
}

.lookup-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  align-items: start;
}

.lookup-row:last-child { border-bottom: none; }

.lookup-key {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-primary);
  padding-top: 1px;
}

.lookup-value {
  font-size: 0.875rem;
  color: var(--text-primary);
  word-break: break-all;
}

.lookup-value a {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.lookup-value.mono {
  font-family: 'DM Mono', monospace;
  font-size: 0.82rem;
}

.click-count {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.click-badge {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 400;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 1px 8px;
  color: var(--text-secondary);
}

/* ── Divider ── */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Footer ── */
footer {
  max-width: 560px;
  margin: 48px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* ── Responsive ── */
@media (max-width: 500px) {
  header { padding: 40px 0 32px; }
  .card-body { padding: 16px 18px 20px; }
  .card-header { padding: 18px 18px 0; }
  .field-row { grid-template-columns: 1fr; }
  .short-url-header { flex-direction: column; align-items: flex-start; gap: 10px; }
}
