/* Icons default to text size; components override */
.ic { width: 1em; height: 1em; vertical-align: -.15em; flex: none; }

/* Layout */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side {
  background: linear-gradient(180deg, #1c1712, #14100c); border-right: 1px solid var(--line);
  padding: 18px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; border-bottom: 2px solid var(--ember); margin-bottom: 8px; }
.brand .mark { width: 40px; height: 40px; border: 2px solid var(--ember); border-radius: 50%; display: grid; place-items: center; color: var(--ember); box-shadow: inset 0 0 0 3px var(--bg), inset 0 0 0 4px var(--line-2); }
.brand .mark .ic { width: 22px; height: 22px; }
.brand h1 { font-size: 1.1rem; margin: 0; line-height: 1; }
.brand small { display: block; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r); color: var(--ink-2); text-decoration: none; font-family: var(--font-head); text-transform: uppercase; letter-spacing: .06em; font-size: .95rem; border-left: 3px solid transparent; }
.nav a:hover { background: var(--bg-3); color: var(--ink); }
.nav a.active { background: var(--bg-3); color: var(--ink); border-left-color: var(--ember); }
.nav a .ic { width: 18px; height: 18px; opacity: .85; }
.nav .sep { font-size: .65rem; letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3); padding: 12px 10px 4px; }
.side .who { margin-top: auto; padding: 12px 10px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--leather); color: var(--ink); display: grid; place-items: center; font-family: var(--font-head); font-weight: 600; letter-spacing: .05em; border: 2px solid var(--line-2); flex: none; }
.avatar.mentor { background: var(--pine); }
.avatar.lg { width: 64px; height: 64px; font-size: 1.4rem; }
.main { padding: 26px 32px 60px; max-width: 1200px; width: 100%; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; border-bottom: 1px dashed var(--line-2); padding-bottom: 14px; flex-wrap: wrap; }
.topbar h1 { margin: 0; }
.topbar .sub { color: var(--ink-2); font-size: .95rem; }
.mobile-bar { display: none; }

/* Panels & cards */
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, 1fr); }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); position: relative; }
.panel > h2, .panel > h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.panel > h2 .ic, .panel > h3 .ic { width: 18px; height: 18px; color: var(--ember); }
.panel.stitch::before { content: ""; position: absolute; inset: 6px; border: 1px dashed var(--line-2); border-radius: 4px; pointer-events: none; opacity: .6; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .n { font-family: var(--font-head); font-size: 2.4rem; line-height: 1; color: var(--ink); }
.stat .l { font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }

/* Badges */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.badge-card { display: block; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; position: relative; overflow: hidden; transition: transform .12s, border-color .12s; box-shadow: var(--shadow); }
.badge-card:hover { transform: translateY(-2px); border-color: var(--line-2); }
.badge-card .emblem { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; border: 3px solid var(--tc, var(--ember)); color: var(--tc, var(--ember)); background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.08), transparent 60%), var(--bg-3); box-shadow: inset 0 0 0 3px var(--bg), inset 0 0 0 4px var(--line-2), 0 3px 0 #0b0906; margin-bottom: 10px; }
.badge-card .emblem .ic { width: 28px; height: 28px; }
.badge-card.awarded .emblem { background: var(--tc, var(--ember)); color: var(--bg); }
.badge-card.awarded::after { content: "EARNED"; position: absolute; top: 12px; right: -30px; transform: rotate(35deg); background: var(--brass); color: var(--accent-ink); font-family: var(--font-head); font-size: .7rem; letter-spacing: .15em; padding: 3px 36px; }
.badge-card h3 { font-size: 1.05rem; margin-bottom: 2px; }
.badge-card .track { font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--tc, var(--ink-3)); }
.badge-card p { font-size: .88rem; color: var(--ink-2); margin: 6px 0 8px; }
.badge-card.locked { opacity: .55; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border: 1px solid var(--line-2); border-radius: 999px; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); background: var(--bg-2); white-space: nowrap; }
.pill .ic { width: 12px; height: 12px; }
.pill.hz-high { border-color: var(--bad); color: #e08a80; }
.pill.hz-med { border-color: var(--warn); color: var(--brass); }
.pill.ok { border-color: var(--ok); color: #a9c46a; }
.pill.ember { border-color: var(--ember); color: var(--ember); }
.pill.solid { background: var(--ember); color: var(--accent-ink); border-color: var(--ember); }

.bar { height: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--rust), var(--ember)); width: var(--w, 0%); transition: width .3s; }
.bar.ok > i { background: linear-gradient(90deg, var(--pine), var(--ok)); }

