:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --text: #1b1f2a;
  --muted: #5d6578;
  --border: #e3e6ef;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --radius: 12px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #181b24;
    --text: #e8eaf0;
    --muted: #9aa2b5;
    --border: #2a2f3c;
    --accent: #8b85ff;
    --accent-soft: #23234a;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

.top, main, .foot { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.top { padding-top: 24px; }
.back { color: var(--muted); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--accent); }
h1 { margin: 8px 0 4px; font-size: 28px; letter-spacing: -0.02em; }
.lede { margin: 0 0 20px; color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.field-label { font-weight: 600; font-size: 14px; }
.hint { color: var(--muted); font-size: 14px; margin: 0; overflow-wrap: anywhere; }

input[type="url"], input[type="text"] {
  width: 100%; min-width: 0; font: inherit; color: inherit; background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button {
  font: inherit; cursor: pointer; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary { background: var(--accent); color: #fff; border-color: var(--accent); padding: 9px 20px; font-weight: 600; white-space: nowrap; }
.primary:disabled { opacity: 0.6; cursor: progress; }
.ghost { background: transparent; color: var(--accent); border-color: transparent; padding: 6px 8px; }
.ghost:hover { background: var(--accent-soft); }
.small { font-size: 14px; padding: 4px 10px; flex: 0 0 auto; }

.composer, .result { padding: 16px; display: grid; gap: 8px; }
.result { margin-top: 12px; border-color: var(--accent); }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }
#short-url { font-weight: 600; }

.message { margin: 0; min-height: 1.5em; color: var(--muted); font-size: 14px; }

/* ---- Recent links ---- */
.recent { margin-top: 28px; }
.recent-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.recent-head h2 { margin: 0; font-size: 18px; }
.links { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 8px; }
.link {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; display: grid; gap: 4px;
}
.link-head, .link-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.short { font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.short:hover { text-decoration: underline; }
.clicks { flex: 0 0 auto; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.target {
  color: var(--muted); font-size: 14px; text-decoration: none; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.target:hover { color: var(--text); text-decoration: underline; }
#forget { font-size: 14px; }

.foot { padding-top: 32px; padding-bottom: 32px; color: var(--muted); font-size: 13px; }

/* ---- go/ redirect page ---- */
.go { padding-top: 15vh; }
.go-card { padding: 24px 20px; display: grid; gap: 8px; text-align: center; }
.go-status { margin: 0; font-size: 18px; font-weight: 600; }
.go-target { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 480px) {
  .composer .input-row { flex-direction: column; }
  .composer .primary { width: 100%; }
}
