/* DeckBuilder web UI — CiteMed house style (CiteMed-Deck-STYLE-GUIDE.md).
   Enterprise, restrained: navy anchor, one brand blue, Georgia display + Calibri
   functional, card grids, generous whitespace. No decorative accent lines under
   titles, no bottom-of-page pitch lines. */
:root {
  --navy: #1B2A4A;
  --blue: #3D6EB6;
  --ice: #CADCFC;
  --ink: #4A5568;       /* body */
  --slate: #718096;     /* captions / muted */
  --line: #DEE5EF;      /* card borders / hairlines */
  --chip: #E8EEF7;      /* pills, light fills */
  --panel: #EEF3FA;     /* section panels */
  --paper: #FFFFFF;
  --ok-fg: #276749; --ok-bg: #F0FFF4;
  --warn-fg: #B7791F; --warn-bg: #FDF1E3;
  --serif: Georgia, "Times New Roman", serif;
  --sans: Calibri, Carlito, "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: var(--sans); color: var(--ink);
  background: #F7F8FA; line-height: 1.5;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header: navy bar, Georgia wordmark, brand-blue brackets. */
header.top {
  background: var(--navy); color: #fff; padding: 0 24px;
  display: flex; align-items: center; gap: 28px; height: 60px;
  border-bottom: 3px solid var(--blue);
}
.wordmark { font-family: var(--serif); font-size: 22px; letter-spacing: .3px; }
.wordmark .b { color: var(--blue); }
.wordmark .n { color: #fff; }
header.top nav { display: flex; gap: 20px; margin-left: auto; align-items: center; }
header.top nav a { color: var(--ice); font-size: 14px; }
header.top nav a.active { color: #fff; font-weight: 600; }
.cart-badge {
  background: var(--blue); color: #fff; border-radius: 12px;
  padding: 1px 9px; font-size: 12px; font-weight: 700; margin-left: 4px;
}

main { max-width: 1200px; margin: 0 auto; padding: 28px 24px 64px; }
h1, h2, h3 { font-family: var(--serif); font-weight: normal; color: var(--navy); }
h1 { font-size: 28px; margin: 4px 0 20px; }
h2 { font-size: 21px; }
.eyebrow {
  font-family: var(--sans); font-weight: 700; font-size: 10.5px;
  letter-spacing: 1.2px; text-transform: uppercase; color: var(--blue);
}

/* Toolbar: search + filters */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 22px; }
.toolbar input[type=search], .toolbar select {
  font-family: var(--sans); font-size: 14px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink);
}
.toolbar input[type=search] { min-width: 280px; }
.count { color: var(--slate); font-size: 13px; margin-left: auto; }

/* Card grid of slides */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr)); gap: 22px; }
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; display: flex; flex-direction: column;
  border-top: 3px solid var(--blue);
}
.card .thumb {
  aspect-ratio: 16 / 9; background: var(--panel); display: flex;
  align-items: center; justify-content: center; overflow: hidden;
}
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .thumb .placeholder { color: var(--slate); font-size: 12px; padding: 8px; text-align: center; }
.card .body { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card .body .t { font-family: var(--serif); color: var(--navy); font-size: 15px; line-height: 1.25; }
.card .meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: auto; }
.card .actions { padding: 10px 14px; border-top: 1px solid var(--line); display: flex; gap: 8px; }

.chip {
  background: var(--chip); color: var(--blue); font-size: 10.5px; font-weight: 700;
  padding: 2px 8px; border-radius: 10px; letter-spacing: .3px; text-transform: uppercase;
}
.chip.muted { background: #F7F8FA; color: var(--slate); }
.chip.count { background: var(--warn-bg); color: var(--warn-fg); }

button, .btn {
  font-family: var(--sans); font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--blue); background: var(--blue); color: #fff;
  padding: 7px 14px; border-radius: 6px;
}
button.ghost, .btn.ghost { background: #fff; color: var(--blue); }
button:hover { filter: brightness(1.05); }
button.in-deck { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-fg); }

/* Deck / cart list */
.deck-list { list-style: none; padding: 0; margin: 0; }
.deck-list li {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; margin-bottom: 8px;
}
.deck-list li .idx { font-family: var(--serif); color: var(--slate); width: 24px; }
.deck-list li .t { flex: 1; color: var(--navy); }

