:root {
  --bg: #e4efe6;
  --bg-2: #d5e7da;
  --paper: #fffcf7;
  --ink: #14211b;
  --muted: #4d5e54;
  --line: #ddd4c6;
  --stamp: #d84a32;
  --sea: #0f6e56;
  --on-sea: #f3fff9;
  --danger: #8d2e2e;
  --stub: #14211b;
  --on-stub: #fffcf7;
  --shadow: 0 1px 0 rgb(255 255 255 / 0.75) inset, 0 14px 34px rgb(20 33 27 / 0.08);
  --serif: "C059", "Liberation Serif", "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --sans: "iA Writer Quattro S", "Adwaita Sans", "Noto Sans", "Segoe UI", sans-serif;
  --mono: "iA Writer Mono S", "JetBrains Mono", "Liberation Mono", ui-monospace, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1411;
    --bg-2: #17211b;
    --ink: #f4f1ea;
    --muted: #b4c0b6;
    --line: #314038;
    --stamp: #ff6a52;
    --sea: #3dceb0;
    --on-sea: #06241c;
    --danger: #ffb1a8;
    --stub: #0b100e;
    --on-stub: #f4f1ea;
    --paper: #1b2620;
    --shadow: 0 16px 40px rgb(0 0 0 / 0.35);
  }
}

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

html, body { margin: 0; }
body {
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  background:
    radial-gradient(900px 420px at 0% -10%, var(--bg-2), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgb(216 74 50 / 0.08), transparent 50%),
    var(--bg);
}

.wrap {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 72px;
}

.kicker, .leave-kicker {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--stamp);
}

.leave-kicker {
  letter-spacing: 0.01em;
  text-transform: none;
  font-size: 13px;
  font-weight: 650;
}

h1 {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: clamp(36px, 6vw, 58px);
  font-weight: 650;
  letter-spacing: -0.035em;
  line-height: 0.95;
}

.lede {
  margin: 0;
  max-width: 46ch;
  color: var(--muted);
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 28px;
}

.top-actions { display: flex; gap: 8px; flex: none; }

.composer, .tag, dialog {
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.composer {
  border-radius: 20px;
  padding: 18px 18px 14px;
  border-top: 3px solid var(--stamp);
}

label { display: block; font-size: 13px; font-weight: 650; margin-bottom: 6px; }

.row { display: flex; gap: 8px; }

input::placeholder { color: var(--muted); opacity: 1; }

input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--paper) 86%, var(--bg));
  color: var(--ink);
  font: 16px/1.3 var(--sans);
}

#q { flex: 1; }
#go, .btn, .file {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: 600 14px/1 var(--sans);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#go {
  flex: none;
  min-width: 92px;
  border: 0;
  background: var(--sea);
  color: var(--on-sea);
}

.alias-row { margin-top: 12px; }
.hint, .meta, .path, .nomatch { color: var(--muted); }
.hint { margin: 10px 0 0; font-size: 13px; }
.error { margin: 10px 0 0; color: var(--danger); font-weight: 650; }

.examples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.examples button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--muted);
  font: 13px/1 var(--sans);
  cursor: pointer;
}

.banner {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--stamp) 12%, var(--paper));
  color: var(--ink);
}

#replace { margin-top: 8px; }

.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 22px 0 12px;
}

#stats { margin: 0; font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em; color: var(--muted); }
#filter { max-width: 220px; min-height: 40px; }

.empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 28px 12px 8px;
  text-align: center;
  color: var(--muted);
}

.ghost-tag {
  width: 148px;
  height: 88px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  border: 1.5px dashed var(--line);
  color: var(--stamp);
  font-family: var(--serif);
  font-size: 32px;
}

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.nomatch { margin: 0; }

.tag {
  display: grid;
  grid-template-columns: 148px 1fr;
  border-radius: 18px;
  overflow: hidden;
  min-height: 132px;
}

.stub {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px 16px;
  background: var(--stub);
  color: var(--on-stub);
}

.stub::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 50%;
  width: 12px;
  height: 12px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--paper) 30%, transparent);
}

.alias {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(18px, 2vw, 26px);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.05;
  text-align: center;
  overflow-wrap: anywhere;
}

.tag-body { padding: 16px 16px 14px; min-width: 0; }
.host { margin: 0; font-weight: 700; }
.path {
  margin: 2px 0 0;
  font-family: var(--mono);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meta { margin: 8px 0 12px; font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.btn.open, .btn.primary, #go { border: 0; }
.btn.open { background: var(--stub); color: var(--on-stub); }
.btn.primary { background: var(--sea); color: var(--on-sea); padding: 0 18px; }
.btn.danger { color: var(--danger); }
.file input { display: none; }

dialog {
  width: min(440px, calc(100vw - 32px));
  max-height: min(640px, calc(100vh - 32px));
  margin: auto;
  padding: 22px 22px 18px;
  border-radius: 20px;
  color: var(--ink);
  overflow: auto;
}

dialog::backdrop { background: rgb(8 14 11 / 0.52); }

.dest {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: clamp(28px, 5vw, 36px);
  letter-spacing: -0.03em;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.leave-url {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  overflow-wrap: break-word;
  max-height: 7.5em;
  overflow: auto;
}

.leave-alias { margin: 8px 0 0; color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
#qr[open] {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
#qr .hint { text-align: center; }
#qr-svg { display: grid; place-items: center; margin: 8px 0 4px; }
#qr-svg svg {
  width: min(240px, 100%);
  height: auto;
  background: #fff;
  border-radius: 12px;
}

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--sea);
  outline-offset: 3px;
}

@media (max-width: 640px) {
  .wrap { width: min(920px, calc(100% - 24px)); padding-top: 24px; }
  .top { flex-direction: column; align-items: stretch; }
  .tag { grid-template-columns: 1fr; }
  .stub { justify-content: flex-start; padding: 16px 16px 16px 40px; min-height: 72px; }
  .stub::before { left: 16px; top: 50%; transform: translateY(-50%); }
  .alias { text-align: left; }
  .bar { align-items: stretch; flex-direction: column; }
  #filter { max-width: none; }
}

@media (max-width: 380px) {
  .row { flex-direction: column; }
  #go { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
