/* ============ DM Tavern — table tools (inventory, dice, NPCs, quests, handouts, calendar, session zero, encounters, factions) ============
   Written in the flat "refine" style: plain surfaces, sentence case, prose font only for story text. */

.small { font-size: 13px; } .tiny { font-size: 12px; }
a.plain { color: inherit; text-decoration: none; } a.plain:hover { text-decoration: underline; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.inline-form .input { flex: 1; min-width: 140px; }
.inline-form .input.qty { flex: 0 0 80px; min-width: 0; }
.tier-mark { font-size: 10.5px; font-weight: 600; color: var(--gold); border: 1px solid rgba(201,164,92,.4); border-radius: 99px; padding: 0 6px; line-height: 16px; }
.select.slim { padding: 4px 26px 4px 8px; font-size: 13px; max-width: 170px; }
.color-in { height: 42px; padding: 4px; cursor: pointer; }
.game-stamp { color: #8d2a1e; font-weight: 600; }

/* generic data table */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--dim); padding: 0 10px 8px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.t-name { font-weight: 500; }
.t-name a { color: var(--ink); text-decoration: none; } .t-name a:hover { color: var(--gold-2); }
.ext-mark { font-size: 11px; color: var(--gold); margin-left: 4px; }
.t-note { color: var(--muted); font-size: 13.5px; }
.t-ctrl { text-align: right; white-space: nowrap; }
.t-qty { white-space: nowrap; }
.t-qty b { display: inline-block; min-width: 26px; text-align: center; }
.qty-btn { width: 24px; height: 24px; border-radius: 4px; border: 1px solid var(--border-2); background: var(--surface-3); color: var(--ink); cursor: pointer; line-height: 1; }
.qty-btn:hover { border-color: var(--gold); }
@media (max-width: 700px) { .table.inv th:nth-child(4), .table.inv td:nth-child(4) { display: none; } }

/* coins */
.coins { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 10px; }
.coin { text-align: center; padding: 10px 4px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); }
.coin b { display: block; font-size: 17px; font-weight: 600; }
.coin span { font-size: 11.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; }
.coin.pp b { color: #d9dde6; } .coin.gp b { color: #e3c88f; } .coin.ep b { color: #c9d1b0; } .coin.sp b { color: #b9bec6; } .coin.cp b { color: #d29a6c; }
.coin-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.ledger-list { list-style: none; margin: 0; padding: 0; }
.ledger-list li { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13.5px; }
.ledger-list li:first-child { border-top: 0; }
.ledger-list .amt { font-weight: 600; white-space: nowrap; }
.ledger-list .amt.pos { color: var(--ok); } .ledger-list .amt.neg { color: var(--no); }
.ledger-list .lwho { grid-column: 2; font-size: 12px; color: var(--dim); }
.buy-btn { margin-left: 8px; padding: 2px 10px !important; }
.buy-total { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.buy-total b { color: var(--ink); }

/* dice */
.dice-tray { display: flex; flex-direction: column; gap: 10px; }
.dice-btns { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.die-btn { padding: 8px 0; border-radius: 6px; border: 1px solid var(--border-2); background: var(--surface-3); color: var(--ink); font-weight: 600; font-size: 13px; cursor: pointer; }
.die-btn:hover { border-color: var(--gold); color: var(--gold-2); }
.dice-opts { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.roll-log { list-style: none; margin: 0; padding: 0; }
.roll { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.roll:first-child { border-top: 0; }
.roll-main { flex: 1; min-width: 0; }
.roll-top { font-size: 14px; }
.roll-detail { font-size: 13px; color: var(--muted); margin-top: 2px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.die { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 4px; border-radius: 4px; background: var(--surface-3); border: 1px solid var(--border-2); color: var(--ink); font-size: 12px; font-weight: 600; }
.die.dropped { opacity: .4; text-decoration: line-through; }
.roll-total { font-size: 24px; font-weight: 700; min-width: 44px; text-align: right; }
.roll.crit .roll-total { color: var(--gold-2); } .roll.crit { box-shadow: inset 3px 0 0 var(--gold); padding-left: 10px; }
.roll.fumble .roll-total { color: var(--no); } .roll.fumble { box-shadow: inset 3px 0 0 var(--no); padding-left: 10px; }
.roll.private { opacity: .85; }
.roll-when { font-size: 11.5px; color: var(--dim); width: 64px; text-align: right; }
body:has(.dice-fab) #toasts { bottom: 76px; }
.dice-fab { position: fixed; right: 20px; bottom: 20px; z-index: 30; display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 99px;
  border: 1px solid var(--border-2); background: var(--surface-3); color: var(--ink); font-weight: 600; cursor: pointer; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.dice-fab:hover { border-color: var(--gold); }
.dice-fab .ic { color: var(--gold-2); width: 18px; height: 18px; }

/* NPCs */
.npc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.npc { padding: 16px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.npc.dead { opacity: .65; } .npc.secret { border-style: dashed; border-color: rgba(217,65,47,.45); }
.npc-head { display: flex; gap: 12px; align-items: center; }
.npc-head h3 { margin: 0; font-size: 16.5px; font-weight: 600; }
.npc-role { font-size: 13px; color: var(--muted); }
.medal { flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 16px; color: #f3e6c8; background: var(--surface-3); border: 2px solid var(--border-2); }
.medal.att-friendly { border-color: #4f8a5c; } .medal.att-hostile { border-color: #9a2e22; } .medal.att-neutral { border-color: #7a6a4a; }
.npc-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--border-2); color: var(--muted); }
.tag.att-friendly { color: #b9dcc0; border-color: rgba(120,177,132,.45); } .tag.att-hostile { color: #eab3a7; border-color: rgba(217,65,47,.5); }
.npc-desc { margin: 0; font-size: 14px; color: #d8cebf; line-height: 1.5; }
.dm-secret { font-size: 13px; padding: 8px 10px; border-radius: 6px; background: rgba(110,23,20,.22); border: 1px dashed rgba(217,65,47,.45); color: #f0c4ba; }

/* quests */
.quest { padding: 14px 0; border-top: 1px solid var(--border); }
.panel h2 + .quest { border-top: 0; padding-top: 0; }
.quest.secret { opacity: .8; }
.quest.completed h3, .quest.failed h3 { color: var(--muted); }
.quest-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.quest-head h3 { margin: 0; font-size: 16.5px; font-weight: 600; }
.quest-progress { margin-left: auto; font-size: 12.5px; color: var(--dim); }
.quest-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); margin-top: 3px; }
.quest-desc { margin: 8px 0 0; font-size: 14px; color: #d8cebf; }
.objectives { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 6px; }
.objectives li { display: flex; gap: 10px; align-items: center; font-size: 14px; }
.objectives li.done { color: var(--dim); text-decoration: line-through; }
.obj-box { flex: none; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 4px; border: 1px solid var(--border-2); background: var(--surface-2); color: var(--ok); font-size: 12px; cursor: pointer; }
span.obj-box { cursor: default; }

/* handouts */
.handout-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.handout { border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; }
.handout.secret { border-style: dashed; border-color: rgba(217,65,47,.45); }
.handout-face { display: block; width: 100%; height: 190px; padding: 0; border: 0; cursor: zoom-in; background: #121011; overflow: hidden; }
.handout-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.letter { height: 100%; padding: 16px 18px; text-align: left; color: var(--parch-ink); font-family: var(--prose); font-style: italic; font-size: 15px; line-height: 1.5;
  background: var(--paper), linear-gradient(180deg, #f1e6cc, var(--parch-2)); white-space: pre-line; overflow: hidden; }
.letter.full { height: auto; border-radius: 6px; font-size: 17.5px; margin-top: 8px; }
.letter.full p { margin: 0 0 10px; }
.handout-full { width: 100%; border-radius: 6px; display: block; }
.handout-foot { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-size: 14px; flex-wrap: wrap; }
.handout-foot .sp { flex: 1; }

/* in-world calendar */
.cal-today { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.game-date { font-family: var(--prose); font-weight: 700; font-size: 26px; color: var(--ink); }
.gcal { display: grid; grid-template-columns: repeat(var(--wd), minmax(0, 1fr)); gap: 4px; }
.gcal .dow { font-size: 12px; color: var(--dim); text-align: center; padding-bottom: 4px; }
.gday { min-height: 70px; border-radius: 4px; background: var(--surface-2); padding: 5px; display: flex; flex-direction: column; gap: 3px; }
.gday.out { background: transparent; }
.gday.past { opacity: .5; }
.gday.today { box-shadow: inset 0 0 0 1px var(--gold); }
.gday .n { font-size: 12px; color: var(--muted); }
.gday.today .n { color: var(--gold-2); font-weight: 600; }
.gev { font-size: 11px; padding: 2px 5px; border-radius: 3px; background: rgba(140,30,24,.45); color: #f3d7cf; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-list { list-style: none; margin: 0; padding: 0; }
.event-list li { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 14px; }
.event-list li:first-child { border-top: 0; }
.event-list b { font-weight: 600; font-size: 13px; color: var(--gold-2); }
.event-list span { grid-column: 1; color: var(--muted); }
.event-list .icon-x { grid-row: 1 / 3; grid-column: 2; align-self: center; }
.cal-event-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
@media (max-width: 640px) { .gday { min-height: 44px; } .gev { font-size: 0; height: 5px; padding: 0; } }

/* session zero */
.prose { font-family: var(--prose); font-size: 17px; line-height: 1.6; color: #e2d8c8; }
.prose p { margin: 0 0 10px; }
.lv { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.lv h3 { margin: 0; font-size: 15px; font-weight: 600; }
.bullet { margin: 6px 0 0; padding-left: 18px; font-size: 14px; color: #d8cebf; }
.bullet li { margin: 3px 0; }
.xcard { border-color: rgba(217,65,47,.45); }
.x-btn { width: 100%; background: #2a1110; border-color: #8e2019; color: #f3cfc4; font-weight: 600; padding: 12px; }
.x-btn:hover { background: #3a1513; border-color: var(--crimson-2); }
@media (max-width: 640px) { .lv { grid-template-columns: 1fr; } }

/* encounter builder */
.difficulty { margin: 16px 0 6px; }
.diff-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 15px; }
.diff-label { font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 99px; border: 1px solid var(--border-2); }
.diff-label.d-low { color: #b9dcc0; } .diff-label.d-moderate { color: #e3c88f; } .diff-label.d-high { color: #f0a274; } .diff-label.d-beyond { color: #ff8a78; border-color: #8e2019; }
.diff-bar { position: relative; height: 10px; border-radius: 5px; background: var(--surface-3); margin: 0 0 22px; }
.diff-bar i { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, #4f8a5c, #cfa253, #c4502a); }
.diff-bar .mark { position: absolute; top: -3px; width: 2px; height: 16px; background: var(--ink); opacity: .6; }
.diff-bar .mark em { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); font-style: normal; font-size: 11px; color: var(--dim); white-space: nowrap; }
.mon-list { list-style: none; margin: 10px 0 0; padding: 0; max-height: 420px; overflow-y: auto; }
.mon-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 2px; border-top: 1px solid var(--border); }
.mon-list li span { display: flex; flex-direction: column; font-size: 14px; }

/* factions */
.faction-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.faction { padding: 16px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--fc); display: flex; flex-direction: column; gap: 10px; }
.faction p { margin: 0; font-size: 14px; }
.faction-head { display: flex; align-items: center; gap: 10px; }
.faction-head h3 { margin: 0; font-size: 16.5px; font-weight: 600; flex: 1; }
.banner-swatch { width: 12px; height: 18px; background: var(--fc); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 75%, 0 100%); }
.tier-tag { font-size: 12px; font-weight: 600; color: var(--muted); }
.rep-bar { position: relative; height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.rep-bar .mid { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--border-2); }
.rep-bar i { position: absolute; top: 0; bottom: 0; }
.rep-bar i.pos { background: #5f9a6b; } .rep-bar i.neg { background: #a3392b; }
.rep-scale { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--dim); margin-top: 4px; }
.rep-scale span:nth-child(2) { color: var(--ink); font-weight: 600; }
.rep-history { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13px; }
.rep-history li { padding: 3px 0; }
.rep-history .pos { color: var(--ok); } .rep-history .neg { color: var(--no); }

/* discord preview */
.discord-preview { margin: 6px 0 12px; padding: 10px 12px; border-radius: 6px; background: #313338; color: #dbdee1; font-family: "gg sans", "Noto Sans", system-ui, sans-serif; font-size: 14px; border-left: 3px solid #5865f2; }
.dp-name { font-weight: 600; color: #f2f3f5; margin-bottom: 2px; }
.dp-name span { font-size: 10px; background: #5865f2; color: #fff; border-radius: 3px; padding: 0 4px; margin-left: 4px; vertical-align: 1px; }

/* combat: what players can see */
.vis-group + .vis-group { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--border); }
.vis-label { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.vis-group .field { margin-bottom: 8px; }
.vis-note { font-size: 11.5px; color: var(--dim); margin-top: 3px; }
.cb-ac.unknown { color: var(--dim); }
