:root {
  --bg: #faf8f5; --panel: #ffffff; --sunk: #f3f0eb; --line: #e6e1d9; --text: #1f1d1a; --dim: #6b655c;
  --accent: #c2410c; --accent-ink: #fff; --accent-soft: #fdeee6; --ok: #15803d; --bad: #b91c1c;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141312; --panel: #1c1b19; --sunk: #232120; --line: #34312d; --text: #ecebe8; --dim: #a29c93;
    --accent: #f97316; --accent-ink: #1a0f08; --accent-soft: #3a2116; --ok: #4ade80; --bad: #f87171;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141312; --panel: #1c1b19; --sunk: #232120; --line: #34312d; --text: #ecebe8; --dim: #a29c93;
  --accent: #f97316; --accent-ink: #1a0f08; --accent-soft: #3a2116; --ok: #4ade80; --bad: #f87171;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
code, pre, textarea.code { font-family: var(--mono); font-size: 13px; }
code { background: var(--sunk); padding: .1em .35em; border-radius: 5px; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }
.dim { color: var(--dim); }
.small { font-size: 13px; }
.boot { padding: 4rem; text-align: center; color: var(--dim); }

button, .btn {
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: .5rem .9rem; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap;
}
button:hover, .btn:hover { border-color: var(--dim); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { color: var(--bad); }
button.ghost { background: none; border-color: transparent; }
button:disabled { opacity: .5; cursor: default; }
input, textarea, select {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .7rem; width: 100%;
}
input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-weight: 600; font-size: 13px; margin: .8rem 0 .3rem; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; font-size: 14px; }
label.check input { width: auto; }
.err { color: var(--bad); font-size: 14px; min-height: 1.2em; margin-top: .5rem; }

/* sign in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 380px; }
.logo { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.logo svg { width: 28px; height: 28px; flex: none; }
.auth-card .logo { font-size: 1.4rem; margin-bottom: .4rem; }
.auth-card .pitch { color: var(--dim); margin: 0 0 1.4rem; }
.auth-card form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; }
.auth-card form button { width: 100%; justify-content: center; margin-top: 1rem; }
.switch { text-align: center; margin-top: 1rem; font-size: 14px; }
.switch button { padding: 0; border: 0; background: none; color: var(--accent); font-weight: 600; }
.features { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem .8rem; margin-top: 1.4rem; font-size: 13px; color: var(--dim); }
.features span::before { content: "✓ "; color: var(--accent); font-weight: 700; }

/* shell */
.top { display: flex; align-items: center; gap: 1rem; padding: .7rem 1.2rem; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.top .crumbs { display: flex; align-items: center; gap: .5rem; min-width: 0; flex: 1; }
.top .crumbs a { color: var(--text); text-decoration: none; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.top .who { color: var(--dim); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 1.6rem 1.2rem 4rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; }
a.card { color: inherit; text-decoration: none; display: block; }
a.card:hover { border-color: var(--accent); }
.card .url { font-size: 13px; color: var(--dim); word-break: break-all; margin-top: .3rem; }
.new-card form { display: flex; gap: .5rem; margin-top: .6rem; }

.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--line); margin-bottom: 1.4rem; overflow-x: auto; }
.tabs a { padding: .6rem .9rem; color: var(--dim); text-decoration: none; font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--text); border-color: var(--accent); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.tile .n { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile .l { color: var(--dim); font-size: 13px; }
.bar { height: 6px; background: var(--sunk); border-radius: 3px; overflow: hidden; margin-top: .5rem; }
.bar i { display: block; height: 100%; background: var(--accent); }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row > input { flex: 1; min-width: 160px; }
pre.snippet { background: var(--sunk); border: 1px solid var(--line); border-radius: 8px; padding: .9rem; overflow-x: auto; margin: .6rem 0 0; }

/* database */
.db { display: grid; grid-template-columns: 200px 260px 1fr; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); min-height: 520px; overflow: hidden; }
.db > div { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.db > div:last-child { border-right: 0; }
.db .head { padding: .6rem .8rem; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-height: 46px; }
.db .list { overflow-y: auto; flex: 1; max-height: 640px; }
.db .item { display: block; width: 100%; text-align: left; border: 0; border-radius: 0; background: none; padding: .45rem .8rem; font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.db .item:hover { background: var(--sunk); }
.db .item.on { background: var(--accent-soft); color: var(--accent); }
.db .item .c { float: right; color: var(--dim); font-size: 12px; }
.db .editor { padding: .8rem; display: flex; flex-direction: column; gap: .6rem; flex: 1; }
.db textarea.code { flex: 1; min-height: 360px; resize: vertical; }
.db .empty { padding: 1rem .8rem; color: var(--dim); font-size: 14px; }
.db .head input { padding: .3rem .5rem; font-size: 13px; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: 14px; }
th, td { text-align: left; padding: .55rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--dim); font-weight: 600; background: var(--sunk); }
tr:last-child td { border-bottom: 0; }
td.mono { font-family: var(--mono); font-size: 12px; color: var(--dim); }
.table-wrap { overflow-x: auto; }

.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 2rem 1rem; text-align: center; color: var(--dim); background: var(--panel); }
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.log { font-family: var(--mono); font-size: 12px; background: var(--sunk); border-radius: 8px; padding: .7rem; max-height: 220px; overflow-y: auto; white-space: pre-wrap; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: .1rem .45rem; border-radius: 99px; background: var(--sunk); color: var(--dim); }
.badge.live { background: var(--accent-soft); color: var(--accent); }

#toasts { position: fixed; bottom: 1rem; right: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 50; max-width: calc(100vw - 2rem); }
.toast { background: var(--text); color: var(--bg); padding: .6rem .9rem; border-radius: 8px; font-size: 14px; box-shadow: 0 4px 16px #0003; }
.toast.bad { background: var(--bad); color: #fff; }

.topnav { display: flex; gap: 1rem; }
.topnav a { color: var(--dim); text-decoration: none; font-weight: 600; font-size: 14px; }
.topnav a:hover { color: var(--text); }
button.big, .btn.big { padding: .8rem 1.3rem; font-size: 15px; }
.btn.small-btn { padding: .35rem .75rem; font-size: 13px; }
.badge.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }

.welcome { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; margin: .5rem 0 1.4rem; }
.welcome .hello { margin: 0 0 .2rem; color: var(--accent); font-weight: 700; }
.welcome h1 { font-size: 2rem; letter-spacing: -.02em; }
.welcome p.dim { margin: .4rem 0 0; max-width: 34rem; }
.quota { min-width: 170px; text-align: right; }
.quota .n { font-size: 1.8rem; font-weight: 800; line-height: 1; } .quota .n span { color: var(--dim); font-size: 1.1rem; }
.quota .bar { margin: .5rem 0 .3rem; }

.create { display: grid; grid-template-columns: 1fr auto; gap: .4rem 1.5rem; align-items: center; padding: 1.4rem;
  background: radial-gradient(ellipse 60% 120% at 100% 0%, var(--accent-soft), transparent 70%), var(--panel); }
.create h2 { font-size: 1.25rem; }
.create p { margin: .25rem 0 0; }
.create-form { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.urlbox { display: flex; align-items: center; margin: 0; padding: 0 .9rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font: 600 15px/1 var(--mono); cursor: text; }
.urlbox:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.urlbox input { border: 0; outline: 0; background: none; padding: .8rem .1rem; width: 9.5rem; font: inherit; color: var(--accent); text-align: right; }
.urlbox input:focus { outline: 0; }
.create .hint { grid-column: 1 / -1; font-size: 13px; color: var(--dim); min-height: 1.2em; }
.create .hint.ok { color: var(--ok); font-weight: 600; } .create .hint.bad { color: var(--bad); }

.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 2rem 0 .8rem; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.pcard { position: relative; display: flex; flex-direction: column; gap: 1rem; transition: border-color .15s, transform .15s; }
.pcard:hover { border-color: var(--accent); transform: translateY(-2px); }
.pcard .stretch { position: absolute; inset: 0; border-radius: inherit; }
.pcard .btn { position: relative; z-index: 1; }
.ptop { display: flex; align-items: center; gap: .8rem; }
.ptile { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; color: #fff; font-weight: 900; font-size: 1.3rem;
  background: linear-gradient(135deg, hsl(var(--h) 75% 55%), hsl(calc(var(--h) + 40) 80% 40%)); }
.pname { flex: 1; min-width: 0; } .pname h3 { font-size: 1.05rem; } .pname .url { font: 12.5px var(--mono); color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; background: var(--sunk); border-radius: 10px; padding: .6rem .8rem; }
.pstats b { display: block; font-size: 1.05rem; font-variant-numeric: tabular-nums; } .pstats span { font-size: 12px; color: var(--dim); }
.pfoot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }

.empty-state { padding: 1.6rem; grid-column: 1 / -1; } .empty-state h3 { font-size: 1.15rem; margin-bottom: 1rem; }
.steps { list-style: none; counter-reset: s; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.steps li { counter-increment: s; display: flex; flex-direction: column; gap: .3rem; font-size: 14px; color: var(--dim); }
.steps li::before { content: counter(s); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-weight: 800; margin-bottom: .3rem; }
.steps li b { color: var(--text); font-size: 15px; }

.resources { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-top: 2.2rem; }
a.card.res { display: flex; flex-direction: column; gap: .3rem; color: inherit; text-decoration: none; }
.res:hover { border-color: var(--accent); }
.res .ri { font-size: 1.4rem; }

@media (max-width: 860px) {
  .create { grid-template-columns: 1fr; }
  .steps, .resources { grid-template-columns: 1fr 1fr; }
  .topnav { display: none; }
}
@media (max-width: 520px) {
  .steps, .resources { grid-template-columns: 1fr; }
  .create-form { width: 100%; } .urlbox { width: 100%; } .urlbox input { flex: 1; width: 0; } .create-form button { width: 100%; justify-content: center; }
  .quota { text-align: left; }
  .top { gap: .5rem; padding: .6rem 16px; }
  .top .logo span, .urlbox .dim:first-child { display: none; }
  .top .btn, .top button { padding: .4rem .7rem; }
}

footer { text-align: center; color: var(--dim); font-size: 13px; padding: 2rem 1rem; }

@media (max-width: 860px) {
  .db { grid-template-columns: 1fr; }
  .db > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .db .list { max-height: 220px; }
  .top .who { display: none; }
}
