/* ============================================================
   Snip — clean light design system (devbay style)
   Light theme is the default; dark via [data-theme="dark"]
   ============================================================ */

:root {
  --bg: #f8fafc;
  --bg-soft: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-dim: #64748b;
  --text-faint: #94a3b8;
  --accent-1: #6366f1;
  --accent-2: #4f46e5;
  --accent-3: #818cf8;
  --accent-soft: rgba(99, 102, 241, 0.08);
  --ok: #10b981;
  --err: #ef4444;
  --nav-bg: #f8fafc;
  --input-bg: #ffffff;
  --input-text: #0f172a;
  --shadow: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-hover: 0 4px 12px 0 rgba(15, 23, 42, 0.08);
  --qr-bg: #ffffff;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --card: #1e293b;
  --border: #334155;
  --border-strong: #475569;
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --text-faint: #64748b;
  --accent-1: #818cf8;
  --accent-2: #a5b4fc;
  --accent-3: #6366f1;
  --accent-soft: rgba(129, 140, 248, 0.14);
  --nav-bg: #0f172a;
  --input-bg: #1e293b;
  --input-text: #f1f5f9;
  --shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 4px 12px 0 rgba(0, 0, 0, 0.4);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s, color 0.3s;
}

::selection { background: rgba(99, 102, 241, 0.2); }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input { font: inherit; }

:focus-visible {
  outline: 2px solid var(--accent-1);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ---------- Cards & buttons ---------- */

.glass {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.625rem;
  box-shadow: var(--shadow);
}

.gradient-text {
  color: var(--accent-1);
}

.btn-gradient {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--accent-1);
  color: #fff;
  border-radius: 0.5rem;
  padding: 0.85rem 1.6rem;
  font-weight: 600;
  font-size: 1rem;
  white-space: nowrap;
  transition: background 0.15s;
}
.btn-gradient:hover { background: var(--accent-2); }
.btn-gradient:active { background: var(--accent-2); }
.btn-gradient:disabled { opacity: 0.75; cursor: wait; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.6rem 1.1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.92rem;
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); background: var(--bg-soft); }
.btn-ghost.small { padding: 0.4rem 0.9rem; font-size: 0.85rem; }
.btn-icon-only { padding: 0.6rem; }
.btn-ghost svg, .btn-icon-only svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ---------- Nav ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem clamp(1rem, 4vw, 2.5rem);
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 0.55rem; font-weight: 700; font-size: 1.25rem; }

.nav-links { display: flex; gap: 1.5rem; }
.nav-links a { color: var(--text-dim); font-size: 0.95rem; font-weight: 500; transition: color 0.15s; }
.nav-links a:hover { color: var(--text); }

.nav-actions { display: flex; align-items: center; gap: 0.6rem; }

.lang-switch {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow: hidden;
  background: var(--bg-soft);
}
.lang-btn {
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-faint);
  transition: background 0.15s, color 0.15s;
}
.lang-btn[aria-pressed="true"] {
  background: var(--accent-1);
  color: #fff;
}

.icon-btn { display: inline-flex; padding: 0.5rem; border-radius: 0.5rem; color: var(--text-dim); border: 1px solid var(--border); background: var(--bg-soft); transition: color 0.15s, border-color 0.15s; }
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ---------- Hero ---------- */

.hero {
  max-width: 880px;
  margin: 0 auto;
  padding: clamp(3rem, 8vw, 5.5rem) 1.25rem 2.5rem;
  text-align: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 1.5rem;
}
.badge-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-1);
}

.hero-title {
  font-size: clamp(2.4rem, 6.5vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.12;
  margin-bottom: 1.1rem;
}

.hero-subtitle {
  max-width: 560px;
  margin: 0 auto 2.2rem;
  color: var(--text-dim);
  font-size: clamp(1rem, 2vw, 1.13rem);
}

/* ---------- Tool card ---------- */

.tool-card {
  padding: clamp(1.1rem, 3vw, 1.6rem);
  text-align: left;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.4rem 0.4rem 1.1rem;
  border-radius: 0.625rem;
  border: 1px solid var(--border);
  background: var(--input-bg);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-row:focus-within {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.input-icon { width: 20px; height: 20px; color: var(--text-faint); flex-shrink: 0; }

#url-input {
  flex: 1;
  min-width: 0;
  padding: 0.75rem 0.4rem;
  border: none;
  background: transparent;
  color: var(--input-text);
  font-size: 1rem;
}
#url-input::placeholder { color: var(--text-faint); }
#url-input:focus { outline: none; }

.field-error {
  margin: 0.75rem 0.5rem 0;
  color: var(--err);
  font-size: 0.9rem;
  font-weight: 500;
}

/* Result */

.result {
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
  animation: fadeUp 0.35s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

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

.result-url { min-width: 0; }
.result-label { display: block; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); margin-bottom: 0.15rem; }
#short-url {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent-1);
  border-bottom: 1px dashed var(--border-strong);
}
#short-url:hover { border-bottom-style: solid; }
.provider-note { display: block; margin-top: 0.2rem; font-size: 0.8rem; color: var(--text-faint); }

.result-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.result-actions .btn-ghost svg { width: 16px; height: 16px; }

.qr-wrap {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-radius: 0.625rem;
  background: var(--card);
  border: 1px solid var(--border);
  animation: fadeUp 0.3s ease;
}
#qr-canvas {
  width: 140px; height: 140px;
  background: var(--qr-bg);
  border-radius: 0.5rem;
  padding: 6px;
}