/* Badge detail */
.badge-hero { display: flex; gap: 20px; align-items: flex-start; }
.badge-hero .emblem { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; border: 4px solid var(--tc, var(--ember)); color: var(--tc, var(--ember)); background: var(--bg-3); box-shadow: inset 0 0 0 4px var(--bg), inset 0 0 0 6px var(--line-2), 0 4px 0 #0b0906; flex: none; }
.badge-hero .emblem .ic { width: 48px; height: 48px; }
.badge-hero.awarded .emblem { background: var(--tc, var(--ember)); color: var(--bg); }
.req { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: start; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.req:last-child { border-bottom: 0; }
.req .box { width: 28px; height: 28px; border: 2px solid var(--line-2); border-radius: 4px; display: grid; place-items: center; color: transparent; background: var(--bg); }
.req.ready .box { border-color: var(--brass); color: var(--brass); }
.req.signed .box { border-color: var(--ok); background: var(--ok); color: var(--bg); }
.req .box .ic { width: 18px; height: 18px; }
.req .t { font-size: .97rem; }
.req .v { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin-top: 3px; }
.req .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.safety { border-left: 3px solid var(--blood); background: rgba(143,47,42,.12); padding: 12px 14px; border-radius: 0 var(--r) var(--r) 0; }
.safety h4 { color: #e08a80; }
.safety ul, .plain ul { margin: 0; padding-left: 18px; }
.safety li { margin: 4px 0; }

.evidence { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: flex-start; }
.evidence .ev { margin: 0; width: 120px; }
.evidence .ph { width: 120px; height: 90px; border: 1px solid var(--line-2); border-radius: 4px; background: var(--bg); display: grid; place-items: center; overflow: hidden; }
.evidence .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.evidence figcaption { font-size: .7rem; line-height: 1.2; margin-top: 3px; display: flex; justify-content: space-between; align-items: center; gap: 4px; }
.evidence figcaption .btn { padding: 2px 5px; }

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--bg-3); color: var(--ink); font-family: var(--font-head); text-transform: uppercase; letter-spacing: .08em; font-size: .85rem; cursor: pointer; text-decoration: none; line-height: 1; }
.btn:hover { border-color: var(--ink-3); }
.btn .ic { width: 14px; height: 14px; }
.btn.primary { background: var(--ember); border-color: var(--ember); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: var(--accent-ink); }
.btn.danger { border-color: var(--bad); color: #e08a80; }
.btn.sm { padding: 5px 9px; font-size: .75rem; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
input, select, textarea { width: 100%; background: var(--bg); color: var(--ink); border: 1px solid var(--line-2); border-radius: var(--r); padding: 9px 11px; font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ember); outline-offset: 0; border-color: var(--ember); }
label { display: block; font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--ink-2); cursor: pointer; font-size: .8rem; font-family: var(--font-head); text-transform: uppercase; letter-spacing: .08em; display: inline-flex; gap: 6px; align-items: center; }
.chip .ic { width: 13px; height: 13px; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip[data-tc].on { background: var(--tc); border-color: var(--tc); color: var(--bg); }

/* Lists */
.list { display: flex; flex-direction: column; }
.item { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.item:last-child { border-bottom: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .ttl { font-weight: 600; }
.item .sub { font-size: .85rem; color: var(--ink-2); }
.item .ic.lead { width: 22px; height: 22px; color: var(--ember); flex: none; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-family: var(--font-head); font-weight: 500; text-transform: uppercase; letter-spacing: .1em; font-size: .72rem; color: var(--ink-3); padding: 8px; border-bottom: 1px solid var(--line-2); }
td { padding: 8px; border-bottom: 1px dashed var(--line); vertical-align: middle; }
tr.me td { background: rgba(217,101,28,.08); }

/* Poll */
.opt { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.opt .bar { margin-top: 6px; }
.opt.mine .ttl { color: var(--ember); }

/* Rank ladder */
.ladder { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.rung { text-align: center; padding: 12px 6px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-2); opacity: .5; }
.rung .ic { width: 28px; height: 28px; color: var(--ink-3); }
.rung .n { font-family: var(--font-head); text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; margin-top: 4px; }
.rung.held { opacity: 1; border-color: var(--brass); }
.rung.held .ic { color: var(--brass); }
.rung.current { background: var(--brass); color: var(--accent-ink); opacity: 1; border-color: var(--brass); }
.rung.current .ic { color: var(--accent-ink); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .box { width: min(560px, 100%); }
.login .brand { border-bottom: 0; justify-content: center; }
.login .brand h1 { font-size: 2rem; }
.profiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.profile { background: var(--bg-2); border: 1px solid var(--line-2); border-radius: var(--r); padding: 12px 8px; text-align: center; cursor: pointer; color: var(--ink); }
.profile:hover, .profile.on { border-color: var(--ember); }
.profile .avatar { margin: 0 auto 6px; }
.profile .nm { font-family: var(--font-head); text-transform: uppercase; letter-spacing: .06em; font-size: .85rem; }
.profile .rl { font-size: .7rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .1em; }
.pin { font-family: var(--font-head); font-size: 1.6rem; letter-spacing: .5em; text-align: center; }

/* Notices */
.notice { padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--bg-2); font-size: .92rem; }
.notice.warn { border-color: var(--warn); }
.notice.bad { border-color: var(--bad); }
.notice.ok { border-color: var(--ok); }
.empty { padding: 28px; text-align: center; color: var(--ink-3); border: 1px dashed var(--line-2); border-radius: var(--r); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: var(--r); font-family: var(--font-head); text-transform: uppercase; letter-spacing: .08em; z-index: 50; box-shadow: var(--shadow); }
.kbd { font-size: .8rem; color: var(--ink-3); }
.ann { border-left: 3px solid var(--brass); padding-left: 12px; margin-bottom: 14px; }
.ann.pinned { border-left-color: var(--ember); }
.ann .h { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.ann .h b { font-family: var(--font-head); text-transform: uppercase; letter-spacing: .06em; }

/* Print badge cards */
@media print {
  .side, .topbar .actions, .btn, .mobile-bar { display: none !important; }
  .app { grid-template-columns: 1fr; }
  body { background: #fff; color: #000; }
  .panel, .badge-card { box-shadow: none; border-color: #999; break-inside: avoid; }
}

/* Responsive */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .2s; z-index: 40; }
  .side.open { transform: none; box-shadow: 0 0 0 100vw rgba(0,0,0,.5); }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--bg-2); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
  .main { padding: 16px 16px 80px; }
  .grid.c2, .grid.c3 { grid-template-columns: 1fr; }
  .grid.c4 { grid-template-columns: 1fr 1fr; }
  .grid[style*='grid-template-columns'] { grid-template-columns: 1fr !important; }
  .ladder { grid-template-columns: repeat(3, 1fr); }
  .req { grid-template-columns: 30px 1fr; }
  .req .actions { grid-column: 2; justify-content: flex-start; }
  .badge-hero { flex-direction: column; }
}
