:root {
  --bg: #f6f7fb;
  --card: #fff;
  --text: #1f2330;
  --muted: #6b7180;
  --line: #e4e6ee;
  --accent: #4f46e5;
  --accent-weak: #eef0ff;
  --danger: #dc2626;
  --radius: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 500; }
code { font-family: ui-monospace, Consolas, monospace; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: rgba(255,255,255,.9); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 18px; }
.user { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.user img { width: 30px; height: 30px; border-radius: 50%; }
@media (max-width: 520px) { #userName { display: none; } }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 10px; padding: 10px 16px;
  font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #4338ca; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { background: #f1f2f7; }
.btn.danger { color: var(--danger); }
.btn.google { background: #fff; border-color: #dadce0; color: #3c4043; padding: 12px 22px; font-size: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.btn.google:hover { background: #f8f9fa; }

input, select {
  font: inherit; font-size: 15px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--text); min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent-weak); border-color: var(--accent); }

/* landing */
.landing { max-width: 760px; margin: 0 auto; padding: 56px 16px; text-align: center; }
.landing h1 { font-size: clamp(28px, 5vw, 42px); line-height: 1.3; margin: 0 0 16px; }
.accent { color: var(--accent); }
.lead { color: var(--muted); line-height: 1.7; margin-bottom: 28px; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 44px; text-align: left; }
@media (max-width: 620px) { .compare { grid-template-columns: 1fr; } }
.cmp { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.cmp.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.cmp h3 { margin: 0 0 10px; }
.cmp p { margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.flow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.flow span { background: var(--bg); border-radius: 6px; padding: 4px 8px; color: var(--text); font-weight: 600; }
.warn { margin-top: 24px; background: #fff7ed; border: 1px solid #fed7aa; padding: 12px; border-radius: 10px; }

/* dashboard */
.dashboard { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 28px; }
.panel h2 { margin: 0 0 12px; font-size: 18px; }
.create-form { display: grid; grid-template-columns: 1fr 2fr auto; gap: 10px; }
@media (max-width: 720px) { .create-form { grid-template-columns: 1fr; } }
.list-title { font-size: 18px; margin: 0 0 14px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
@media (max-width: 380px) { .grid { grid-template-columns: 1fr; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.qr-wrap { background: #fafbff; display: grid; place-items: center; padding: 18px; border-bottom: 1px solid var(--line); }
.qr canvas, .qr svg { display: block; width: 200px; height: 200px; }
.card-body { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.title-row { display: flex; align-items: center; gap: 8px; }
.title-input { flex: 1; font-weight: 700; font-size: 16px; border-color: transparent; padding: 6px 8px; margin-left: -8px; }
.title-input:hover { border-color: var(--line); }
.scans { font-size: 12px; color: var(--muted); white-space: nowrap; }
.short-row { display: flex; align-items: center; gap: 8px; }
.short { flex: 1; font-size: 12.5px; color: var(--accent); background: var(--accent-weak); padding: 6px 8px; border-radius: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.url-row { display: flex; gap: 6px; }
.url-input { flex: 1; font-size: 14px; padding: 8px 10px; }
.url-input.dirty { border-color: #f59e0b; background: #fffbeb; }
.history { display: flex; flex-direction: column; gap: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 12px; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 9px; cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

/* dialog */
dialog { border: none; border-radius: 16px; padding: 0; max-width: 560px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(15,18,30,.45); }
.dlg { padding: 20px; }
.dlg h3 { margin: 0 0 14px; }
.dlg-grid { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: start; }
@media (max-width: 520px) { .dlg-grid { grid-template-columns: 1fr; justify-items: center; } }
.preview canvas, .preview svg { display: block; width: 200px; height: 200px; }
.opts { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.opts label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.opts input[type=color] { width: 100%; height: 38px; padding: 2px; }
.opts input[type=file] { font-size: 13px; padding: 6px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* misc */
.loading { display: grid; place-items: center; min-height: 60vh; }
.spin { width: 36px; height: 36px; border: 4px solid #dde; border-top-color: var(--accent); border-radius: 50%; animation: s .8s linear infinite; }
@keyframes s { to { transform: rotate(360deg); } }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: #1f2330; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .2s; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
