:root {
  --bg: #fafaf8;
  --fg: #111;
  --muted: #666;
  --border: #ddd;
  --accent: #111;
  --accent-fg: #fff;
  --error: #c0392b;
  --radius: 4px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

header h1 {
  font-family: var(--mono);
  font-size: 1.75rem;
  margin: 0 0 0.25rem;
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--muted);
  margin: 0 0 2rem;
  font-size: 0.95rem;
}

.field {
  display: block;
  margin-bottom: 1rem;
}

.label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input[type="text"] {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: var(--mono);
  background: #fff;
  color: var(--fg);
}

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

/* Container for the optional URL actions (shorten toggle / form / error /
 * status). Children are full-width block elements that stack vertically;
 * each has its own internal layout. Was flex-row before, which constrained
 * child widths and prevented the shorten-error from spanning to the edge
 * like other form rows. */
.url-actions {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.link-button {
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0;
  font-family: inherit;
}

.link-button:hover { opacity: 0.7; }
.hint { color: var(--muted); }

/* Filled, solid action button — same visual family as the download
 * buttons (PNG/SVG/PDF) so the action UI doesn't get confused with the
 * outlined status/progress box. Block-level + full-width so it spans the
 * URL field column above and the status box below. */
.action-btn {
  display: block;
  width: 100%;
  font-family: var(--mono);
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  margin-top: 0.5rem;
  padding: 0.7rem 0.85rem;
  background: #2c7a3a;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--accent-fg);
  font-weight: 500;
  transition: opacity 0.15s, transform 0.05s;
}

.action-btn:hover { opacity: 0.85; }
.action-btn:active { transform: translateY(1px); }

.action-btn.warn {
  background: #c08020;
  color: var(--accent-fg);
}

.action-btn.danger {
  background: #c0392b;
  color: var(--accent-fg);
}

.action-btn[hidden] { display: none; }

/* Neutral variant — solid, but in the standard accent (black) so it
 * matches PNG/SVG/PDF download buttons exactly. */
.action-btn.neutral {
  background: var(--accent);
  color: var(--accent-fg);
}

/* Subtle variant — same size and shape as the solid action-btn, but
 * outlined / transparent. Used for secondary actions (e.g., cancel) that
 * should be visually matched to a primary submit button alongside but
 * not compete with it for attention. */
.action-btn.subtle {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
}
.action-btn.subtle:hover { background: #f0f0e8; opacity: 1; }

.shorten-form {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.shorten-form[hidden] { display: none; }

/* Compound input: a flex row that LOOKS like a single text field, with a
 * non-editable "https://is.gd/" prefix so the user can see what their
 * final shortlink will look like as they type the alias. */
.alias-input {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.alias-input:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: transparent;
}

.alias-prefix {
  display: flex;
  align-items: center;
  padding: 0 0.5rem 0 0.85rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 1rem;
  background: #fafaf2;
  border-right: 1px solid var(--border);
  user-select: none;
  white-space: nowrap;
}

.shorten-form input {
  flex: 1;
  min-width: 0;
  padding: 0.7rem 0.85rem;
  border: none;
  outline: none;
  font-size: 1rem;
  font-family: var(--mono);
  background: transparent;
  color: var(--fg);
}

/* Buttons inside the shorten form: auto-width (not full row), stretched
 * vertically to match input height, aligned to the right of the input. */
.shorten-form-btn {
  width: auto;
  margin-top: 0;
  flex: 0 0 auto;
}

.toggles {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.status-box {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 1.5rem;
  /* Match URL input padding / font-size so this row's outer dimensions
   * line up with the input + action buttons above it. */
  padding: 0.7rem 0.85rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  color: var(--muted);
  font-family: var(--mono);
  transition: border-color 0.18s, background 0.18s;
}

/* `.status-box { display: flex }` outweighs `[hidden]` — restore intent. */
.status-box[hidden] { display: none; }

.status-box.idle { color: var(--muted); }
.status-box.working { border-color: var(--accent); background: #fafaf2; color: var(--fg); }
.status-box.improving { border-color: #f0c270; background: #fff5e6; color: #5a3d00; }
.status-box.done { border-color: #6aa86a; background: #f0faf0; color: #244a24; }
.status-box.error { border-color: var(--error); background: #fff5f5; color: var(--error); }

/* Same shape as .status-box but red, used when the shortener API rejects.
 * Sits in place of the shorten-form's status hint; full-width across the
 * URL field column so it visually matches the progress status box. */
.shorten-error {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
  padding: 0.7rem 0.85rem;
  background: #fff5f5;
  border: 1px solid var(--error);
  border-radius: var(--radius);
  font-size: 0.95rem;
  color: var(--error);
  font-family: var(--mono);
}

.shorten-error[hidden] { display: none; }

/* Mirror of .shorten-error in the same row position, but in a green
 * success palette. Replaces both the shorten form and the toggle button
 * after a successful shorten — single visible affirmation that the URL
 * was shortened, instead of toggle + status text living side by side. */
.shorten-success {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
  padding: 0.7rem 0.85rem;
  background: #e6f4ea;
  border: 1px solid #6aa86a;
  border-radius: var(--radius);
  font-size: 0.95rem;
  color: #1f4d1f;
  font-family: var(--mono);
}

.shorten-success[hidden] { display: none; }

.shorten-success-icon { font-size: 1.1rem; line-height: 1; flex: 0 0 auto; }
.shorten-success-text { flex: 1; min-width: 0; line-height: 1.3; }

.shorten-error-icon { font-size: 1.1rem; line-height: 1; flex: 0 0 auto; }

.shorten-error-text { flex: 1; min-width: 0; line-height: 1.3; }

.shorten-error-btn {
  /* Override .action-btn's width:100% — these are inline pills inside the
   * error row, sized to their label, not full-width like the standalone
   * action buttons elsewhere. */
  width: auto;
  margin-top: 0;
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
  flex: 0 0 auto;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.status-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.status-text {
  flex: 1;
  line-height: 1.3;
}

.toggle {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 0.6rem;
  cursor: pointer;
  padding: 0.5rem 0;
}

.toggle input { grid-row: 1 / span 2; align-self: center; }
.toggle span { font-weight: 500; }
.toggle small { color: var(--muted); font-size: 0.8rem; }

.ec-badge {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.85rem;
  background: var(--accent);
  color: var(--accent-fg);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius);
  letter-spacing: 0.04em;
}

.ec-info {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1;
  justify-content: flex-end;
  min-width: 0;
}

.ec-bump {
  font-family: var(--mono);
  font-size: 0.85rem;
  width: 1.6em;
  height: 1.6em;
  padding: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  color: var(--fg);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ec-bump:hover { background: #f0f0e8; border-color: var(--accent); }
.ec-bump[hidden] { display: none; }

.version-token {
  text-decoration: underline dotted;
  text-decoration-color: var(--border);
  cursor: help;
}

.redundancy-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
  min-height: 1.6em;
}

.redundancy-row .variant-ec {
  /* Single-letter badge sits to the left, like a tag for the row. */
  flex: 0 0 auto;
}

.redundancy-note {
  font-size: 0.85rem;
  color: var(--muted);
  font-family: system-ui, sans-serif;
  line-height: 1.3;
  flex: 0 0 auto;
}

.redundancy-row .ec-bump {
  /* Both bump buttons sit on the RIGHT side of the row. */
  flex: 0 0 auto;
}

.info small {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.2rem;
  font-family: system-ui, sans-serif;
}

.info-data {
  color: var(--fg);
  word-break: break-all;
}

.results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

@keyframes dots {
  0%, 20% { content: ""; }
  40% { content: "."; }
  60% { content: ".."; }
  80%, 100% { content: "..."; }
}

.variant {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 0;
}

/* `.variant { display: flex }` has higher specificity than `[hidden]` —
 * without this, hidden cards keep showing. Restore intent. */
.variant[hidden] { display: none; }

.variant-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
}

.variant-title {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0;
  text-transform: uppercase;
}


@media (max-width: 540px) {
  .results { grid-template-columns: 1fr; }
}

.preview {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 180px;
  background: #fafafa;
  border-radius: var(--radius);
  padding: 0.5rem;
}

.loading {
  color: var(--muted);
  font-style: italic;
  font-size: 0.9rem;
}

.loading .loading-dots::after {
  content: "";
  display: inline-block;
  width: 0.5em;
  margin-left: 0.2em;
  animation: dots 1.2s steps(4) infinite;
}

.preview img, .preview canvas, .preview svg {
  /* Both QR cards live in equal-width grid columns, so width: 100% +
   * aspect-ratio: 1 forces both QRs to render at the SAME display size
   * regardless of their internal QR-version (different module counts
   * produce different native PNG sizes; we let the browser stretch them
   * onto identical display boxes). image-rendering: pixelated keeps
   * modules crisp under the stretch. Klemen 2026-05-10. */
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  image-rendering: pixelated;
}

.empty {
  color: var(--muted);
  font-style: italic;
}

.info {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
}

.downloads {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.downloads button {
  padding: 0.55rem 1.2rem;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

.downloads button:hover { opacity: 0.85; }
.downloads button:active { transform: translateY(1px); }

.error-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 180px;
  padding: 1rem;
  background: #fff5f5;
  border: 1px dashed #e0a0a0;
  border-radius: var(--radius);
  color: var(--error);
  font-size: 0.8rem;
  line-height: 1.4;
  text-align: center;
}

footer {
  margin-top: 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.dedication {
  margin-top: 0.4rem;
}

/* The heart is clickable but deliberately gives no visual affordance —
 * not a link, not a button. Discovery is part of the easter egg. */
.dedication-heart {
  cursor: default;
  user-select: none;
}

@media (max-width: 420px) {
  main { padding: 1.5rem 1rem 3rem; }
  header h1 { font-size: 1.5rem; }
}
