:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --accent: #2b6cb0;
  --accent-dark: #1a4979;
  --border: #d9dce5;
  --text: #1f2933;
  --muted: #5f6c7b;
  --danger: #c53030;
  --success: #2f855a;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-bar {
  padding: 2rem 3vw 1rem;
  background: linear-gradient(135deg, #0c1b33, #15457a);
  color: white;
  box-shadow: 0 2px 10px rgba(12, 27, 51, 0.25);
}

.top-bar h1 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.subtitle {
  margin-top: 0.5rem;
  max-width: 720px;
  color: rgba(255, 255, 255, 0.8);
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  gap: 1.5rem;
  padding: 1.5rem 3vw 3rem;
  flex: 1;
}

.left-panel, .right-panel {
  background: var(--panel);
  border-radius: 18px;
  padding: 1.75rem;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.article-form label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

textarea {
  width: 100%;
  resize: vertical;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 1rem;
  font-size: 1rem;
  line-height: 1.5;
  min-height: 260px;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.15);
}

.actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

button {
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
}

button.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 10px 20px rgba(43, 108, 176, 0.2);
}

button.primary:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

button.secondary {
  background: rgba(43, 108, 176, 0.08);
  color: var(--accent);
}

button.secondary:hover {
  background: rgba(43, 108, 176, 0.15);
}

.results.hidden {
  display: none;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.article-output {
  background: #f9fafc;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
  max-height: 420px;
  overflow-y: auto;
  line-height: 1.7;
}

.article-output p {
  margin: 0 0 1rem;
}

.article-output a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(43, 108, 176, 0.4);
}

.article-output a:hover {
  color: var(--accent-dark);
  border-bottom-color: var(--accent-dark);
}

.article-output .link-removed {
  color: var(--muted);
  border-bottom: none;
  font-weight: 500;
}

.metrics {
  background: rgba(15, 23, 42, 0.04);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  display: grid;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.right-panel {
  position: relative;
}

.panel-header h2 {
  margin: 0;
}

.panel-subtitle {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.links-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.links-list.empty {
  justify-content: center;
  align-items: center;
  text-align: center;
  color: var(--muted);
}

.link-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.link-card:hover {
  border-color: var(--accent);
  box-shadow: 0 12px 20px rgba(15, 23, 42, 0.08);
}

.link-info {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex: 1;
}

.link-url {
  background: rgba(43, 108, 176, 0.1);
  padding: 0.45rem 0.85rem;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

.link-url:hover {
  background: rgba(43, 108, 176, 0.18);
}

.link-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.anchor-text {
  font-weight: 600;
}

.link-details {
  color: var(--muted);
  font-size: 0.9rem;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  color: var(--muted);
}

.toggle input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
}

.loading {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  color: white;
  z-index: 1000;
}

.loading.hidden {
  display: none;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

#toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #1f2933;
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform: translateY(20px);
  z-index: 1001;
}

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

@media (max-width: 1024px) {
  .dashboard {
    grid-template-columns: 1fr;
  }

  .right-panel {
    order: -1;
  }
}

@media (max-width: 640px) {
  .top-bar {
    padding: 1.5rem 1.25rem 1rem;
  }

  .dashboard {
    padding: 1.25rem;
  }

  .left-panel, .right-panel {
    padding: 1.25rem;
  }
}
