/* ============================================================
   BBS Command Melding Calculator — styles ported from the
   original single-file version, scoped under .kh
   ============================================================ */

.kh-header { padding: 22px 0 8px; max-width: 1100px; margin: 0 auto; }
.kh-header h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: .3px; }
.kh-header .sub { color: var(--dim); font-size: 13px; margin: 0; }

.kh .tabs { display: flex; gap: 6px; max-width: 1100px; margin: 14px auto 0; flex-wrap: wrap; }
.kh .tab { background: var(--panel); border: 1px solid var(--line); color: var(--dim); padding: 8px 14px;
    border-radius: 10px 10px 0 0; cursor: pointer; font-size: 13px; font-weight: 600; }
.kh .tab.active { background: var(--panel2); color: var(--ink); border-bottom-color: var(--panel2); }

.kh-main { max-width: 1100px; margin: 0 auto; padding: 0 0 60px; }
.kh .card { background: var(--panel2); border: 1px solid var(--line); border-radius: 0 12px 12px 12px; padding: 18px; }
.kh .row { display: flex; gap: 14px; flex-wrap: wrap; }
.kh .slot { flex: 1; min-width: 220px; }
.kh label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--dim); margin: 0 0 6px; }
.kh select, .kh input[type=text] { width: 100%; background: var(--panel); border: 1px solid var(--line); color: var(--ink);
    padding: 10px 12px; border-radius: 10px; font-size: 14px; appearance: none; }
.kh select:focus, .kh input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.kh .crystal-row { margin-top: 14px; }
.kh .hint { color: var(--dim); font-size: 12px; margin: 10px 0 0; }
.kh .results { margin-top: 18px; }
.kh .grp-title { font-size: 13px; color: var(--accent2); text-transform: uppercase; letter-spacing: .7px; margin: 18px 0 8px; }
.kh table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.kh th, .kh td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.kh th { color: var(--dim); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; }
.kh tbody tr:hover { background: rgba(95, 179, 255, .06); }
.kh .cmd { font-weight: 700; color: var(--ink); }
.kh .ing { color: var(--ink); }
.kh .type-pill { display: inline-block; min-width: 22px; text-align: center; background: var(--chip); border: 1px solid var(--line);
    border-radius: 6px; padding: 1px 7px; font-weight: 700; font-size: 12px; }
