/* =====================================================================
   FRONT OFFICE TEMPLATE LIBRARY: INTERFACE
   Readability first: generous line height, measured column widths,
   high-contrast type in both themes.
   ===================================================================== */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg:            #f4f5f8;
  --surface:       #ffffff;
  --surface-2:     #fafbfc;
  --surface-3:     #f0f1f5;
  --ink:           #15171e;
  --ink-soft:      #3d4250;
  --muted:         #676e81;
  --line:          #e2e5ec;
  --line-strong:   #c9cdd8;
  --accent:        #ffd400;
  --accent-deep:   #e6b800;
  --accent-ink:    #1a1a1a;
  --accent-wash:   #fff8d6;
  --good:          #1a7f4b;
  --good-wash:     #e6f6ec;
  --warn:          #a8541a;
  --warn-wash:     #fdf0e4;
  --shadow-sm:     0 1px 2px rgba(18, 20, 26, .06), 0 2px 8px rgba(18, 20, 26, .04);
  --shadow-md:     0 4px 12px rgba(18, 20, 26, .10), 0 12px 28px rgba(18, 20, 26, .07);
  --radius:        14px;
  --radius-sm:     9px;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html[data-theme="dark"] {
  --bg:            #101219;
  --surface:       #1a1d26;
  --surface-2:     #202430;
  --surface-3:     #262b38;
  --ink:           #eef0f6;
  --ink-soft:      #cbd0dd;
  --muted:         #97a0b5;
  --line:          #2c3140;
  --line-strong:   #3c4356;
  --accent:        #ffd400;
  --accent-deep:   #ffe45c;
  --accent-ink:    #14161c;
  --accent-wash:   #34301a;
  --good:          #5fd39a;
  --good-wash:     #14301f;
  --warn:          #f0a86a;
  --warn-wash:     #33231a;
  --shadow-sm:     0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md:     0 6px 20px rgba(0, 0, 0, .5);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
}

a { color: inherit; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.topbar-inner {
  max-width: 1500px;
  margin: 0 auto;
  padding: .85rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: .7rem;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-mark {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -.5px;
}

.brand-mark-img {
  width: 46px; height: 46px;
  border-radius: 10px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

.brand-text strong { display: block; font-size: 1rem; font-weight: 700; line-height: 1.2; }
.brand-text span   { display: block; font-size: .78rem; color: var(--muted); }

.search-wrap { position: relative; flex: 1 1 320px; min-width: 240px; }

.search-wrap svg {
  position: absolute; left: .9rem; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--muted); pointer-events: none;
}

#search {
  width: 100%;
  padding: .7rem 5.5rem .7rem 2.6rem;
  font: inherit;
  font-size: .95rem;
  color: var(--ink);
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
#search::placeholder { color: var(--muted); }
#search:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent-deep);
  box-shadow: 0 0 0 3px var(--accent-wash);
}

.search-hint {
  position: absolute; right: .6rem; top: 50%; transform: translateY(-50%);
  display: flex; gap: .3rem; pointer-events: none;
}

kbd {
  font-family: var(--sans);
  font-size: .7rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: .12rem .38rem;
  line-height: 1.4;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-left: auto;
  min-width: 0;
  flex-wrap: wrap;
}

.icon-btn {
  display: inline-flex; align-items: center; gap: .4rem;
  height: 38px; padding: 0 .8rem;
  font: inherit; font-size: .85rem; font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  transition: all .18s;
  white-space: nowrap;
}
.icon-btn:hover { border-color: var(--line-strong); color: var(--ink); transform: translateY(-1px); }
.icon-btn:focus-visible { outline: 3px solid var(--accent-wash); outline-offset: 1px; }
.icon-btn.is-on { background: var(--accent); border-color: var(--accent-deep); color: var(--accent-ink); }

/* ---------------------------------------------------------------- layout */
.shell {
  max-width: 1500px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 5rem;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}

/* ---------------------------------------------------------------- sidebar */
.sidebar { position: sticky; top: 86px; max-height: calc(100vh - 108px); overflow-y: auto; padding-right: .35rem; }
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }

.side-block { margin-bottom: 1.6rem; }

.side-label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .6rem;
  padding-left: .2rem;
}

.cat-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }

