/* MHFU game font (falls back to sans-serif for glyphs it lacks) */
@font-face {
  font-family: 'MHFU';
  src: url('fonts/mhfu_font.ttf') format('truetype');
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #16181d;
  --bg2: #1e2129;
  --line: #333844;
  --text: #e8e8ec;
  --text-dim: #9aa0ac;
  --accent: #9146ff;
  --accent-hover: #772ce8;
  --danger: #e05a5a;
}

* { box-sizing: border-box; }

input[type="checkbox"] { accent-color: var(--accent); }

/* Fixed-viewport app shell — the page itself never scrolls; only .main-scroll does.
   This sidesteps the whole class of scroll-clamp/jump issues that come from opening
   wildly different-height accordion sections on a normally-scrolling page. */
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  display: flex; flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: 'MHFU', system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.4;
}

h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0 0 10px; }
h3 { font-size: 13px; margin: 14px 0 6px; color: var(--text-dim); font-weight: 600; }
p { margin: 0 0 10px; }
.muted { color: var(--text-dim); font-size: 13px; }

.topbar {
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  background-image:
    linear-gradient(color-mix(in srgb, var(--bg2) 88%, transparent), color-mix(in srgb, var(--bg2) 88%, transparent)),
    url('assets/titlebar-background.png');
  background-size: auto 100%;
  background-position: left center;
  background-repeat: repeat;
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; flex-wrap: wrap;
}
.topbar-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topbar-modal-btns { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#authArea:not(:empty) { padding-left: 14px; border-left: 1px solid var(--line); }

.btn {
  background-color: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 7px 14px; font-size: 13px; cursor: pointer;
  background-image:
    linear-gradient(color-mix(in srgb, var(--accent) 85%, transparent), color-mix(in srgb, var(--accent) 85%, transparent)),
    url('assets/banner-background.png');
  background-position: right; background-repeat: repeat;
}
.btn:hover { background-color: var(--accent-hover); }
.btn.secondary { background-color: var(--bg); border: 1px solid var(--line); color: var(--text); }
.btn.secondary:hover { background-color: color-mix(in srgb, var(--bg) 75%, var(--accent) 25%); border-color: var(--accent); }
.btn.tiny { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }

#saveBtn { background-color: color-mix(in srgb, var(--accent) 78%, black 22%); }
#saveBtn:hover { background-color: color-mix(in srgb, var(--accent-hover) 78%, black 22%); }

.panel {
  background-color: var(--bg2); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 14px;
}

.acc-head {
  display: flex; align-items: center; justify-content: space-between;
  border: none; border-radius: 10px 10px 0 0; color: #fff; cursor: pointer;
  padding: 10px 16px; margin: -14px -16px 0; font: inherit; text-align: left;
  width: calc(100% + 32px);
  background-color: var(--accent);
  background-image:
    linear-gradient(color-mix(in srgb, var(--accent) 65%, black 35%), color-mix(in srgb, var(--accent) 65%, black 35%)),
    url('assets/panel-body-bg.png');
  background-size: contain 100%; background-position: left center; background-repeat: repeat;
}
.acc-head:hover { background-color: var(--accent-hover); }
.acc-head h2 { margin: 0; }
.acc-chevron { color: var(--text-dim); transition: transform .15s; flex-shrink: 0; margin-left: 8px; }
.panel.accordion.open .acc-chevron { transform: rotate(180deg); }
.acc-body { display: none; margin-top: 10px; }
/* Collapsed: no .acc-body below to fill the panel's own bottom padding, so acc-head
   would otherwise leave a sliver of the panel's plain background showing beneath it.
   Zero out that padding and round acc-head's bottom corners to match the panel's. */
.panel.accordion:not(.open) { padding-bottom: 0; }
.panel.accordion:not(.open) .acc-head { border-radius: 10px; }
.panel.accordion.open .acc-body { display: block; }

.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 12px;
}

.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; padding: 2px 0; }
.chk input { margin: 0; }

