/* Qijisi resonance guide builder v5: six-step editor, searchable libraries and mobile full-screen flow. */
.resonance-builder-dialog .resonance-builder-shell,
body.resonance-builder-standalone .resonance-builder-shell {
  --rb-ink: #17364b;
  --rb-muted: #617b8a;
  --rb-line: rgba(36, 91, 105, .16);
  --rb-teal: #116f70;
  --rb-teal-soft: #dff1ec;
  --rb-gold: #ae7629;
  --rb-paper: #f7faf7;
  --rb-blue: #eaf5fa;
  color: var(--rb-ink);
}

.resonance-builder-dialog .rb-steps,
body.resonance-builder-standalone .rb-steps {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.rb-set-planner,
.rb-precise-equipment,
.rb-combat-block {
  margin-top: 18px;
  border: 1px solid var(--rb-line);
  background: rgba(255,255,255,.72);
}

.rb-set-planner > header,
.rb-combat-block > header,
.rb-jade-choice > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px;
}

.rb-set-planner header small,
.rb-combat-block header small,
.rb-jade-choice header small {
  display: block;
  color: var(--rb-teal);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
}

.rb-set-planner h4,
.rb-combat-block h4,
.rb-jade-choice h4 {
  margin: 4px 0 5px;
  font-size: 20px;
}

.rb-set-planner p,
.rb-combat-block p,
.rb-jade-choice p {
  margin: 0;
  color: var(--rb-muted);
  line-height: 1.65;
}

.rb-set-planner button,
.rb-combat-block header button,
.rb-jade-choice header button,
.rb-open-library,
.rb-selected-flow button,
.rb-selected-jade button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(17,111,112,.24);
  border-radius: 999px;
  background: #fff;
  color: var(--rb-teal);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.rb-set-plan-list { border-top: 1px solid var(--rb-line); }
.rb-set-plan-row {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) minmax(118px, 160px) 42px;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--rb-line);
}
.rb-set-plan-row:last-child { border-bottom: 0; }
.rb-set-plan-row > div { min-width: 0; }
.rb-set-plan-row > div small,
.rb-set-plan-row > div strong,
.rb-set-plan-row > div span { display: block; }
.rb-set-plan-row > div small { color: var(--rb-teal); font-weight: 800; }
.rb-set-plan-row > div strong { margin: 3px 0; font-size: 18px; }
.rb-set-plan-row > div span { color: var(--rb-muted); font-size: 13px; line-height: 1.55; }
.rb-set-plan-row label { min-width: 0; color: var(--rb-muted); font-size: 12px; }
.rb-set-plan-row input,
.rb-equipment-control-grid input,
.rb-combo-list input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  height: 42px;
  margin-top: 6px;
  border: 1px solid var(--rb-line);
  border-radius: 8px;
  background: #fff;
  color: var(--rb-ink);
  padding: 0 12px;
  font: inherit;
}
.rb-set-plan-row > button:last-child { width: 38px; min-height: 38px; padding: 0; font-size: 22px; }
.rb-set-plan-icon { width: 70px; height: 70px; border-radius: 12px; }

.rb-inline-empty {
  margin: 0;
  padding: 18px 20px;
  color: var(--rb-muted);
  line-height: 1.65;
}