.cat-btn {
  width: 100%;
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .65rem;
  font: inherit; font-size: .9rem; font-weight: 500;
  text-align: left;
  color: var(--ink-soft);
  background: none;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.cat-btn:hover { background: var(--surface-3); color: var(--ink); }
.cat-btn:focus-visible { outline: 3px solid var(--accent-wash); }
.cat-btn.active { background: var(--accent); color: var(--accent-ink); font-weight: 650; }
.cat-btn.active .cat-count { background: rgba(0,0,0,.14); color: var(--accent-ink); }

.cat-ico { font-size: 1rem; line-height: 1; width: 1.2rem; text-align: center; flex-shrink: 0; }
.cat-name { flex: 1; min-width: 0; }
.cat-count {
  font-size: .74rem; font-weight: 700;
  background: var(--surface-3); color: var(--muted);
  border-radius: 20px; padding: .05rem .45rem; flex-shrink: 0;
}

.chip-row { display: flex; flex-wrap: wrap; gap: .35rem; }

.chip {
  font: inherit; font-size: .78rem; font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 20px;
  padding: .28rem .68rem;
  cursor: pointer;
  transition: all .15s;
}
.chip:hover { border-color: var(--line-strong); }
.chip:focus-visible { outline: 3px solid var(--accent-wash); }
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--surface); }

/* ------------------------------------------------------ placeholder panel */
.filter-rows { margin-bottom: 1.2rem; }

.filter-row {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  margin-bottom: .5rem;
}

.filter-row:last-child { margin-bottom: 0; }

/* display:flex above would otherwise beat the hidden attribute, leaving a
   stranded label with no chips beside it */
.filter-row[hidden] { display: none; }

.filter-row-label {
  flex-shrink: 0;
  padding-top: .42rem;
  width: 52px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}

.stage-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.chip-n {
  display: inline-block;
  margin-left: .45rem;
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted);
}

.chip.active .chip-n { color: inherit; opacity: .75; }

.fill-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .6rem .75rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  list-style: none;
}

.fill-details summary::-webkit-details-marker { display: none; }

.fill-details summary::after {
  content: '\203A';
  font-size: 1.1rem;
  line-height: 1;
  color: var(--muted);
  transition: transform .2s ease;
}

.fill-details[open] summary::after { transform: rotate(90deg); }
.fill-details summary:hover { color: var(--ink); border-color: var(--line-strong); }
.fill-details summary:focus-visible { outline: 3px solid var(--accent-wash); outline-offset: 2px; }

.fill-details[open] summary {
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: none;
}

.fill-details[open] .fill-panel {
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
}

.fill-panel {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: .9rem;
}
.fill-panel p { font-size: .78rem; color: var(--muted); margin-bottom: .7rem; line-height: 1.45; }
.fill-row { display: flex; flex-direction: column; gap: .2rem; margin-bottom: .5rem; }
.fill-row label { font-size: .72rem; font-weight: 700; color: var(--muted); letter-spacing: .03em; }
.fill-row input {
  font: inherit; font-size: .85rem;
  color: var(--ink);
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: 7px;
  padding: .35rem .55rem;
}
.fill-row input:focus { outline: none; border-color: var(--accent-deep); box-shadow: 0 0 0 3px var(--accent-wash); }

/* ---------------------------------------------------------------- content */
.page-head { margin-bottom: 1.4rem; }
.page-head h1 { font-size: 1.75rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.25; }
.page-head p { color: var(--muted); font-size: .95rem; margin-top: .3rem; max-width: 70ch; }

.result-bar {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .7rem 0 1.1rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.4rem;
}
.result-count { font-size: .88rem; color: var(--muted); }
.result-count b { color: var(--ink); font-weight: 700; }
.active-filters { display: flex; gap: .35rem; flex-wrap: wrap; margin-left: auto; }

.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .76rem; font-weight: 600;
  background: var(--accent-wash); color: var(--ink);
  border: 1px solid var(--accent-deep);
  border-radius: 20px; padding: .18rem .3rem .18rem .6rem;
}
.pill button {
  border: none; background: none; cursor: pointer; color: var(--ink-soft);
  font-size: .95rem; line-height: 1; padding: 0 .2rem; border-radius: 20px;
}
.pill button:hover { color: var(--ink); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(430px, 1fr)); gap: 1.15rem; }
.cards.compact { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }

/* ---------------------------------------------------------------- card */
.tcard {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}
.tcard:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.tcard.is-ref { border-left: 5px solid var(--accent); }