/* ---------- Trust chips ---------- */

.trust-row { display: flex; justify-content: center; gap: 0.7rem; flex-wrap: wrap; margin-top: 1.4rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 500;
}
.chip svg { width: 14px; height: 14px; color: var(--ok); }

/* ---------- Sections ---------- */

.section { max-width: 880px; margin: 0 auto; padding: 2.5rem 1.25rem 1rem; }
.section-title { font-size: clamp(1.5rem, 3.5vw, 2rem); font-weight: 700; margin-bottom: 1.6rem; text-align: center; letter-spacing: -0.01em; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.1rem; }
.feature-card { padding: 1.6rem; text-align: left; transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s; }
.feature-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-hover);
}
.feature-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 0.5rem;
  background: var(--accent-soft);
  color: var(--accent-1);
  margin-bottom: 1rem;
}
.feature-icon svg { width: 22px; height: 22px; }
.feature-card h3 { font-size: 1.1rem; margin-bottom: 0.4rem; }
.feature-card p { color: var(--text-dim); font-size: 0.94rem; }

/* Steps */

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.1rem; }
.step { display: flex; align-items: flex-start; gap: 0.9rem; padding: 1.2rem 1.3rem; }
.step-num {
  flex-shrink: 0;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  background: var(--accent-1);
}
.step p { color: var(--text-dim); font-size: 0.95rem; }

/* FAQ */

.faq-list { display: grid; gap: 0.8rem; max-width: 720px; margin: 0 auto; }
.faq-item { padding: 1rem 1.3rem; }
.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.98rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+";
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--accent-1);
  transition: transform 0.2s;
}
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item p { margin-top: 0.7rem; color: var(--text-dim); font-size: 0.93rem; }

/* ---------- History ---------- */

.history-list { list-style: none; display: grid; gap: 0.6rem; margin-bottom: 1rem; }
.history-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1rem;
  border-radius: 0.625rem;
  border: 1px solid var(--border);
  background: var(--card);
  transition: border-color 0.15s;
}
.history-item:hover { border-color: var(--border-strong); }
.history-main { flex: 1; min-width: 0; }
.history-short {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent-1);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-long { color: var(--text-faint); font-size: 0.82rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-meta { color: var(--text-faint); font-size: 0.8rem; flex-shrink: 0; }
.history-item .btn-ghost { padding: 0.4rem 0.7rem; font-size: 0.8rem; }
.history-item .btn-ghost svg { width: 15px; height: 15px; }

/* ---------- Footer ---------- */

.footer {
  margin-top: 3.5rem;
  padding: 2.5rem 1.25rem 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
}
.footer-main { display: flex; align-items: center; justify-content: center; gap: 0.6rem; }
.footer-brand { display: flex; align-items: center; gap: 0.45rem; font-weight: 700; font-size: 1.1rem; }
.footer-tagline { color: var(--text-dim); font-size: 0.92rem; margin-top: 0.4rem; }
.footer-links { display: flex; justify-content: center; gap: 1.6rem; margin: 1.2rem 0; }
.footer-links a { color: var(--text-dim); font-size: 0.9rem; font-weight: 500; transition: color 0.15s; }
.footer-links a:hover { color: var(--text); }
.footer-credit { color: var(--text-faint); font-size: 0.82rem; max-width: 520px; margin: 0 auto 0.6rem; }
.footer-rights { color: var(--text-faint); font-size: 0.82rem; }

/* ---------- Spinner ---------- */

.btn-spinner {
  display: none;
  width: 18px; height: 18px;
  animation: spin 0.9s linear infinite;
}
.btn-gradient.loading .btn-spinner { display: block; }
.btn-gradient.loading .btn-label { opacity: 0.85; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .nav-links { display: none; }
  .input-row { flex-direction: column; border-radius: 1rem; padding: 0.7rem; }
  #url-input { width: 100%; text-align: center; }
  .btn-gradient { width: 100%; }
  .result-main { flex-direction: column; align-items: stretch; text-align: center; }
  .result-actions { justify-content: center; }
  .history-item { flex-wrap: wrap; }
  .history-meta { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}