.grp {
  margin-bottom: 12px; padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.grp:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.grphead {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  font-weight: 600; font-size: 13px; margin-bottom: 4px;
}
.grphead input { margin: 0; }
.grphead.sub { font-weight: 500; font-size: 12.5px; color: var(--text-dim); margin: 0; }
.grp > .grid, .grp > .grid.kids, .grp > .art-rows { padding-left: 22px; }

/* Hunter Arts: one row per base art. Single-level arts are a plain checkbox; leveled
   arts (I/II/III) lay their levels out horizontally in the same row, so a weapon with
   an odd count of arts never leaves a lone item stranded on its own row like a
   wrapping grid would. */
.art-rows { display: flex; flex-direction: column; }
.art-row { display: flex; align-items: center; gap: 14px; padding: 3px 0; flex-wrap: wrap; }
.art-row .grphead.sub { flex: 0 0 auto; min-width: 150px; }
.art-row-levels { display: flex; gap: 12px; align-items: center; }
.art-row-levels .chk { padding: 0; }

#rankGroups { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }

.cmd-row {
  display: flex; align-items: flex-start; gap: 6px; margin-bottom: 8px;
}
.cmd-row code {
  flex: 1; min-width: 0; word-break: break-all;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 7px; font-family: ui-monospace, Consolas, monospace; font-size: 11.5px;
}
.cmd-row button { flex-shrink: 0; }
.cmd-desc { font-size: 11.5px; color: var(--text-dim); margin: -4px 0 10px; line-height: 1.4; }
.cmd-desc code { font-size: 11px; background: var(--bg); border-radius: 3px; padding: 0 3px; }

.bl-row, .row-gap-wrap {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap;
}
.bl-row select, .row-gap-wrap select, #chSelect { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 4px 6px; font-size: 13px; }
.bl-list { margin-top: 8px; }
.bl-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 8px; margin-bottom: 4px; font-size: 13px;
}
.bl-item button { background: transparent; border: none; color: var(--danger); cursor: pointer; font-size: 13px; }

/* Challenges: an editable version of the same tag-row pattern (inline text/number
   instead of a static label), matching the main site's .bl-tag/.ch-edit-* look. */
.ch-add { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.ch-add input[type="text"] {
  flex: 1; min-width: 120px; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; font-size: 13px; font-family: inherit;
}
.ch-add input[type="number"], #challengeCount {
  background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 4px; padding: 4px 6px; font-size: 13px;
}
.bl-tag {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 10px; margin-bottom: 4px; font-size: 13px;
}
.bl-tag button { background: transparent; border: none; color: var(--text-dim); cursor: pointer; font-size: 16px; padding: 0 2px; line-height: 1; flex-shrink: 0; font-family: inherit; }
.bl-tag button:hover { color: var(--danger); }
.ch-edit-text, .ch-edit-chance {
  border: 1px solid transparent; border-radius: 5px; padding: 2px 5px; font-size: 12px;
  font-family: inherit; background: transparent; color: var(--text);
}
.ch-edit-text { flex: 1; min-width: 0; }
.ch-edit-chance { width: 46px; text-align: center; }
.ch-edit-text:hover, .ch-edit-text:focus, .ch-edit-chance:hover, .ch-edit-chance:focus { outline: none; border-color: var(--line); }
.ch-pct { font-size: 12px; opacity: .7; flex-shrink: 0; }

#resultBox {
  white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; font-family: ui-monospace, Consolas, monospace; font-size: 13px;
  margin-top: 8px;
}

.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.status { font-size: 13px; }
.status.ok { color: #6fd88a; }
.status.err { color: var(--danger); }

#loginGate { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; }

/* App shell: a scrollable filters area next to a fixed side column (Preview/Save/
   result), inside the flex column body — .main-scroll is the only thing on the page
   that ever scrolls. Since the page itself never scrolls, .action-col needs no sticky
   positioning at all — it simply isn't in a scrolling context to begin with. */
.app-shell { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.app-body {
  flex: 1; min-height: 0; display: flex; gap: 16px; padding: 16px;
  max-width: 1200px; margin: 0 auto; width: 100%;
}
.main-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.main-scroll-inner { max-width: 900px; margin: 0 auto; }
.action-col { width: 260px; flex-shrink: 0; align-self: flex-start; max-height: 100%; overflow-y: auto; }
.action-col .actions { flex-direction: column; align-items: stretch; }

@media (max-width: 820px) {
  .app-body { flex-direction: column; overflow-y: auto; }
  .main-scroll { overflow-y: visible; }
  .action-col { width: auto; max-height: none; overflow-y: visible; }
}

.hidden { display: none !important; }

/* Modals — bot commands / export-import / help — matching the main app's pattern. */
.modal {
  position: fixed; inset: 0; background: #000000a8;
  display: flex; align-items: center; justify-content: center; z-index: 20;
}
.modal-card {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 22px; width: min(480px, 90vw); max-height: 85vh; overflow-y: auto;
  background-color: var(--bg2);
  background-image:
    linear-gradient(color-mix(in srgb, var(--bg2) 84%, transparent), color-mix(in srgb, var(--bg2) 84%, transparent)),
    url('assets/rockyTextureDark2.png');
  background-repeat: repeat; background-size: auto, 200px 200px;
}
.modal-card h2 { margin: 0 0 16px; font-size: 18px; }
.modal-card .muted { margin-bottom: 10px; }
.row { display: flex; align-items: center; }
.row.gap { gap: 8px; }
.row.end { justify-content: flex-end; }