.tcard-head { padding: 1rem 1.15rem .75rem; }

.tcard-meta { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; margin-bottom: .5rem; }

.tag {
  font-size: .69rem; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase;
  padding: .16rem .5rem; border-radius: 5px;
  background: var(--surface-3); color: var(--muted);
  white-space: nowrap;
}
.tag.stage-reference        { background: var(--accent); color: var(--accent-ink); }
.tag.stage-first-reply      { background: var(--good-wash); color: var(--good); }
.tag.stage-in-progress      { background: var(--surface-3); color: var(--ink-soft); }
.tag.stage-follow-up        { background: var(--accent-wash); color: var(--warn); }
.tag.stage-resolution       { background: var(--good-wash); color: var(--good); }
.tag.stage-difficult-moment { background: var(--warn-wash); color: var(--warn); }
.tag.cat { background: transparent; border: 1px solid var(--line-strong); color: var(--muted); }

.fav-btn {
  margin-left: auto;
  border: none; background: none; cursor: pointer;
  font-size: 1.05rem; line-height: 1;
  color: var(--line-strong);
  padding: .15rem; border-radius: 6px;
  transition: color .15s, transform .15s;
}
.fav-btn:hover { transform: scale(1.15); color: var(--accent-deep); }
.fav-btn.on { color: var(--accent-deep); }
.fav-btn:focus-visible { outline: 3px solid var(--accent-wash); }

.tcard-head h3 { font-size: 1.08rem; font-weight: 700; line-height: 1.35; letter-spacing: -.01em; }

.tcard-use {
  font-size: .855rem; color: var(--muted); line-height: 1.5; margin-top: .3rem;
}

.tcard-body {
  margin: 0 1.15rem;
  padding: 1rem 1.1rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  line-height: 1.72;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 74ch;
  flex: 1;
}

.ph {
  background: var(--accent-wash);
  border-bottom: 1.5px solid var(--accent-deep);
  border-radius: 3px;
  padding: 0 .18rem;
  font-weight: 650;
  font-size: .93em;
}
.ph.filled { background: var(--good-wash); border-bottom-color: var(--good); color: var(--good); }

mark { background: var(--accent); color: var(--accent-ink); border-radius: 3px; padding: 0 .1rem; }

.tcard-note {
  display: flex; gap: .55rem;
  margin: .8rem 1.15rem 0;
  padding: .6rem .75rem;
  background: var(--warn-wash);
  border-left: 3px solid var(--warn);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: .82rem; line-height: 1.5; color: var(--warn);
}
.tcard-note strong { font-weight: 750; }

.tcard-tags { display: flex; gap: .3rem; flex-wrap: wrap; padding: .85rem 1.15rem 0; }
.tag-mini {
  font-size: .73rem; font-weight: 500; color: var(--muted);
  background: none; border: 1px solid var(--line); border-radius: 20px;
  padding: .1rem .5rem; cursor: pointer; font-family: inherit;
  transition: all .15s;
}
.tag-mini:hover { border-color: var(--accent-deep); color: var(--ink); background: var(--accent-wash); }

.tcard-foot {
  display: flex; align-items: center; gap: .5rem;
  padding: .85rem 1.15rem 1.05rem;
  margin-top: auto;
}

.copy-btn {
  display: inline-flex; align-items: center; gap: .45rem;
  font: inherit; font-size: .87rem; font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1.5px solid var(--accent-deep);
  border-radius: 9px;
  padding: .5rem 1rem;
  cursor: pointer;
  transition: all .15s;
}
.copy-btn:hover { background: var(--accent-deep); transform: translateY(-1px); }
.copy-btn:focus-visible { outline: 3px solid var(--accent-wash); outline-offset: 2px; }
.copy-btn.done { background: var(--good); border-color: var(--good); color: #fff; }

.ghost-btn {
  font: inherit; font-size: .82rem; font-weight: 600;
  color: var(--muted);
  background: none; border: 1.5px solid var(--line);
  border-radius: 9px; padding: .45rem .8rem; cursor: pointer;
  transition: all .15s;
}
.ghost-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.ghost-btn:focus-visible { outline: 3px solid var(--accent-wash); }

.card-id { margin-left: auto; font-size: .72rem; color: var(--line-strong); font-weight: 600; letter-spacing: .04em; }

/* ---------------------------------------------------------------- empty */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 1rem;
  color: var(--muted);
}
.empty-mark { font-size: 2.5rem; display: block; margin-bottom: .6rem; }
.empty h3 { font-size: 1.15rem; color: var(--ink); margin-bottom: .3rem; }