.kh .pct { color: var(--dim); }
.kh .pct.low { color: #ff8e8e; }
.kh .ability { color: #6fe39a; font-weight: 600; }
.kh .crystal-tag { color: var(--dim); font-size: 12px; }
.kh .empty { color: var(--dim); padding: 24px 4px; font-size: 14px; }
.kh .pillbar { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.kh .pill { background: var(--chip); border: 1px solid var(--line); color: var(--ink); padding: 5px 10px; border-radius: 999px; font-size: 12.5px; cursor: pointer; }
.kh .pill.on { background: var(--accent); color: #06203b; border-color: var(--accent); font-weight: 700; }
.kh .countbadge { color: var(--dim); font-size: 12px; margin-left: 8px; }
.kh .ablist { display: flex; flex-wrap: wrap; gap: 5px; }
.kh .abtag { background: #15351f; border: 1px solid #2c5b3c; color: #6fe39a; border-radius: 6px; padding: 1px 7px; font-size: 12px; }
/* completed ability = red + strikethrough (strikethrough carries the
   meaning for colourblind readers), used across all tabs */
.kh .abtag.done { background: #3a1414; border-color: #7a2c2c; color: #ff8e8e; text-decoration: line-through; }
.kh .ability.done { color: #ff8e8e; text-decoration: line-through; }
.kh .celldone { background: rgba(255, 90, 90, .16); color: #ff8e8e; text-decoration: line-through; }
/* tracker */
.kh .trk-cat { font-size: 13px; color: var(--accent2); text-transform: uppercase; letter-spacing: .7px; margin: 20px 0 8px; }
.kh .trk-table td, .kh .trk-table th { vertical-align: middle; }
.kh .trk-name { font-weight: 600; }
.kh .trk-name.done { color: #ff8e8e; text-decoration: line-through; }
.kh .stepper { display: inline-flex; align-items: center; gap: 8px; }
.kh .stepbtn { width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel);
    color: var(--ink); font-size: 16px; cursor: pointer; line-height: 1; }
.kh .stepbtn:hover { border-color: var(--accent); color: var(--accent); }
.kh .stepval { min-width: 54px; text-align: center; font-variant-numeric: tabular-nums; }
.kh .stepval .mx { color: var(--dim); font-size: 12px; }
.kh .donepill { background: #3a1414; border: 1px solid #7a2c2c; color: #ff8e8e; border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 700; }
.kh .crystaltag { font-size: 11px; color: var(--dim); }
.kh .trk-progress { height: 6px; border-radius: 4px; background: var(--panel); overflow: hidden; min-width: 70px; }
.kh .trk-progress > i { display: block; height: 100%; background: #6fe39a; }
.kh .trk-progress.full > i { background: #ff6b6b; }
.kh .trk-summary { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--dim); margin: 4px 0 0; }
.kh .trk-summary b { color: var(--ink); }
/* search-by-ability */
.kh .recipe-have { background: rgba(111, 227, 154, .10); }
.kh .chip-have { background: #15351f; border: 1px solid #2c5b3c; color: #6fe39a; border-radius: 6px; padding: 1px 7px; font-size: 12px; }
.kh .chip-need { background: var(--panel); border: 1px solid var(--line); color: var(--dim); border-radius: 6px; padding: 1px 7px; font-size: 12px; }
.kh .recipe-line { font-size: 13px; }
.kh .havechip { background: #15351f; border: 1px solid #2c5b3c; color: #6fe39a; border-radius: 6px; padding: 1px 7px; font-size: 12px; }
.kh .toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.kh .clearbtn { background: var(--panel); border: 1px solid var(--line); color: var(--dim); border-radius: 8px; padding: 7px 12px; cursor: pointer; font-size: 12px; }
.kh .clearbtn:hover { color: var(--ink); }
.kh .legend { font-size: 12px; color: var(--dim); margin-top: 6px; }
/* combobox */
.kh .combo { position: relative; }
.kh .combo input { width: 100%; }
.kh .combo .clearx { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: none;
    color: var(--dim); font-size: 16px; cursor: pointer; line-height: 1; padding: 2px 4px; }
.kh .combo .clearx:hover { color: var(--ink); }
.kh .menu { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); background: var(--panel);
    border: 1px solid var(--line); border-radius: 10px; max-height: 260px; overflow: auto;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .45); display: none; }
.kh .menu.open { display: block; }
.kh .opt { padding: 8px 12px; font-size: 14px; cursor: pointer; }
.kh .opt:hover, .kh .opt.active { background: var(--chip); }
.kh .opt .match { color: var(--accent); font-weight: 700; }
.kh .opt.none { color: var(--dim); cursor: default; }
/* character filter */
.kh .charbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 4px 0 0; }
.kh .charbtn { display: flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line);
    color: var(--dim); padding: 7px 12px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 600; }
.kh .charbtn.on { color: #06203b; font-weight: 700; }
.kh .charbtn[data-c="terra"].on { background: #ff9b6b; border-color: #ff9b6b; }
.kh .charbtn[data-c="ventus"].on { background: #7be07b; border-color: #7be07b; }
.kh .charbtn[data-c="aqua"].on { background: #6fb8ff; border-color: #6fb8ff; }
.kh .charbtn .dot { width: 9px; height: 9px; border-radius: 50%; }
.kh .charbtn[data-c="terra"] .dot { background: #ff7a3c; }
.kh .charbtn[data-c="ventus"] .dot { background: #3fc23f; }
.kh .charbtn[data-c="aqua"] .dot { background: #3c93ff; }
.kh .userbadge { display: inline-flex; gap: 4px; margin-left: 6px; }
.kh .ub { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.kh .ub.terra { background: #ff7a3c; }
.kh .ub.ventus { background: #3fc23f; }
.kh .ub.aqua { background: #3c93ff; }
.kh .ub.off { background: var(--line); }
/* crystal chart */
.kh .ctype { font-weight: 700; text-align: center; background: var(--chip); }
.kh .crystal-table td { font-size: 13px; }
.kh .crystal-table th { position: sticky; top: 0; background: var(--panel2); z-index: 2; }
.kh .cryhead { color: var(--accent2); }
.kh .cellhit { background: rgba(95, 179, 255, .18); color: var(--ink); font-weight: 700; border-radius: 4px; }
.kh .scrollx { overflow-x: auto; }

/* ============================================================
   BBS achievement / completion tracker additions
   ============================================================ */
.kh .chk { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.kh .chk:disabled { cursor: default; }
.kh td.chkcell { width: 30px; text-align: center; }
.kh tr.donerow td { color: var(--dim); }
.kh tr.donerow .itemname { text-decoration: line-through; color: var(--dim); }
.kh .itemname { font-weight: 600; color: var(--ink); }
.kh .srcbadge { display: inline-block; margin-left: 6px; background: #15351f; border: 1px solid #2c5b3c; color: #6fe39a;
    border-radius: 6px; padding: 0 6px; font-size: 11px; font-weight: 700; vertical-align: 1px; }
.kh .rewardbadge { display: inline-block; background: var(--chip); border: 1px solid var(--line); color: var(--accent2);
    border-radius: 6px; padding: 1px 7px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.kh .rarity { display: inline-block; min-width: 64px; text-align: center; border-radius: 6px; padding: 1px 8px;
    font-size: 11.5px; font-weight: 700; border: 1px solid var(--line); background: var(--chip); color: var(--dim); }
.kh .rarity.platinum { color: #cfe6ff; border-color: #6f93c4; }
.kh .rarity.gold { color: var(--accent2); border-color: #8a6f2c; }
.kh .rarity.silver { color: #d7dce8; border-color: #76819e; }
.kh .rarity.bronze { color: #e0a878; border-color: #8a5d33; }
.kh .stars { color: var(--accent2); letter-spacing: 1px; white-space: nowrap; }
.kh .prgchip { display: inline-block; background: var(--panel); border: 1px solid var(--line); color: var(--dim);
    border-radius: 999px; padding: 1px 9px; font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kh .prgchip.full { color: #6fe39a; border-color: #2c5b3c; }
.kh .dash-table td, .kh .dash-table th { vertical-align: middle; }
.kh .dashbar { display: inline-block; vertical-align: middle; width: 90px; height: 6px; border-radius: 4px;
    background: var(--panel); overflow: hidden; margin-left: 8px; }
.kh .dashbar > i { display: block; height: 100%; background: var(--accent); }
.kh .dashbar.full > i { background: #6fe39a; }
.kh .dashnum { font-variant-numeric: tabular-nums; color: var(--ink); }
.kh .hidelbl { display: inline-flex; align-items: center; gap: 6px; color: var(--dim); font-size: 12px;
    text-transform: none; letter-spacing: 0; margin: 0; cursor: pointer; }
.kh .sub-title { font-size: 13px; color: var(--accent); text-transform: uppercase; letter-spacing: .7px; margin: 22px 0 8px; }
.kh .grpbtn { margin-left: 10px; background: var(--panel); border: 1px solid var(--line); color: var(--dim);
    border-radius: 6px; padding: 2px 9px; cursor: pointer; font-size: 11px; font-weight: 600;
    text-transform: none; letter-spacing: 0; vertical-align: 1px; }
.kh .grpbtn:hover { color: var(--accent); border-color: var(--accent); }
/* Sora / Riku character buttons (CoM, DDD trackers) */
.kh .charbtn[data-c="sora"].on { background: #6fb8ff; border-color: #6fb8ff; }
.kh .charbtn[data-c="riku"].on { background: #c79bff; border-color: #c79bff; }
.kh .charbtn[data-c="sora"] .dot { background: #3c93ff; }
.kh .charbtn[data-c="riku"] .dot { background: #9a5cff; }

/* ---- command-type icons + meld action (melding calculator) ----
   Sized to sit inside the 13.5px table text without inflating rows. */
.kh .cmdicon { width: 14px; height: 14px; vertical-align: -2px; margin-right: 5px; }
.kh .grp-title .cmdicon { width: 15px; height: 15px; vertical-align: -3px; }
/* owned in the Achievement Tracker = gold highlight (no extra marker).
   :not(.done) so a completed ability keeps its red strikethrough. */
.kh .abtag.ach:not(.done) { background: #3a3114; border-color: #8a6d1d; color: #e6c450; }
.kh .ability.ach:not(.done) { color: #e6c450; }
.kh .cellach:not(.celldone) { background: rgba(230, 196, 80, .14); color: #e6c450; }
.kh .pill.ach { border-color: #8a6d1d; box-shadow: inset 0 0 0 1px #8a6d1d; }
.kh .achpill { background: #3a3114; border: 1px solid #8a6d1d; color: #e6c450; border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 700; }
/* selectable ability tags */
.kh .abtag.pick { cursor: pointer; }
.kh .abtag.pick:hover { border-color: var(--accent); }
.kh .abtag.sel { background: var(--accent); border-color: var(--accent); color: #06203b; font-weight: 700; }
.kh .abtag.sel.done { text-decoration: line-through; }
/* "None" pick tag (meld without an ability) */
.kh .abtag.none { background: var(--panel); border-color: var(--line); color: var(--dim); }
.kh .abtag.none.sel { background: var(--accent); border-color: var(--accent); color: #06203b; }
/* owned-result indicators — row tint only; names/chips never wrap mid-name */
.kh .owned-row { background: rgba(111, 227, 154, .08); }
.kh .ownname { white-space: nowrap; }
.kh .ing .chip-have, .kh .ing .chip-need { white-space: nowrap; display: inline-block; }
.kh .meldbtn { background: var(--panel); border: 1px solid var(--accent); color: var(--accent); border-radius: 8px;
    padding: 5px 12px; cursor: pointer; font-size: 12px; font-weight: 700; white-space: nowrap; }
.kh .meldbtn:hover:not(:disabled) { background: var(--accent); color: #06203b; }
.kh .meldbtn:disabled { border-color: var(--line); color: var(--dim); cursor: not-allowed; opacity: .6; }
.meldtoast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(12px); background: #15351f;
    border: 1px solid #2c5b3c; color: #6fe39a; border-radius: 10px; padding: 10px 18px; font-size: 13.5px; font-weight: 600;
    opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 60; }
.meldtoast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
/* import/export progress bar */
.kh .kp-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.kh .kp-note { color: var(--dim); font-size: 12px; }
