/* qrme — public pages (home, link page, messages) */
:root {
  color-scheme: light;
  --bg: #f5f5f1;
  --surface: #ffffff;
  --surface-2: #efeee9;
  --ink: #121212;
  --ink-2: #4c4b47;
  --muted: #7c7b75;
  --line: #e3e2db;
  --accent: #5b4cf0;
  --accent-ink: #ffffff;
  --accent-soft: #ecebfe;
  --good: #0a7d32;
  --bad: #c42b2b;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 28px rgba(20,20,40,.07);
  --radius: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f0f12;
    --surface: #18181c;
    --surface-2: #222227;
    --ink: #f2f2ef;
    --ink-2: #c9c8c1;
    --muted: #8e8d87;
    --line: #2c2c31;
    --accent: #8579ff;
    --accent-ink: #0f0f12;
    --accent-soft: #24223f;
    --good: #3fcf6e;
    --bad: #ff6b6b;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font);
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* ---------- header / footer */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 1080px; width: 100%; margin: 0 auto; padding: 18px 16px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; font-size: 1.35rem; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand img { width: 32px; height: 32px; }
.top nav a { color: var(--ink-2); font-weight: 600; font-size: .95rem; }
main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px 48px; }
footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px 16px 32px; }
footer a { color: var(--ink-2); }

/* ---------- buttons & inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: 600 .92rem/1.2 var(--font); cursor: pointer;
  white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 16px; height: 16px; flex: none; }
.link-btn { background: none; border: 0; padding: 4px; color: var(--muted); font: inherit; font-size: .875rem; cursor: pointer; }
.link-btn:hover { color: var(--ink); text-decoration: underline; }
input[type=text], input[type=search], input[type=url] {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 12px; min-height: 40px; width: 100%;
}
input:focus-visible, .btn:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px;
}

/* ---------- hero & paste box */
.hero { text-align: center; padding: 28px 0 8px; }
.hero h1 { font-size: clamp(2rem, 6vw, 3.3rem); font-weight: 800; letter-spacing: -.035em; }
.hero h1 .arrow { color: var(--accent); }
.sub { color: var(--ink-2); font-size: 1.08rem; max-width: 600px; margin: 12px auto 26px; }
.sub b { font-family: var(--mono); font-weight: 600; font-size: .95em; color: var(--ink); }
.paste {
  display: flex; gap: 8px; max-width: 720px; margin: 0 auto; padding: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
}
.paste:focus-within { border-color: var(--accent); }
.paste input { border: 0; background: transparent; font-size: 1.12rem; min-height: 52px; padding: 0 12px; }
.paste input:focus-visible { outline: none; }
.paste .btn { min-height: 52px; padding: 0 22px; font-size: 1.02rem; border-radius: 12px; }
.hint { color: var(--muted); font-size: .88rem; margin: 12px 0 0; }
.hint kbd { font: 600 .8rem var(--mono); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; background: var(--surface); }
.err { color: var(--bad); font-weight: 600; margin: 12px auto 0; max-width: 720px; }