/* ---------------------------------------------------------------- tone view */
.tone-wrap { display: none; max-width: 1000px; margin: 0 auto; }
body.view-tone .tone-wrap { display: block; }
body.view-tone .library-wrap { display: none; }
body.view-tone .sidebar { display: none; }
body.view-tone .shell { grid-template-columns: minmax(0, 1fr); }

.tone-section { margin-bottom: 2.75rem; }
.tone-section > h2 {
  font-size: 1.25rem; font-weight: 750; letter-spacing: -.01em;
  padding-bottom: .55rem; margin-bottom: 1.1rem;
  border-bottom: 2px solid var(--accent);
}

.rule-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 1rem; }
.rule {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow-sm);
}
.rule h3 { font-size: 1rem; font-weight: 700; margin-bottom: .4rem; }
.rule p { font-size: .9rem; color: var(--ink-soft); line-height: 1.65; }

.steps { display: flex; flex-direction: column; gap: .7rem; }
.step {
  display: flex; gap: .95rem; align-items: flex-start;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: .95rem 1.1rem;
}
.step-n {
  flex-shrink: 0;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
  font-weight: 800; font-size: .9rem;
}
.step-b strong { display: block; font-size: .97rem; margin-bottom: .15rem; }
.step-b span { font-size: .88rem; color: var(--ink-soft); line-height: 1.6; }

