/* ===== Design Tokens ===== */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a26;
  --bg-input: #0e0e18;
  --border-color: rgba(255, 255, 255, 0.06);
  --border-focus: rgba(99, 102, 241, 0.5);
  --text-primary: #e8e8f0;
  --text-secondary: #8888a0;
  --text-muted: #55556a;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.1);
  --danger: #f87171;
  --warning: #fbbf24;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 30% 20%, rgba(99, 102, 241, 0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(139, 92, 246, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ===== Layout ===== */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  min-height: 100dvh;
}

/* ===== Header ===== */
.app-header {
  text-align: center;
  padding: 24px 0 20px;
}

.app-logo {
  font-size: 2rem;
  margin-bottom: 8px;
}

.app-title {
  font-size: 1.4rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-hover));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.app-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ===== URL Input ===== */
.url-section {
  margin-bottom: 16px;
}

.url-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 4px 4px 4px 14px;
  transition: var(--transition);
}

.url-input-wrapper:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.url-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-right: 8px;
}

.url-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  outline: none;
  min-width: 0;
  padding: 10px 0;
}

.url-input::placeholder {
  color: var(--text-muted);
}

.btn-fetch {
  flex-shrink: 0;
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-fetch:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.btn-fetch:active:not(:disabled) {
  transform: scale(0.96);
}

.btn-fetch:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.url-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 8px;
  padding-left: 2px;
}

/* ===== Divider ===== */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
}

.divider-line {
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.divider-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ===== Paste Details ===== */
.paste-details {
  margin-bottom: 16px;
}

.paste-summary {
  font-size: 0.88rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  list-style: none;
  transition: var(--transition);
  user-select: none;
}

.paste-summary::-webkit-details-marker {
  display: none;
}

.paste-summary::after {
  content: '▸';
  float: right;
  transition: transform var(--transition);
}

.paste-details[open] .paste-summary::after {
  transform: rotate(90deg);
}

.paste-summary:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.paste-section {
  margin-top: 10px;
}

.paste-area {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.paste-area:focus-within {
  border-color: var(--border-focus);
}

.paste-input {
  width: 100%;
  min-height: 140px;
  padding: 14px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}

.paste-input::placeholder {
  color: var(--text-muted);
}

.paste-actions {
  margin-top: 10px;
}

/* ===== Status Message ===== */
.status-message {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  margin-bottom: 16px;
  animation: fadeIn 0.25s ease-out;
}

.status-message.loading {
  background: var(--accent-glow);
  border: 1px solid rgba(99, 102, 241, 0.2);
  color: var(--accent-hover);
}

.status-message.error {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.2);
  color: var(--danger);
}

.status-message.success {
  background: var(--success-bg);
  border: 1px solid rgba(52, 211, 153, 0.2);
  color: var(--success);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Buttons ===== */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  width: 100%;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: white;
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.btn-ghost:hover {
  color: var(--text-secondary);
  background: var(--bg-card);
}

/* ===== Result Section ===== */
.result-section {
  display: none;
  animation: fadeSlideUp 0.35s ease-out;
}

.result-section.visible {
  display: block;
}

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.result-title {
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success);
  font-weight: 500;
}

.result-actions {
  display: flex;
  gap: 6px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: var(--transition);
}

.btn-icon:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.btn-icon:active {
  transform: scale(0.92);
}

/* Result Meta */
.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Tabs */
.result-tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 12px;
}

.tab-btn {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* Result content */
.result-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 12px;
}

.result-raw {
  display: none;
  width: 100%;
  min-height: 250px;
  max-height: 60vh;
  padding: 16px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.7;
  resize: vertical;
  outline: none;
  overflow-y: auto;
}

.result-raw.visible {
  display: block;
}

.result-preview {
  display: none;
  padding: 16px;
  max-height: 60vh;
  overflow-y: auto;
  font-size: 0.9rem;
  line-height: 1.7;
}

.result-preview.visible {
  display: block;
}

/* Clear button */
.clear-btn {
  margin-top: 4px;
  font-size: 0.82rem;
  padding: 10px;
}

/* Preview Markdown Styles */
.result-preview h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 12px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.result-preview h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 20px 0 8px;
}

.result-preview h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 16px 0 6px;
}

.result-preview p {
  margin: 0 0 12px;
}

.result-preview a {
  color: var(--accent-hover);
  text-decoration: none;
}

.result-preview a:hover {
  text-decoration: underline;
}

.result-preview img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 8px 0;
}

.result-preview blockquote {
  border-left: 3px solid var(--accent);
  padding: 4px 12px;
  margin: 8px 0;
  color: var(--text-secondary);
  background: rgba(99, 102, 241, 0.05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.result-preview code {
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.result-preview pre {
  background: var(--bg-input);
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 8px 0;
}

.result-preview pre code {
  background: none;
  padding: 0;
}

.result-preview ul,
.result-preview ol {
  padding-left: 20px;
  margin: 0 0 12px;
}

.result-preview li {
  margin-bottom: 4px;
}

.result-preview hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 16px 0;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  color: white;
  background: var(--success);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Footer ===== */
.app-footer {
  text-align: center;
  padding: 24px 0 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.8;
}

.app-footer a {
  color: var(--text-secondary);
  text-decoration: none;
}

.app-footer a:hover {
  color: var(--accent-hover);
}

/* ===== Mobile ===== */
@media (max-width: 480px) {
  .app-container {
    padding: 12px 12px 32px;
  }

  .app-title {
    font-size: 1.2rem;
  }

  .url-input {
    font-size: 0.88rem;
  }

  .btn-fetch {
    padding: 10px 14px;
    font-size: 0.85rem;
  }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}