:root {
  --ink: #0a1128;
  --gold: #b8923a;
  --cream: #f4f0e6;
  --paper: #f7f4ec;
  --card: #ffffff;
  --line: #ddd6c6;
  --muted: #4a5160;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; overflow-x: hidden; }
body {
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-size: 16px;
  line-height: 1.45;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button, input, select, textarea { font-family: inherit; }

.pub { background: var(--cream); color: var(--ink); }
.pub-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: #fff; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--ink); }
.brand span { font-size: 18px; }
.brand em { font-style: italic; color: var(--gold); }
.brand-dark { color: #f4f0e6; }
.rail-logo { height: 22px; width: auto; max-width: 48px; object-fit: contain; }
.pub-nav { display: flex; align-items: center; gap: 18px; font-size: 14px; color: var(--ink); }
.btn-gold, .btn-ink, button.btn-ink, button.btn-gold {
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; cursor: pointer; font-size: 14px; font-weight: 600;
  padding: 12px 18px; min-height: 44px;
}
.btn-gold { background: var(--gold); color: #1a1408; }
.btn-ink { background: var(--ink); color: #f4f0e6; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); padding: 10px 14px; min-height: 44px; }
.pub-main { max-width: 1080px; margin: 0 auto; padding: 40px 20px 72px; }
.pub-foot { padding: 20px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); background: #fff; }
.hero h1 { font-size: clamp(32px, 6vw, 52px); font-weight: 600; line-height: 1.1; color: var(--ink); }
.hero p { margin-top: 12px; color: var(--muted); max-width: 46ch; }
.hero { margin-bottom: 36px; }
.plans { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.plan {
  background: var(--card); border: 1px solid var(--line); padding: 24px;
  display: flex; flex-direction: column; gap: 10px; color: var(--ink);
}
.plan.featured { background: var(--ink); color: #f4f0e6; }
.plan.featured p, .plan.featured li { color: #d9d3c4; }
.plan .tag { font-size: 12px; font-weight: 600; color: var(--gold); }
.plan h2 { font-size: 26px; font-weight: 600; }
.plan ul { list-style: none; font-size: 14px; flex: 1; }
.plan ul li { padding: 6px 0; border-top: 1px solid var(--line); }
.plan.featured ul li { border-color: rgba(244,240,230,.15); }
.form { max-width: 440px; margin: 0 auto; background: var(--card); padding: 28px; border: 1px solid var(--line); }
.form h1 { font-size: 28px; margin-bottom: 6px; color: var(--ink); }
.form .lede { color: var(--muted); margin-bottom: 20px; }
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 6px; color: var(--ink); }
input, select, textarea {
  width: 100%; padding: 12px; border: 1px solid var(--line);
  background: #fff; font-size: 16px; color: var(--ink); border-radius: 0;
}
textarea { min-height: 96px; resize: vertical; }
.err { background: #f4e4de; color: #5c2418; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.ok { background: #e4eee6; color: #1c3d28; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 12px; }
.kicker { font-size: 12px; font-weight: 600; color: #8a6a24; margin-bottom: 2px; }

.app { background: var(--ink); }
.app-shell { display: flex; min-height: 100vh; }
.rail {
  width: 76px; padding: 20px 10px; color: #f4f0e6;
  border-right: 1px solid rgba(244,240,230,.12);
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}
.rail-plan { font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); writing-mode: vertical-rl; transform: rotate(180deg); margin-top: auto; padding-bottom: 16px; }
.rail-nav { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.rail-nav a {
  position: relative; display: flex; align-items: center; justify-content: center;
  height: 48px; color: rgba(244,240,230,.45);
}
.rail-nav a.on { color: var(--gold); }
.rail-nav .dot {
  position: absolute; top: 8px; right: 14px; width: 7px; height: 7px;
  background: #e24a3b; border-radius: 50%;
}
.app-body { flex: 1; background: var(--paper); color: var(--ink); min-width: 0; display: flex; flex-direction: column; }
.app-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.app-head h1 { font-size: 17px; font-weight: 600; color: var(--ink); }
.app-main { padding: 16px 16px 96px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat {
  background: var(--card); border: 1px solid var(--line); padding: 14px;
}
.stat b { display: block; font-size: 22px; font-weight: 700; color: var(--ink); }
.stat span { font-size: 12px; color: var(--muted); }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.quick a {
  background: var(--ink); color: #f4f0e6; padding: 14px; font-size: 14px; font-weight: 600; min-height: 48px;
  display: flex; align-items: center;
}
.quick a.alt { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.feed { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); padding: 16px; color: var(--ink); }
.card .kind { font-size: 12px; font-weight: 600; color: #8a6a24; margin-bottom: 4px; }
.card h2 { font-size: 17px; font-weight: 600; margin-bottom: 4px; color: var(--ink); }
.card p { color: var(--muted); font-size: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  background: var(--card); border: 1px solid var(--line); padding: 16px;
  min-height: 120px; display: flex; flex-direction: column; gap: 6px; color: var(--ink);
}
.tile h3 { font-size: 16px; font-weight: 600; }
.tile p { color: var(--muted); font-size: 13px; flex: 1; }
.tile.locked { background: #efe9dc; }
.lock { font-size: 11px; font-weight: 600; color: #8a6a24; }
.back { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 600; margin-bottom: 12px; color: var(--ink); }
.row-actions {
  display: flex; gap: 12px; margin-top: 18px; flex-wrap: wrap; align-items: center;
}
.card p + .row-actions, .card h2 + .row-actions { margin-top: 18px; }
.btn-ink, .btn-ghost, a.btn-ink, a.btn-ghost {
  padding: 12px 16px;
}
.tabbar {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  justify-content: space-between;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 0 0 var(--safe-b);
  overflow: hidden;
}
.tabbar a {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 0%;
  min-width: 0;
  max-width: none;
  width: auto;
  height: 52px;
  padding: 0;
  margin: 0;
  color: #5c6370;
  flex-shrink: 1;
}
.tabbar a.on { color: var(--ink); }
.tabbar svg { width: 20px; height: 20px; display: block; flex-shrink: 0; }
.tabbar .dot {
  position: absolute;
  top: 8px;
  left: 50%;
  margin-left: 8px;
  width: 7px;
  height: 7px;
  background: #e24a3b;
  border-radius: 50%;
}
.chip { display: inline-block; background: #0a1128; color: #f4f0e6; font-size: 11px; font-weight: 600; padding: 4px 8px; margin-right: 6px; }
.progress { height: 8px; background: #eee7d8; margin: 12px 0 4px; }
.progress > i { display: block; height: 8px; background: var(--gold); max-width: 100%; }

@media (max-width: 860px) {
  .plans, .grid-2 { grid-template-columns: 1fr; }
  .rail { display: none; }
  .tabbar { display: flex !important; flex-wrap: nowrap !important; }
  html, body.app { overflow-x: hidden; }
  .pub-nav a:not(.btn-gold) { display: none; }
}
@media (min-width: 861px) {
  .tabbar { display: none !important; }
  .app-main { padding: 24px 28px 40px; }
  .stats { grid-template-columns: repeat(4, 1fr); }
}