/* Compose: reorder slides with large thumbnails */
.deck-reorder { list-style: none; padding: 0; margin: 18px 0 0; }
.deck-reorder li {
  display: flex; align-items: center; gap: 16px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-bottom: 12px;
}
.deck-reorder .idx { font-family: var(--serif); color: var(--slate); width: 22px; text-align: center; font-size: 18px; }
.reorder-thumb {
  flex: 0 0 auto; width: 240px; aspect-ratio: 16 / 9; overflow: hidden;
  border: 1px solid var(--line); border-radius: 6px; background: var(--panel);
  display: flex; align-items: center; justify-content: center;
}
.reorder-thumb img { width: 100%; height: 100%; object-fit: cover; }
.reorder-thumb .placeholder { color: var(--slate); font-size: 12px; padding: 8px; text-align: center; }
.reorder-meta { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.reorder-meta .t { font-family: var(--serif); color: var(--navy); font-size: 16px; line-height: 1.3; }
.reorder-actions { flex: 0 0 auto; display: flex; gap: 6px; }

button.danger { background: #fff; color: #C0392B; border: 1px solid #E3B4AE; }
button.danger:hover { background: #C0392B; color: #fff; border-color: #C0392B; }
button.danger-ghost:hover { color: #C0392B; border-color: #E3B4AE; }

/* Auth */
.navuser { color: #cdd6e6; font-size: 12px; opacity: .85; margin-left: 10px; }
.login-wrap { max-width: 440px; margin: 24px auto 0; }
.login-form { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.login-form input[type=email] { font-family: var(--sans); font-size: 15px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 8px; }
.login-form button { padding: 11px 14px; font-size: 15px; }
.login-error { background: #FBECEA; color: #B03A2E; border: 1px solid #E3B4AE; border-radius: 6px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }

/* Decks toolbar (My/All + sort) */
.decks-toolbar { display: flex; align-items: center; gap: 10px; margin: 6px 0 14px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg a { padding: 6px 14px; font-size: 13px; text-decoration: none; color: var(--ink); background: #fff; }
.seg a + a { border-left: 1px solid var(--line); }
.seg a.on { background: var(--navy); color: #fff; }
.seg a:not(.on):hover { background: var(--panel); }
.linkish { font-size: 12px; text-decoration: none; color: var(--slate); padding: 2px 4px; }
.linkish.on { color: var(--navy); font-weight: 600; }

/* Tag filter bar */
.tagbar { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin: 2px 0 18px; }
.tagbar-label { font-size: 12px; color: var(--slate); margin-right: 4px; }
.tagpill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; text-decoration: none;
  color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 3px 10px; }
.tagpill:hover { border-color: var(--blue); color: var(--blue); }
.tagpill .tagpill-n { color: var(--slate); font-size: 11px; }
.tagpill.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.tagpill.on .tagpill-n { color: #cdd6e6; }

/* Master library multi-select + bulk delete */
.grid .card { position: relative; }
.selbox { position: absolute; top: 8px; left: 8px; width: 20px; height: 20px; z-index: 3;
  cursor: pointer; accent-color: var(--blue); background: #fff; border-radius: 4px; box-shadow: 0 0 0 2px #fff; }
.grid .card.selected { outline: 2px solid var(--blue); outline-offset: 1px; }
.bulk-bar { display: flex; align-items: center; gap: 16px; margin: 4px 0 16px; padding: 8px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.bulk-bar label { font-size: 13px; color: var(--ink); display: flex; align-items: center; gap: 6px; cursor: pointer; }
.bulk-sep { width: 1px; height: 22px; background: var(--line); }
.bulk-tag { font-family: var(--sans); font-size: 13px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; width: 150px; }
a.chip { text-decoration: none; }
a.chip:hover { border-color: var(--blue); color: var(--blue); }

/* Tag editing (slide page) */
.tags-edit { margin-top: 10px; }
.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tag-chip { display: inline-flex; align-items: center; background: var(--chip); border-radius: 20px; padding: 2px 4px 2px 11px; font-size: 12px; }
.tag-chip a { color: var(--navy); text-decoration: none; }
.tag-chip a:hover { color: var(--blue); }
.tag-x { background: none; border: none; color: var(--slate); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 5px; }
.tag-x:hover { color: #C0392B; }
.tag-add { display: flex; gap: 6px; }
.tag-add input { flex: 1; font-family: var(--sans); font-size: 13px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; }

/* Style guide */
.swatches { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; }
.swatch { display: flex; flex-direction: column; gap: 4px; width: 158px; }
.swatch .chipcolor { height: 46px; border-radius: 6px; display: block; }
.swatch .sw-hex { font-family: var(--sans); font-size: 12px; color: var(--navy); font-weight: 600; letter-spacing: .04em; }
.swatch .sw-label { font-size: 11px; color: var(--slate); line-height: 1.3; }

.markdown { color: var(--ink); line-height: 1.6; font-family: var(--sans); font-size: 14px; max-width: 860px; }
.markdown h1, .markdown h2, .markdown h3 { font-family: var(--serif); color: var(--navy); margin: 22px 0 10px; font-weight: normal; }
.markdown h2 { font-size: 20px; border-top: 1px solid var(--line); padding-top: 18px; }
.markdown h3 { font-size: 16px; }
.markdown table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13px; }
.markdown th, .markdown td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.markdown th { background: var(--panel); color: var(--navy); }
.markdown code { background: var(--chip); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.markdown pre { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px; overflow-x: auto; }
.markdown pre code { background: none; padding: 0; }
.markdown hr { border: none; border-top: 1px solid var(--line); margin: 20px 0; }
.markdown ul { padding-left: 20px; }
.markdown blockquote { border-left: 3px solid var(--blue); margin: 12px 0; padding-left: 14px; color: var(--slate); }
@media (max-width: 640px) { .deck-reorder li { flex-wrap: wrap; } .reorder-thumb { width: 100%; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; }
.notice { background: var(--ok-bg); color: var(--ok-fg); border: 1px solid var(--ok-fg); border-radius: 6px; padding: 10px 14px; margin-bottom: 18px; }
.footer-rule { border: none; border-top: 1px solid var(--navy); opacity: .12; margin: 40px 0 12px; }
.muted { color: var(--slate); font-size: 13px; }