.rb-precise-equipment > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  cursor: pointer;
  list-style: none;
}
.rb-precise-equipment > summary::-webkit-details-marker { display: none; }
.rb-precise-equipment > summary span b,
.rb-precise-equipment > summary span small { display: block; }
.rb-precise-equipment > summary span small { margin-top: 4px; color: var(--rb-muted); }
.rb-precise-equipment > summary em { color: var(--rb-teal); font-style: normal; font-weight: 800; }
.rb-precise-body { padding: 0 20px 20px; border-top: 1px solid var(--rb-line); }
.rb-open-library { display: block; margin: 16px 0; background: var(--rb-teal); color: #fff; }

.rb-equipment-settings { border: 1px solid var(--rb-line); background: var(--rb-paper); }
.rb-equipment-settings > header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--rb-line);
}
.rb-equipment-settings > header > div { display: flex; gap: 14px; min-width: 0; }
.rb-equipment-settings > header span { min-width: 0; }
.rb-equipment-settings > header small,
.rb-equipment-settings > header h4,
.rb-equipment-settings > header p { display: block; margin: 0; }
.rb-equipment-settings > header small { color: var(--rb-teal); font-weight: 800; }
.rb-equipment-settings > header h4 { margin: 4px 0; font-size: 20px; }
.rb-equipment-settings > header p { color: var(--rb-muted); }
.rb-equipment-settings > header > button { align-self: flex-start; border: 0; background: transparent; color: #a94c45; cursor: pointer; }
.rb-current-equipment-image { width: 72px; height: 72px; flex: 0 0 72px; border-radius: 12px; }
.rb-equipment-control-grid { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 16px; padding: 18px; }
.rb-equipment-control-grid > * { min-width: 0; }
.rb-equipment-control-grid fieldset { margin: 0; min-width: 0; border: 1px solid var(--rb-line); }
.rb-level-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.rb-level-buttons button { min-width: 0; min-height: 38px; border: 1px solid var(--rb-line); background: #fff; color: var(--rb-ink); cursor: pointer; }
.rb-level-buttons button.active { border-color: var(--rb-teal); background: var(--rb-teal); color: #fff; }

.rb-selected-flow,
.rb-selected-jade {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 18px 18px;
  padding: 15px;
  border: 1px solid var(--rb-line);
  background: #fff;
}
.rb-selected-flow > div,
.rb-selected-jade > span { min-width: 0; flex: 1; }
.rb-selected-flow small,
.rb-selected-flow strong,
.rb-selected-flow span,
.rb-selected-jade strong,
.rb-selected-jade small { display: block; }
.rb-selected-flow small { color: var(--rb-teal); font-weight: 800; }
.rb-selected-flow span,
.rb-selected-jade small { margin-top: 4px; color: var(--rb-muted); line-height: 1.55; }
.rb-jade-choice { margin: 0 18px 18px; border: 1px solid rgba(174,118,41,.25); background: #fffaf0; }
.rb-jade-choice > header button.active { background: var(--rb-gold); border-color: var(--rb-gold); color: #fff; }
.rb-jade-image { width: 58px; height: 58px; flex: 0 0 58px; border-radius: 50%; background: #163f49; }
.rb-jade-rules {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 18px 18px;
}
.rb-jade-rules span { padding: 10px 12px; border-left: 3px solid var(--rb-gold); background: rgba(255,255,255,.86); color: var(--rb-muted); font-size: 12px; line-height: 1.5; }

.rb-combat-block { margin-bottom: 18px; }
.rb-chip-grid,
.rb-team-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 0 20px 20px; }
.rb-chip-grid article,
.rb-team-grid article { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 12px; border: 1px solid var(--rb-line); background: #fff; }
.rb-chip-grid article strong,
.rb-team-grid article > div { min-width: 0; flex: 1; }
.rb-chip-grid article > button,
.rb-team-grid article > button { border: 0; background: transparent; color: #a94c45; font-size: 20px; cursor: pointer; }
.rb-chip-icon,
.rb-team-icon { width: 52px; height: 52px; flex: 0 0 52px; border-radius: 50%; }
.rb-team-grid strong,
.rb-team-grid small,
.rb-team-grid label { display: block; }
.rb-team-grid small { color: var(--rb-muted); }
.rb-team-grid label { margin-top: 6px; color: var(--rb-teal); font-size: 12px; line-height: 1.45; }

.rb-combo-list { padding: 0 20px 20px; }
.rb-combo-list article { display: grid; grid-template-columns: 42px 58px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--rb-line); }
.rb-combo-order { color: var(--rb-gold); font-weight: 900; letter-spacing: .08em; }
.rb-combo-icon { width: 58px; height: 58px; border-radius: 50%; background: #183f4d; }
.rb-combo-list article > div { min-width: 0; }
.rb-combo-actions { display: flex; gap: 5px; }
.rb-combo-actions button { width: 34px; min-height: 34px; border: 1px solid var(--rb-line); background: #fff; color: var(--rb-ink); cursor: pointer; }
.rb-combo-notes { display: block; padding: 0 20px 20px; }
.rb-combo-notes span { display: block; margin-bottom: 7px; font-weight: 800; }
.rb-combo-notes textarea { box-sizing: border-box; width: 100%; min-width: 0; resize: vertical; border: 1px solid var(--rb-line); background: #fff; padding: 12px; font: inherit; color: var(--rb-ink); }

.rb-picker-layer {
  position: fixed;
  z-index: 2147481200;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 34, 43, .66);
  backdrop-filter: blur(10px);
}
.rb-picker-card-shell { display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto; width: min(1040px, calc(100vw - 48px)); height: min(780px, calc(100dvh - 48px)); overflow: hidden; border: 1px solid rgba(255,255,255,.5); background: #f4f8f5; box-shadow: 0 30px 90px rgba(0,31,39,.34); }
.rb-picker-card-shell > header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 24px; border-bottom: 1px solid var(--rb-line); }
.rb-picker-card-shell > header small { color: var(--rb-teal); font-size: 11px; font-weight: 900; letter-spacing: .15em; }
.rb-picker-card-shell > header h3 { margin: 4px 0 0; font-size: 26px; }
.rb-picker-card-shell > header button { width: 44px; height: 44px; border: 1px solid var(--rb-line); border-radius: 50%; background: #fff; color: var(--rb-ink); font-size: 25px; cursor: pointer; }
.rb-picker-tabs { display: flex; gap: 8px; padding: 14px 24px 0; overflow-x: auto; scrollbar-width: none; }
.rb-picker-tabs::-webkit-scrollbar { display: none; }
.rb-picker-tabs button { flex: 0 0 auto; min-height: 38px; padding: 0 18px; border: 1px solid var(--rb-line); border-radius: 999px; background: #fff; color: var(--rb-muted); font: inherit; font-weight: 800; cursor: pointer; }
.rb-picker-tabs button.active { background: var(--rb-teal); border-color: var(--rb-teal); color: #fff; }
.rb-picker-search { display: flex; align-items: center; gap: 12px; margin: 14px 24px; padding: 0 16px; min-height: 48px; border: 1px solid var(--rb-line); background: #fff; }
.rb-picker-search span { color: var(--rb-teal); font-weight: 900; }
.rb-picker-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--rb-ink); font: inherit; }
.rb-picker-empty-action { margin: 0 24px 12px; min-height: 42px; border: 1px dashed var(--rb-gold); background: #fffaf0; color: var(--rb-gold); font-weight: 800; cursor: pointer; }
.rb-picker-results { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-content: start; gap: 10px; min-height: 0; overflow-y: auto; padding: 0 24px 22px; }
.rb-picker-card { display: grid; grid-template-columns: 64px minmax(0, 1fr) 28px; align-items: center; gap: 12px; min-width: 0; min-height: 88px; padding: 11px; border: 1px solid var(--rb-line); background: #fff; color: var(--rb-ink); text-align: left; cursor: pointer; }
.rb-picker-card.active { border-color: var(--rb-teal); box-shadow: inset 3px 0 var(--rb-teal); }
.rb-picker-card > span { min-width: 0; }
.rb-picker-card b,
.rb-picker-card small { display: block; }
.rb-picker-card small { margin-top: 4px; color: var(--rb-muted); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.rb-picker-card > i { color: var(--rb-teal); font-size: 20px; font-style: normal; }
.rb-picker-icon { width: 64px; height: 64px; border-radius: 12px; }
.rb-picker-card.is-jade { grid-template-columns: 68px minmax(0, 1fr); align-items: start; }
.rb-picker-card.is-jade > i { display: none; }
.rb-picker-jade-meta { margin-top: 7px; }
.rb-picker-jade-meta span { display: block; margin-top: 3px; color: var(--rb-muted); font-size: 12px; line-height: 1.5; }
.rb-picker-jade-meta b { color: var(--rb-teal); }
.rb-picker-empty { grid-column: 1 / -1; padding: 50px 20px; text-align: center; color: var(--rb-muted); }
.rb-picker-card-shell > footer { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 15px 24px; border-top: 1px solid var(--rb-line); background: rgba(255,255,255,.84); }
.rb-picker-card-shell > footer span { color: var(--rb-muted); font-size: 13px; }
.rb-picker-card-shell > footer button { min-height: 42px; padding: 0 24px; border: 0; border-radius: 999px; background: var(--rb-teal); color: #fff; font: inherit; font-weight: 900; cursor: pointer; }

.rb-sheet-set-plan { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.rb-sheet-set-plan article { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; align-items: center; padding: 12px; background: rgba(255,255,255,.76); }
.rb-sheet-set-plan article > div { min-width: 0; }
.rb-sheet-set-plan h5,
.rb-sheet-set-plan p { margin: 0; }
.rb-sheet-set-plan span { color: var(--rb-teal); font-size: 11px; font-weight: 800; }
.rb-sheet-set-plan p { margin-top: 4px; color: var(--rb-muted); font-size: 12px; line-height: 1.45; }
.rb-sheet-set-icon { width: 64px; height: 64px; border-radius: 50%; background: #183f4d; }
.rb-sheet-equipment-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.rb-sheet-equipment { min-width: 0; padding: 10px; background: rgba(255,255,255,.76); }
.rb-sheet-equipment h5,
.rb-sheet-equipment p,
.rb-sheet-equipment em { display: block; margin: 5px 0 0; overflow-wrap: anywhere; }
.rb-sheet-equipment > span { color: var(--rb-muted); font-size: 11px; }
.rb-sheet-equipment p,
.rb-sheet-equipment em { color: var(--rb-muted); font-size: 11px; line-height: 1.4; font-style: normal; }
.rb-sheet-equipment-image { width: 100%; aspect-ratio: 1; }
.rb-sheet-jade { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--rb-line); color: var(--rb-teal); font-size: 11px; line-height: 1.45; }
.rb-sheet-jade-image { display: inline-flex; width: 30px; height: 30px; margin-right: 5px; vertical-align: middle; border-radius: 50%; background: #183f4d; }
.rb-sheet-jade-detail { display: block; margin-top: 5px; color: var(--rb-muted); }
.rb-sheet-combat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.rb-sheet-round-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.rb-sheet-round-grid figure { width: 76px; margin: 0; text-align: center; }
.rb-sheet-round-icon { width: 58px; height: 58px; margin: 0 auto; border-radius: 50%; }
.rb-sheet-round-grid figcaption { margin-top: 5px; font-size: 12px; }
.rb-sheet-round-grid small { display: block; color: var(--rb-gold); }
.rb-sheet-combo { margin-top: 18px; }
.rb-sheet-combo > article { display: grid; grid-template-columns: 34px 48px minmax(0, 1fr); gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--rb-line); }
.rb-sheet-combo-icon { width: 48px; height: 48px; border-radius: 50%; background: #183f4d; }
.rb-sheet-combo p { margin: 3px 0 0; color: var(--rb-muted); font-size: 12px; }
.rb-sheet-combo blockquote { margin: 14px 0 0; padding: 12px 15px; border-left: 3px solid var(--rb-gold); background: rgba(255,255,255,.72); color: var(--rb-muted); }

@media (max-width: 980px) {
  .rb-picker-results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rb-sheet-equipment-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  html:has(.resonance-builder-dialog[open]),
  body:has(.resonance-builder-dialog[open]) { overflow: hidden; }
  body.resonance-builder-standalone { width: 100%; min-width: 0; overflow-x: hidden; }
  .resonance-builder-dialog,
  body.resonance-builder-standalone .resonance-builder-dialog { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0; }
  .resonance-builder-dialog .resonance-builder-shell,
  body.resonance-builder-standalone .resonance-builder-shell { box-sizing: border-box; width: 100%; max-width: none; min-width: 0; min-height: 100dvh; height: 100dvh; border: 0; }
  .resonance-builder-dialog .rb-header,
  body.resonance-builder-standalone .rb-header { width: 100%; box-sizing: border-box; padding: max(14px, env(safe-area-inset-top)) 18px 13px; }
  .rb-header h2 { font-size: clamp(20px, 6vw, 27px); }
  .rb-header-actions > span { display: none; }
  .resonance-builder-dialog .rb-steps,
  body.resonance-builder-standalone .rb-steps { display: grid; grid-template-columns: repeat(6, minmax(76px, 1fr)); width: 100%; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
  .rb-steps::-webkit-scrollbar { display: none; }
  .rb-steps button { min-width: 76px; padding-inline: 8px; white-space: nowrap; }
  .resonance-builder-dialog .rb-layout,
  body.resonance-builder-standalone .rb-layout { width: 100%; min-width: 0; overflow-x: hidden; }
  .rb-layout > main { width: 100%; min-width: 0; padding: 18px 14px 118px; }
  .rb-panel,
  .rb-panel-heading,
  .rb-set-planner,
  .rb-precise-equipment,
  .rb-combat-block { min-width: 0; max-width: 100%; }
  .rb-panel-heading { display: block; }
  .rb-panel-heading > p { width: auto; max-width: none; margin-top: 10px; }
  .rb-set-planner > header,
  .rb-combat-block > header,
  .rb-jade-choice > header { display: block; padding: 16px; }
  .rb-set-planner > header button,
  .rb-combat-block > header button,
  .rb-jade-choice > header button { width: 100%; margin-top: 13px; }
  .rb-set-plan-row { grid-template-columns: 56px minmax(0, 1fr) 40px; gap: 11px; padding: 14px; }
  .rb-set-plan-icon { width: 56px; height: 56px; }
  .rb-set-plan-row label { grid-column: 2 / 4; display: grid; grid-template-columns: 1fr minmax(88px, 126px); align-items: center; gap: 8px; width: 100%; }
  .rb-set-plan-row label input { margin: 0; }
  .rb-set-plan-row > button:last-child { grid-column: 3; grid-row: 1; }
  .rb-precise-body { padding: 0 14px 16px; }
  .rb-slot-strip { display: grid; grid-template-columns: repeat(5, minmax(72px, 1fr)); overflow-x: auto; width: 100%; }
  .rb-slot-strip button { min-width: 72px; }
  .rb-equipment-settings > header { padding: 14px; }
  .rb-current-equipment-image { width: 56px; height: 56px; flex-basis: 56px; }
  .rb-equipment-control-grid { grid-template-columns: minmax(0, 1fr); padding: 14px; }
  .rb-level-buttons { width: 100%; }
  .rb-selected-flow,
  .rb-selected-jade { flex-wrap: wrap; margin: 0 14px 14px; }
  .rb-selected-flow > div,
  .rb-selected-jade > span { flex-basis: calc(100% - 72px); }
  .rb-selected-flow button,
  .rb-selected-jade button { flex: 1 1 auto; }
  .rb-jade-choice { margin: 0 14px 14px; }
  .rb-jade-rules { grid-template-columns: 1fr; margin: 0 14px 14px; }
  .rb-chip-grid,
  .rb-team-grid { grid-template-columns: 1fr; padding: 0 14px 16px; }
  .rb-combo-list { padding: 0 14px 16px; }
  .rb-combo-list article { grid-template-columns: 30px 48px minmax(0, 1fr); }
  .rb-combo-icon { width: 48px; height: 48px; }
  .rb-combo-actions { grid-column: 2 / 4; justify-content: flex-end; }
  .rb-combo-notes { padding: 0 14px 16px; }
  .rb-picker-layer { place-items: stretch; padding: 0; }
  .rb-picker-card-shell { width: 100vw; height: 100dvh; max-width: none; max-height: none; }
  .rb-picker-card-shell > header { padding: max(14px, env(safe-area-inset-top)) 16px 13px; }
  .rb-picker-card-shell > header h3 { font-size: 22px; }
  .rb-picker-tabs { padding: 11px 14px 0; }
  .rb-picker-search { margin: 11px 14px; }
  .rb-picker-empty-action { margin: 0 14px 10px; }
  .rb-picker-results { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 0 14px 94px; }
  .rb-picker-card { grid-template-columns: 58px minmax(0, 1fr) 24px; min-height: 80px; }
  .rb-picker-icon { width: 58px; height: 58px; }
  .rb-picker-card-shell > footer { position: fixed; z-index: 2; right: 0; bottom: 0; left: 0; padding: 12px 14px max(12px, env(safe-area-inset-bottom)); }
  .rb-picker-card-shell > footer span { display: none; }
  .rb-picker-card-shell > footer button { width: 100%; }
  .rb-sheet-set-plan,
  .rb-sheet-equipment-grid,
  .rb-sheet-combat-grid { grid-template-columns: minmax(0, 1fr); }
  .rb-sheet-equipment { display: grid; grid-template-columns: 76px minmax(0, 1fr); column-gap: 12px; }
  .rb-sheet-equipment-image { grid-row: 1 / span 6; width: 76px; height: 76px; }
  .rb-sheet-jade { grid-column: 2; }
  .resonance-builder-dialog .rb-footer,
  body.resonance-builder-standalone .rb-footer { box-sizing: border-box; width: 100%; gap: 8px; padding: 11px 14px max(11px, env(safe-area-inset-bottom)); }
  .rb-footer > p { display: none; }
  .rb-footer > div { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); width: 100%; gap: 8px; }
  .rb-footer button { width: 100%; min-width: 0; padding-inline: 10px; }
}
