/* snip - one stylesheet, no framework, no build step. */

:root {
  color-scheme: light dark;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #16191d;
  --muted: #656d78;
  --accent: #2f6df6;
  --accent-text: #ffffff;
  --danger: #c0392b;
  --ok: #1e8a4c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 20, 26, .06), 0 4px 16px rgba(16, 20, 26, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151a;
    --surface: #191d24;
    --border: #2b313b;
    --text: #e8eaed;
    --muted: #9aa3af;
    --accent: #6f9bff;
    --accent-text: #0b1020;
    --danger: #ff7b6b;
    --ok: #5ed394;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 20px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 2rem 1rem 4rem;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

main, .masthead, footer { max-width: 640px; margin-inline: auto; }

/* -- masthead ------------------------------------------------------------ */

.masthead { text-align: center; margin-bottom: 2rem; }

.masthead h1 {
  margin: 0 0 .35rem;
  font-size: clamp(2rem, 6vw, 2.75rem);
  letter-spacing: -.02em;
}

.tagline { margin: 0; color: var(--muted); }

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.field { margin-bottom: 1.25rem; }

label {
  display: block;
  margin-bottom: .4rem;
  font-weight: 600;
  font-size: .9rem;
}

.optional {
  font-weight: 400;
  color: var(--muted);
  font-size: .8rem;
}

input[type="text"] {
  width: 100%;
  padding: .7rem .8rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

input[type="text"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.alias { display: flex; align-items: stretch; }

.alias .prefix {
  display: flex;
  align-items: center;
  padding: 0 .6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-right: 0;
  border-radius: 8px 0 0 8px;
  color: var(--muted);
  font-size: .85rem;
  white-space: nowrap;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alias input { border-radius: 0 8px 8px 0; }

.help { margin: .35rem 0 0; font-size: .8rem; color: var(--muted); }

button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: .7rem 1rem;
  background: var(--accent);
  color: var(--accent-text);
}

button[type="submit"] { width: 100%; }
button:hover:not(:disabled) { filter: brightness(1.08); }
button:disabled { opacity: .6; cursor: progress; }

button.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
  padding: .35rem .7rem;
  font-size: .8rem;
  font-weight: 500;
}

button.ghost:hover { color: var(--danger); border-color: var(--danger); }

.error {
  margin: 1rem 0 0;
  padding: .7rem .8rem;
  border-radius: 8px;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  font-size: .9rem;
}

/* -- history ------------------------------------------------------------- */

.history { margin-top: 2.5rem; }

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .75rem;
}

.history h2 { margin: 0; font-size: 1rem; letter-spacing: .02em; }

.empty { color: var(--muted); font-size: .9rem; margin: 0; }

.history ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }

.history li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .5rem 1rem;
  align-items: center;
}

.history li.fresh { border-color: var(--accent); }

.short {
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
  color: var(--accent);
  text-decoration: none;
}

.short:hover { text-decoration: underline; }

.target {
  grid-column: 1 / -1;
  font-size: .82rem;
  color: var(--muted);
  word-break: break-all;
  margin: 0;
}

.actions { display: flex; gap: .4rem; }

.copied { color: var(--ok); border-color: var(--ok); }

/* -- footer -------------------------------------------------------------- */

footer {
  margin-top: 3rem;
  text-align: center;
  font-size: .8rem;
  color: var(--muted);
}

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

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .95em;
}

@media (max-width: 420px) {
  .history li { grid-template-columns: 1fr; }
  .actions { justify-content: flex-start; }
}