/* ---------- result */
.result {
  display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 28px; align-items: start;
  max-width: 860px; margin: 28px auto 0; padding: 24px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow);
  animation: rise .25s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.qr-frame {
  background: #fff; border-radius: 14px; border: 1px solid var(--line); aspect-ratio: 1; display: grid; place-items: center; overflow: hidden;
}
.qr-frame img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; margin-top: 12px; }
.seg button {
  flex: 1; border: 0; background: transparent; color: var(--ink-2); font: 600 .82rem var(--font);
  padding: 7px 6px; border-radius: 8px; cursor: pointer;
}
.seg button[aria-pressed=true] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg-help { font-size: .78rem; color: var(--muted); margin: 6px 2px 0; }
.swatches { display: flex; gap: 8px; margin-top: 12px; justify-content: center; }
.swatches button {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line);
  cursor: pointer; padding: 0;
}
.swatches button[aria-pressed=true] { box-shadow: 0 0 0 2px var(--ink); }
.code-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pill {
  display: inline-block; font: 700 .85rem var(--mono); background: var(--accent-soft); color: var(--accent);
  padding: 4px 10px; border-radius: 999px;
}
.badge { font-size: .75rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.badge.good { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.short {
  display: block; margin: 10px 0 2px; font: 800 clamp(1.4rem, 4.2vw, 2.1rem)/1.15 var(--font); letter-spacing: -.02em;
  color: var(--ink); word-break: break-all;
}
.short:hover { color: var(--accent); text-decoration: none; }
.dest { color: var(--muted); margin: 6px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.dest a { color: var(--ink-2); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.store { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.store h3 { font-size: 1rem; }
.store p { margin: 4px 0 10px; }
.store-row { display: flex; gap: 8px; }
.store-row input { flex: 1; }
.store-msg { margin: 8px 0 0; font-size: .9rem; font-weight: 600; }
.store-msg.good { color: var(--good); }

/* ---------- sections */
.sec { max-width: 1080px; margin: 44px auto 0; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.sec-head h2 { font-size: 1.3rem; letter-spacing: -.01em; }
.sec-head h2 small { font-weight: 500; color: var(--muted); font-size: .9rem; margin-left: 6px; }
.sec-head input { max-width: 260px; }
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; max-width: 260px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px;
  font: inherit; color: var(--ink); cursor: pointer;
}
.chips li button:hover { border-color: var(--accent); }
.chips .c1 { font: 700 .88rem var(--mono); }
.chips .c2 { font-size: .78rem; color: var(--muted); max-width: 236px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.card {
  display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; min-width: 0;
}
.card .mini { flex: none; width: 76px; height: 76px; border-radius: 8px; background: #fff; border: 1px solid var(--line); overflow: hidden; display: block; }
.card .mini img { width: 100%; height: 100%; display: block; }
.card .body { min-width: 0; flex: 1; }
.card .t { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); display: block; }
.card .s { font: 600 .86rem var(--mono); color: var(--accent); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .m { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .copy { flex: none; }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 16px; height: 16px; }
.more-row { text-align: center; margin-top: 16px; }
.empty { color: var(--muted); text-align: center; padding: 28px 12px; border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: .92rem;
  transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- link page */
.lp { max-width: 560px; margin: 8px auto 0; text-align: center; }
.lp .qr-frame { max-width: 380px; margin: 0 auto; box-shadow: var(--shadow); }
.lp .short { margin-top: 20px; }
.lp .label { font-size: 1.15rem; font-weight: 700; margin: 0 0 14px; }
.lp .dest { white-space: normal; word-break: break-all; }
.lp .actions { justify-content: center; }
.lp .go { min-height: 48px; padding: 0 26px; font-size: 1.02rem; margin-top: 18px; }

/* ---------- message pages (404 etc.) */
body.msg { align-items: center; justify-content: center; padding: 24px 16px; }
.msg-card { text-align: center; max-width: 440px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 32px 24px; box-shadow: var(--shadow); }
.msg-card h1 { font-size: 1.6rem; margin: 18px 0 8px; }
.msg-card p { color: var(--ink-2); margin: 0 0 22px; word-break: break-word; }

/* ---------- small screens */
@media (max-width: 720px) {
  .result { grid-template-columns: 1fr; padding: 16px; gap: 18px; margin-top: 20px; }
  .qr-col { max-width: 320px; width: 100%; margin: 0 auto; }
  .paste { flex-direction: column; padding: 6px; }
  .paste input { min-height: 48px; text-align: center; }
  .paste .btn { width: 100%; }
  .actions .btn { flex: 1 1 auto; }
  .store-row { flex-direction: column; }
  .sec-head input { max-width: none; }
  .cards { grid-template-columns: 1fr; }
  .hero { padding-top: 12px; }
}
