/* Lynk — URL Shortener UI */

:root {
  --bg: #0a0c14;
  --bg-2: #0f1220;
  --surface: rgba(255,255,255,.045);
  --surface-2: rgba(255,255,255,.07);
  --border: rgba(255,255,255,.10);
  --border-strong: rgba(255,255,255,.18);
  --text: #eef1f8;
  --text-dim: #9aa3b8;
  --text-faint: #6b7488;
  --accent: #6366f1;
  --accent-2: #22d3ee;
  --accent-3: #a855f7;
  --ok: #34d399;
  --err: #f87171;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 20px 50px -12px rgba(0,0,0,.65);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

html[data-theme="light"] {
  --bg: #f5f7fb;
  --bg-2: #ffffff;
  --surface: rgba(255,255,255,.85);
  --surface-2: rgba(15,18,32,.04);
  --border: rgba(15,18,32,.12);
  --border-strong: rgba(15,18,32,.22);
  --text: #131722;
  --text-dim: #55607a;
  --text-faint: #8a93a8;
  --shadow: 0 18px 44px -14px rgba(20,25,45,.22);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background .3s ease, color .3s ease;
}

h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.02em; }
a { color: inherit; }
code { font-family: var(--mono); font-size: .88em; }

.wrap { width: min(1080px, 100% - 2.5rem); margin-inline: auto; }

/* ---------- ambient background ---------- */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.aurora::before, .aurora::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .40;
}
.aurora::before {
  width: 620px; height: 620px;
  top: -260px; left: -140px;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  animation: drift 22s ease-in-out infinite alternate;
}
.aurora::after {
  width: 560px; height: 560px;
  top: -180px; right: -160px;
  background: radial-gradient(circle, var(--accent-3) 0%, transparent 70%);
  animation: drift 26s ease-in-out infinite alternate-reverse;
}
html[data-theme="light"] .aurora::before,
html[data-theme="light"] .aurora::after { opacity: .22; }
@keyframes drift {
  from { transform: translate(0,0) scale(1); }
  to   { transform: translate(70px, 60px) scale(1.15); }
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 66px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -.02em;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  color: #fff;
  box-shadow: 0 6px 18px -6px var(--accent);
}
.brand-mark svg { width: 19px; height: 19px; }
.topbar-actions { display: flex; align-items: center; gap: .6rem; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .32rem .7rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: .78rem;
  color: var(--text-dim);
  white-space: nowrap;
}
.status-pill i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: background .3s;
}
.status-pill.up i { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.status-pill.down i { background: var(--err); box-shadow: 0 0 0 3px color-mix(in srgb, var(--err) 22%, transparent); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  transition: .2s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn.small { width: 28px; height: 28px; border-radius: 8px; }
.icon-btn.small svg { width: 14px; height: 14px; }

#themeToggle .ico-sun { display: none; }
html[data-theme="light"] #themeToggle .ico-sun { display: block; }
html[data-theme="light"] #themeToggle .ico-moon { display: none; }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 3.2rem 0 2.2rem; }
.hero h1 {
  font-size: clamp(2.1rem, 6vw, 3.5rem);
  font-weight: 800;
  margin-bottom: .8rem;
}
.grad {
  background: linear-gradient(120deg, var(--accent-2), var(--accent), var(--accent-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.sub {
  max-width: 560px;
  margin: 0 auto;
  color: var(--text-dim);
  font-size: 1.03rem;
}

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.card-head h2 { font-size: 1.02rem; font-weight: 650; }

.row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.field { margin-bottom: 1.1rem; }
.field.grow { flex: 1 1 240px; }
.field label {
  display: block;
  margin-bottom: .42rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: .01em;
}
.opt { color: var(--text-faint); font-weight: 400; }

.input-wrap {
  display: flex;
  align-items: center;
  gap: .6rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 .85rem;
  transition: border-color .2s, box-shadow .2s;
}
html[data-theme="light"] .input-wrap { background: #fff; }
.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--accent) 18%, transparent);
}
.input-wrap.invalid { border-color: var(--err); }
.input-wrap.invalid:focus-within { box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--err) 18%, transparent); }
.input-ico { width: 16px; height: 16px; color: var(--text-faint); flex-shrink: 0; }
.prefix-text { color: var(--text-faint); font-family: var(--mono); font-size: .9rem; flex-shrink: 0; }

input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font: inherit;
  font-size: .95rem;
  padding: .78rem 0;
}
input::placeholder { color: var(--text-faint); }
input[type="datetime-local"] { color-scheme: dark; }
html[data-theme="light"] input[type="datetime-local"] { color-scheme: light; }

