:root {
  --bg: #f7f7f8;
  --panel: #ffffff;
  --line: #e4e4e7;
  --text: #18181b;
  --muted: #71717a;
  --solid: #18181b;
  --solid-text: #ffffff;
  --focus: #2563eb;
  --radius: 14px;
  --tap: 48px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f10;
    --panel: #18181b;
    --line: #2a2a2e;
    --text: #fafafa;
    --muted: #a1a1aa;
    --solid: #fafafa;
    --solid-text: #18181b;
    --focus: #60a5fa;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  padding:
    max(24px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    calc(32px + env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 440px; margin-inline: auto; }

.head { margin-bottom: 20px; }
.head h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.head p { margin: 4px 0 0; color: var(--muted); font-size: 14.5px; }

/* ------------------------------------------------------------- cards */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.input {
  width: 100%;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--mono);
  resize: none;
}
.input::placeholder { color: var(--muted); }
.input:focus { outline: none; border-color: var(--muted); }

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

.check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; cursor: pointer; }
.check input { width: 17px; height: 17px; margin: 0; accent-color: var(--solid); cursor: pointer; }
.check span { user-select: none; }

/* ------------------------------------------------------------ buttons */
.btn {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font: 500 15px/1 inherit;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--solid); border-color: var(--solid); color: var(--solid-text); }
.btn-primary:hover { opacity: .88; }
.btn:disabled { opacity: .55; cursor: default; }
/* A dimmed solid button reads as muddy; fall back to a quiet outline. */
.btn-primary:disabled {
  opacity: 1;
  background: var(--bg);
  border-color: var(--line);
  color: var(--muted);
}
.wide { width: 100%; }

.text-btn {
  padding: 4px 0; border: 0; background: none;
  color: var(--muted); font: 500 14px/1 inherit;
  text-decoration: underline; text-underline-offset: 3px;
  cursor: pointer;
}
.text-btn:hover { color: var(--text); }

.row { display: flex; gap: 8px; }
.centered { margin: 12px 0 0; text-align: center; }

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

.note { margin: 12px 0 0; font-size: 14px; color: var(--muted); }
.note.is-error { color: #b91c1c; }
@media (prefers-color-scheme: dark) { .note.is-error { color: #fca5a5; } }

/* ---------------------------------------------------------- short url */
.short-url {
  display: block; width: 100%;
  padding: 14px; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text);
  font: 600 17px/1.3 var(--mono);
  word-break: break-all; text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.short-url:hover { border-color: var(--muted); }

/* ---------------------------------------------------------------- qr */
.qr-tile {
  width: min(62vw, 230px);
  margin: 0 auto 10px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.qr-tile canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.qr-for {
  margin: 0 0 14px; text-align: center;
  color: var(--muted); font-size: 12.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ------------------------------------------------------------ recent */
.recent { margin-top: 22px; }
.recent-head { display: flex; align-items: baseline; justify-content: space-between; }
.recent-head .label { margin-bottom: 8px; }
.recent-list { list-style: none; margin: 0; padding: 0; }
.recent-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; margin-bottom: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.recent-main {
  flex: 1; min-width: 0; text-align: left;
  background: none; border: 0; padding: 0; cursor: pointer;
}
.recent-short { color: var(--text); font: 600 14px/1.3 var(--mono); word-break: break-all; }
.recent-target { margin-top: 2px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-copy {
  flex: none; min-height: 38px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text);
  font: 500 13px/1 inherit; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.recent-copy:hover { border-color: var(--muted); }

/* -------------------------------------------------------------- misc */
.foot { margin-top: 24px; }
.foot p { margin: 0; color: var(--muted); font-size: 12.5px; text-align: center; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom));
  padding: 11px 18px; border-radius: 8px;
  background: var(--solid); color: var(--solid-text);
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
  z-index: 20;
}
