:root {
  color-scheme: light dark;
  --bg: #0f172a;
  --card: #1e293b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --border: rgba(148, 163, 184, 0.3);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, #1d1f30, #05060f 50%, #02030b);
  color: var(--text);
  display: flex;
  justify-content: center;
  padding: 2rem;
}

main.app {
  width: min(960px, 100%);
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.6);
}

header > h1 {
  margin: 0;
  font-size: clamp(2rem, 3vw + 1rem, 3rem);
}

header > p {
  margin: 0.5rem 0 0;
  color: var(--muted);
  max-width: 46ch;
}

section.builder {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 18px;
  border: 1px solid var(--border);
  padding: 2rem;
}

.utm-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.field span {
  font-size: 0.9rem;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid transparent;
  background: rgba(148, 163, 184, 0.12);
  color: inherit;
  font-size: 1rem;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.12);
}

.field-group {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.field.flex {
  flex: 1;
}

button.primary {
  padding: 0.9rem 1.6rem;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #0f172a;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  align-self: flex-end;
}

button.primary:hover,
button.primary:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(14, 165, 233, 0.35);
}

section.links {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

section.links h2 {
  margin: 0;
}

#empty-state {
  margin: 0;
  color: var(--muted);
}

.link-lists {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.link-list::before {
  content: attr(data-title);
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}

.link-item {
  position: relative;
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 14px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.link-item:hover,
.link-item:focus-visible {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.link-item header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.link-item .link-url {
  margin: 0;
  word-break: break-all;
  font-size: 1rem;
}

.link-item time {
  color: var(--muted);
  font-size: 0.8rem;
}

.link-item footer {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.16);
  color: var(--accent);
}

.context-menu {
  position: fixed;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.4rem;
  display: grid;
  gap: 0.25rem;
  min-width: 150px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.6);
  z-index: 1000;
}

.context-menu[hidden] {
  display: none;
}

.context-menu button {
  background: transparent;
  border: none;
  color: inherit;
  padding: 0.6rem 0.8rem;
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.context-menu button:hover,
.context-menu button:focus-visible {
  background: rgba(56, 189, 248, 0.18);
}

.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: rgba(56, 189, 248, 0.18);
  color: var(--text);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 999px;
  padding: 0.75rem 1.25rem;
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  z-index: 999;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 640px) {
  body {
    padding: 1rem;
  }

  main.app {
    padding: 1.5rem;
  }

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

  button.primary {
    width: 100%;
  }

  .toast {
    left: 50%;
    right: auto;
    transform: translate(-50%, 20px);
    width: calc(100% - 2rem);
    text-align: center;
  }

  .toast.visible {
    transform: translate(-50%, 0);
  }
}