.hint { margin: .35rem 0 0; font-size: .78rem; color: var(--err); min-height: 1em; }
.hint:empty { min-height: 0; }

/* ---------- buttons ---------- */
.btn-primary {
  width: 100%;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .88rem 1.4rem;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(120deg, var(--accent), var(--accent-3));
  color: #fff;
  font: inherit;
  font-weight: 650;
  font-size: .96rem;
  cursor: pointer;
  box-shadow: 0 10px 26px -10px var(--accent);
  transition: transform .15s, box-shadow .2s, filter .2s;
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 14px 30px -10px var(--accent); filter: brightness(1.06); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: .68; cursor: not-allowed; }

.spinner {
  display: none;
  width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,.32);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .65s linear infinite;
}
.btn-primary.loading .spinner { display: block; }
.btn-primary.loading .btn-label { opacity: .75; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 8px;
  padding: .35rem .7rem;
  font: inherit;
  font-size: .8rem;
  cursor: pointer;
  transition: .2s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); }

.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .6rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: .87rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: .2s;
}
.btn-copy:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); border-color: var(--accent); }
.btn-copy svg { width: 15px; height: 15px; }
.btn-copy.copied { color: var(--ok); border-color: var(--ok); }

/* ---------- result ---------- */
.result-card {
  margin-top: 1.2rem;
  padding: 1.3rem 1.5rem;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--ok) 34%, transparent);
  background: color-mix(in srgb, var(--ok) 7%, var(--surface));
  animation: rise .32s cubic-bezier(.2,.8,.3,1);
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.result-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .85rem; }
.badge {
  display: inline-block;
  padding: .22rem .6rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ok) 18%, transparent);
  color: var(--ok);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.short-link-row { display: flex; gap: .7rem; align-items: stretch; flex-wrap: wrap; }
.short-link {
  flex: 1 1 260px;
  display: flex;
  align-items: center;
  padding: .78rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: .93rem;
  color: var(--accent-2);
  text-decoration: none;
  word-break: break-all;
  transition: .2s;
}
html[data-theme="light"] .short-link { background: #fff; }
.short-link:hover { border-color: var(--accent); color: var(--accent); }

.meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .9rem;
  margin: 1.1rem 0 0;
}
.meta dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); margin-bottom: .2rem; }
.meta dd { margin: 0; font-size: .88rem; color: var(--text-dim); }
.mono { font-family: var(--mono); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- recent ---------- */
.recent { margin-top: 1.2rem; }
.recent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .55rem; }
.recent-item {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .7rem .9rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: .2s;
}
.recent-item:hover { border-color: var(--border-strong); }
.recent-item .ri-code {
  font-family: var(--mono);
  font-size: .82rem;
  padding: .22rem .5rem;
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent-2);
  flex-shrink: 0;
}
html[data-theme="light"] .recent-item .ri-code { color: var(--accent); }
.recent-item .ri-body { flex: 1; min-width: 0; }
.recent-item .ri-short { font-size: .9rem; font-weight: 600; color: var(--accent-2); text-decoration: none; }
html[data-theme="light"] .recent-item .ri-short { color: var(--accent); }
.recent-item .ri-target { font-size: .78rem; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item .ri-actions { display: flex; gap: .35rem; flex-shrink: 0; }

/* ---------- features ---------- */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin: 2.4rem 0 1rem;
}
.feature {
  padding: 1.3rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}
.feature-ico {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent-2);
  margin-bottom: .8rem;
}
html[data-theme="light"] .feature-ico { color: var(--accent); }
.feature-ico svg { width: 19px; height: 19px; }
.feature h3 { font-size: .98rem; font-weight: 650; margin-bottom: .3rem; }
.feature p { margin: 0; font-size: .87rem; color: var(--text-dim); }

/* ---------- footer ---------- */
.footer {
  margin-top: 3rem;
  padding: 1.6rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-faint);
  font-size: .82rem;
}
.footer p { margin: 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translate(-50%, 140%);
  padding: .7rem 1.1rem;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  font-size: .87rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: transform .3s cubic-bezier(.2,.8,.3,1);
  z-index: 100;
  max-width: calc(100vw - 2rem);
}
.toast.show { transform: translate(-50%, 0); }
.toast.err { background: var(--err); color: #fff; }

.hidden { display: none !important; }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .wrap { width: min(100%, 100% - 1.6rem); }
  .hero { padding: 2.2rem 0 1.6rem; }
  .card { padding: 1.2rem; }
  .short-link-row { flex-direction: column; }
  .btn-copy { width: 100%; justify-content: center; }
  .status-pill { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
