:root {
  --bg: #FFF7EC; --ink: #17131F; --muted: #7A7286; --soft: #4A4356; --line: #D9D1C4;
  --coral: #FF5A36; --sun: #FFC83D; --mint: #DDF7EF; --ok: #127A5C; --bad: #C0322B; --card: #FFFFFF;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 'Bricolage Grotesque', system-ui, sans-serif; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--coral); outline-offset: 2px; }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
[hidden] { display: none !important; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 16px 28px; border-bottom: 2px solid var(--ink); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-size: 22px; font-weight: 800; margin-right: auto; }
.logo { display: block; width: 40px; height: 40px; object-fit: contain; }
.who { color: var(--muted); font-size: 14px; }
.banner { margin: 0; padding: 10px 28px; background: var(--sun); font-size: 15px; font-weight: 700; }

.btn, .btn-ghost, .btn-danger { min-height: 44px; padding: 0 20px; border-radius: 999px; border: 2px solid var(--ink); cursor: pointer; font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn { background: var(--ink); color: var(--bg); box-shadow: 0 3px 0 var(--coral); }
.btn:hover { transform: translateY(-1px); }
.btn-ghost { background: var(--card); }
.btn-ghost:hover { background: #FFF1DE; }
.btn-danger { background: transparent; border-color: var(--bad); color: var(--bad); align-self: flex-start; }
.card { background: var(--card); border: 2px solid var(--ink); border-radius: 24px; padding: 20px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.msg { margin: 0; min-height: 22px; font-weight: 700; font-size: 14px; }
.msg.ok { color: var(--ok); }
.msg.bad { color: var(--bad); }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; }
input { height: 48px; padding: 0 14px; border-radius: 12px; border: 2px solid var(--line); background: #FFFBF4; font-weight: 500; }
input[aria-invalid="true"] { border-color: var(--bad); }

.auth { display: grid; place-items: center; padding: 64px 16px; }
.auth-card { width: min(420px, 100%); display: flex; flex-direction: column; gap: 16px; }
.auth-card h1 { margin: 0; font-size: 28px; }

.app { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; padding: 24px 28px; }
.list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.list-head h1 { margin: 0; font-size: 26px; }
.code-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.code-list button { width: 100%; display: grid; grid-template-columns: 56px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 12px; align-items: center; text-align: left; padding: 10px 12px; border-radius: 18px; border: 2px solid #E7DFD2; background: var(--bg); cursor: pointer; }
.code-list .thumb { grid-row: 1 / span 2; display: block; border-radius: 8px; border: 1px solid #E7DFD2; }
.view-toggle { display: flex; gap: 6px; margin: 0 0 12px; padding: 4px; border-radius: 999px; background: #F1EADF; }
.view-toggle button { flex: 1; min-height: 38px; border: 0; border-radius: 999px; background: transparent; font-weight: 700; cursor: pointer; }
.view-toggle button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.gallery h2 { margin: 0 0 16px; font-size: 30px; letter-spacing: -0.02em; }
.gallery-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; }
.gallery-grid button { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px; border-radius: 22px; border: 2px solid var(--ink); background: var(--card); cursor: pointer; text-align: center; }
.gallery-grid button:hover { transform: translateY(-3px); }
.gallery-grid svg { width: 100%; height: auto; max-width: 180px; }
.gallery-grid .name { font-size: 18px; font-weight: 800; }
.gallery-grid .dest { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--muted); word-break: break-all; }
.code-list button[aria-current="true"] { border-color: var(--ink); background: var(--card); }
.code-list .name { font-size: 18px; font-weight: 700; }
.code-list .dest { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--soft); }

.detail { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.detail-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.detail-head h2 { margin: 0; font-size: 30px; letter-spacing: -0.02em; }
.live { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border-radius: 999px; background: var(--mint); font-size: 14px; font-weight: 700; }
.live span { width: 8px; height: 8px; border-radius: 50%; background: #18A57E; }
.stats { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.stats div { display: flex; flex-direction: column; align-items: flex-end; }
.stats strong { font-size: 22px; }
.stats span { font-size: 12px; color: var(--muted); }
#spark { width: 120px; height: 36px; }

.panels { display: grid; grid-template-columns: minmax(300px, 380px) 64px minmax(260px, 1fr); align-items: stretch; }
.code-card, .phone-card { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.card-head { align-self: stretch; display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
.eyebrow { align-self: stretch; font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; color: var(--muted); }
.plate { padding: 28px; border-radius: 18px; background: #F3F7FC; overflow: hidden; }
.qr { position: relative; }
.cell { position: absolute; background: var(--ink); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
#styles button { min-height: 40px; padding: 0 16px; border-radius: 999px; border: 2px solid var(--ink); background: var(--card); font-weight: 700; cursor: pointer; }
#styles button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.flow { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font: 700 11px 'JetBrains Mono', monospace; color: var(--muted); }
.flow svg { width: 64px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.flow .dash { stroke-dasharray: 6 4; animation: dash 0.8s linear infinite; }
.phone-card { background: #FFEFD6; }
.phone { width: 250px; height: 470px; padding: 9px; border-radius: 38px; background: var(--ink); box-shadow: 0 18px 40px rgba(23, 19, 31, 0.25); }
.screen { height: 100%; border-radius: 30px; background: var(--card); overflow: hidden; display: flex; flex-direction: column; }
.clock { text-align: center; font-size: 11px; font-weight: 700; padding: 6px 0; }
.addr { margin: 0 10px; padding: 7px 12px; border-radius: 999px; background: #F1EDE6; font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 20px; text-align: center; animation: swap 0.45s ease both; }
.initial { display: grid; place-items: center; width: 68px; height: 68px; border-radius: 18px; background: var(--ink); color: var(--bg); font-size: 32px; font-weight: 800; }
.host { margin: 0; font-size: 19px; font-weight: 800; word-break: break-all; }
.path { margin: 0; font-size: 11px; color: var(--muted); word-break: break-all; }
.note { margin: 0; font-size: 12px; color: var(--muted); }

.dest-card { display: flex; flex-direction: column; gap: 12px; }
.dest-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.dest-head label { font-size: 17px; font-weight: 800; }
.dest-head span { font-size: 14px; color: var(--soft); }
#dest-input { flex: 1; min-width: 240px; }
.history h3 { margin: 6px 0; font-size: 15px; }
.history ul { margin: 0; padding-left: 18px; font-size: 14px; color: var(--soft); }
.history .mono { font-size: 13px; color: var(--ink); }

dialog { border: 2px solid var(--ink); border-radius: 24px; padding: 24px; width: min(460px, calc(100% - 32px)); background: var(--card); }
dialog::backdrop { background: rgba(23, 19, 31, 0.45); }
dialog form { display: flex; flex-direction: column; gap: 14px; }
dialog h2 { margin: 0; }

@keyframes pop { 0% { transform: scale(0); opacity: 0 } 6% { transform: scale(1.3); opacity: 1 } 9% { transform: scale(1) } 78% { transform: scale(1); opacity: 1 } 84% { transform: scale(1.25) rotate(20deg); opacity: 1 } 90%, 100% { transform: scale(0) rotate(45deg); opacity: 0 } }
@keyframes rain { 0% { transform: translateY(-420px); opacity: 0; background: #BFE6FF; box-shadow: 0 0 10px #5DB8FF } 1% { opacity: 1 } 8% { transform: translateY(0) scale(1.3, .7); background: #BFE6FF; box-shadow: 0 0 12px #5DB8FF } 11% { transform: none } 30% { background: var(--ink); box-shadow: none } 78% { transform: none; opacity: 1; background: var(--ink) } 86% { transform: translateY(-34px) scale(.4); opacity: 0; background: #BFE6FF } 100% { opacity: 0; transform: translateY(-420px) } }
@keyframes ripple { 0%, 100% { transform: scale(1) } 5% { transform: scale(.45); background: #7A5CFF } 12% { transform: scale(1); background: var(--ink) } }
@keyframes swap { from { opacity: 0; transform: translateY(14px) } to { opacity: 1; transform: none } }
@keyframes dash { to { stroke-dashoffset: -20 } }
@media (prefers-reduced-motion: reduce) { .cell, .page, .flow .dash { animation: none !important; } }

@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; }
  .panels { grid-template-columns: 1fr; gap: 16px; }
  .flow { flex-direction: row; }
  .flow svg { transform: rotate(90deg); }
}
@media (max-width: 600px) {
  .topbar, .banner { padding-left: 16px; padding-right: 16px; }
  .app { padding: 16px; }
  .stats { margin-left: 0; }
}

/* Billing: plan badge in the top bar, and the motion line on each code. */
.plan-badge { padding: 4px 12px; border-radius: 999px; border: 2px solid var(--ink); font-size: 13px; font-weight: 800; letter-spacing: 0.04em; background: var(--card); }
.plan-badge.pro { background: var(--sun); }
.motion { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border-radius: 16px; border: 2px dashed var(--ink); font-size: 15px; }
.motion.paid { border-style: solid; background: #FFF1DE; }
.motion .btn { min-height: 38px; padding: 0 16px; }