.swap-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: .89rem;
}
.swap-table th {
  text-align: left; padding: .7rem 1rem;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); background: var(--surface-3);
  border-bottom: 1px solid var(--line);
}
.swap-table td { padding: .75rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; line-height: 1.55; }
.swap-table tr:last-child td { border-bottom: none; }
.swap-table td.bad { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); width: 40%; }
.swap-table td.good { color: var(--ink); font-weight: 550; }
.swap-table tr:hover td { background: var(--surface-2); }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed; bottom: 1.6rem; left: 50%;
  transform: translateX(-50%) translateY(140%);
  background: var(--ink); color: var(--bg);
  font-size: .88rem; font-weight: 600;
  padding: .7rem 1.2rem; border-radius: 10px;
  box-shadow: var(--shadow-md);
  z-index: 100;
  transition: transform .28s cubic-bezier(.2,.9,.3,1.2);
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ---------------------------------------------------------------- responsive */
/* ------------------------------------------- narrow: sidebar goes on top */
@media (max-width: 1080px) {
  .shell { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    position: static;
    max-height: none;
    overflow: visible;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
  }

  .side-block { margin-bottom: 0; }

  /* categories become one swipeable row rather than a tall wall of chips */
  .cat-list {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: .4rem;
    padding-bottom: .3rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .cat-list::-webkit-scrollbar { display: none; }
  .cat-list li { flex-shrink: 0; }
  .cat-btn { width: auto; border: 1.5px solid var(--line); white-space: nowrap; }
  .cat-name { flex: 0 1 auto; }

  .cards { grid-template-columns: minmax(0, 1fr); }
}

/* ------------------------------------------------------------- phones */
@media (max-width: 860px) {
  .topbar-inner { padding: .7rem 1rem; gap: .6rem .7rem; }
  .brand-text { display: none; }
  .search-hint { display: none; }

  /* search takes its own row, actions scroll sideways rather than
     forcing the whole page wider than the screen */
  .search-wrap { order: 3; flex: 1 1 100%; min-width: 0; }
  #search { padding-right: 1rem; }

  .topbar-actions {
    flex-wrap: nowrap;
    overflow-x: auto;
    max-width: 100%;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .topbar-actions::-webkit-scrollbar { display: none; }
  .icon-btn { flex-shrink: 0; height: 38px; padding: 0 .7rem; font-size: .8rem; }
}

@media (max-width: 760px) {
  /* the bar shares one row with the mark and stops being sticky, so a phone
     screen is not spending a fifth of its height on navigation */
  .topbar { position: static; }
  .topbar-actions { flex: 1 1 0; min-width: 0; margin-left: .4rem; }
  .brand-mark-img { width: 40px; height: 40px; }

  /* comfortable targets for a thumb */
  .fav-btn { padding: .4rem; font-size: 1.15rem; }
  .chip { padding: .45rem .8rem; }
  .tag-mini { padding: .42rem .7rem; font-size: .76rem; }
  .ghost-btn, .copy-btn { padding: .55rem .9rem; }
}

@media (max-width: 760px) {
  .filter-row { gap: .5rem; }
  .filter-row-label { width: 42px; font-size: .62rem; }

  .stage-bar, #svcBar {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: .3rem;
    scrollbar-width: none;
  }

  .stage-bar::-webkit-scrollbar, #svcBar::-webkit-scrollbar { display: none; }
  .stage-bar .chip, #svcBar .chip { flex-shrink: 0; }

  .tcard-foot { flex-wrap: wrap; }
  .card-id { display: none; }
}

@media (max-width: 640px) {
  .shell { padding: 1.25rem 1rem 4rem; }
  .page-head h1 { font-size: 1.4rem; }
  .tcard-body { margin: 0 .8rem; padding: .85rem; font-size: .93rem; }
  .tcard-head, .tcard-foot, .tcard-tags { padding-left: .8rem; padding-right: .8rem; }
  .tcard-note { margin-left: .8rem; margin-right: .8rem; }
  .swap-table td.bad { width: auto; }
}

/* ---------------------------------------------------------------- print */
@media print {
  .topbar, .sidebar, .result-bar, .tcard-foot, .toast, .tcard-tags { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .shell { display: block; padding: 0; }
  .cards { display: block; }
  .tcard { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; margin-bottom: .8rem; }
  .tcard-body { background: #fff; }
}

/* ---------------------------------------------------------------- footer */
.site-footer {
  max-width: 1500px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: .87rem;
  color: var(--muted);
}

.site-footer p { margin: 0; }

.site-footer .credit { margin-top: .35rem; font-size: .84rem; }

.site-footer .credit a {
  color: var(--ink-soft);
  font-weight: 650;
  text-decoration: none;
  border-bottom: 1.5px solid var(--accent);
  padding-bottom: 1px;
  transition: color .15s, border-color .15s;
}

.site-footer .credit a:hover { color: var(--ink); border-bottom-color: var(--accent-deep); }
.site-footer .credit a:focus-visible { outline: 3px solid var(--accent-wash); outline-offset: 2px; }

@media print { .site-footer { display: none; } }

/* =====================================================================
   LOADING SCREEN
   ===================================================================== */
html.is-loading, html.is-loading body { overflow: hidden; }

.fo-loader {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  background: var(--bg);
  transition: opacity .5s ease, visibility .5s ease;
}

.fo-loader.done { opacity: 0; visibility: hidden; }

.fo-loader-mark {
  position: relative;
  width: 132px;
  height: 132px;
  display: grid;
  place-items: center;
}

.fo-loader-mark img {
  width: 76px;
  height: 76px;
  animation: fo-breathe 2s ease-in-out infinite;
}

.fo-loader-ring,
.fo-loader-ring::after {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid transparent;
}

.fo-loader-ring {
  border-top-color: var(--accent);
  border-right-color: var(--accent);
  animation: fo-spin 1s cubic-bezier(.5, .12, .5, .88) infinite;
}

.fo-loader-ring::after {
  content: '';
  inset: 9px;
  border-bottom-color: var(--accent-deep);
  opacity: .5;
  animation: fo-spin 1.6s linear infinite reverse;
}

.fo-loader-text {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
  animation: fo-fade 2s ease-in-out infinite;
}

.fo-loader-bar {
  width: 190px;
  height: 3px;
  border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden;
}

.fo-loader-bar span {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-deep));
  animation: fo-sweep 1.15s ease-in-out infinite;
}

@keyframes fo-spin   { to { transform: rotate(360deg); } }
@keyframes fo-breathe{ 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }
@keyframes fo-fade   { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
@keyframes fo-sweep  { 0% { transform: translateX(-115%); } 100% { transform: translateX(365%); } }

@media (prefers-reduced-motion: reduce) {
  .fo-loader-mark img,
  .fo-loader-ring,
  .fo-loader-ring::after,
  .fo-loader-text,
  .fo-loader-bar span { animation-duration: .01ms; animation-iteration-count: 1; }
  .fo-loader-bar span { width: 100%; transform: none; }
}

@media print { .fo-loader { display: none; } }
