/* ============================================================
   Skyblock Slayer Calculator — style.css
   Theme: "Meadow Ledger" — a bright, relaxed farm-journal feel
   for tracking slayer drops. Soft sage paper, honey and sky-blue
   accents, big soft-shadow cards instead of hairline boxes.
   Numbers stay precise (mono, tabular) even as everything around
   them softens up.
   ============================================================ */

/* ----------------------------------------------------------
   CSS Custom Properties
   ---------------------------------------------------------- */
:root {
  --color-bg:            #f3f6ef;
  --color-surface:       #ffffff;
  --color-surface-raised:#ffffff;
  --color-border:        #e3e9da;
  --color-border-bright: #cfe0c2;

  --color-text:          #2e3527;
  --color-text-muted:    #71795f;
  --color-text-dim:      #a7ae97;

  --color-accent:        #e8a23d;
  --color-accent-glow:   rgba(232, 162, 61, 0.16);
  --color-accent-hover:  #f2b65c;
  --color-accent-ink:    #3a2308;
  --color-accent-deep:   #ab6f22;

  --color-accent-2:      #57aec8;
  --color-accent-2-glow: rgba(87, 174, 200, 0.16);

  --color-success:       #5fa864;
  --color-success-glow:  rgba(95, 168, 100, 0.14);
  --color-danger:        #e0705f;
  --color-danger-glow:   rgba(224, 112, 95, 0.14);

  --type-enemy:          #e8a23d;
  --type-mission:        #57aec8;
  --type-other:          #cf7ea3;

  --color-header-bg:     #fbfaf2;
  --color-tab-bg:        #ebeee0;
  --color-tab-active-bg: #ffffff;
  --color-tab-hover-bg:  #f4f5ea;

  --header-height:       64px;
  --tab-height:          44px;
  --sticky-top:          calc(var(--header-height) + var(--tab-height));

  --font-display:        'Fraunces', serif;
  --font-body:           'Quicksand', system-ui, sans-serif;
  --font-mono:           'JetBrains Mono', monospace;

  --radius-sm:           10px;
  --radius-md:           16px;
  --radius-lg:           22px;

  --shadow-card:         0 1px 3px rgba(46, 53, 39, 0.05), 0 8px 20px rgba(46, 53, 39, 0.055);
  --shadow-card-hover:   0 2px 6px rgba(46, 53, 39, 0.06), 0 12px 28px rgba(46, 53, 39, 0.08);
  --shadow-pop:          0 20px 55px rgba(46, 53, 39, 0.16);

  --color-well:          #f4f6ec;
}

/* ----------------------------------------------------------
   Reset & Base
   ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background:
    radial-gradient(ellipse 800px 480px at 8% -8%, rgba(232, 162, 61, 0.10), transparent 60%),
    radial-gradient(ellipse 700px 460px at 100% 10%, rgba(87, 174, 200, 0.09), transparent 55%),
    radial-gradient(ellipse 900px 600px at 50% 120%, rgba(207, 126, 163, 0.06), transparent 60%),
    var(--color-bg);
  background-attachment: fixed;
  color: var(--color-text);
  min-height: 100vh;
  line-height: 1.6;
  font-weight: 500;
  transition: background 0.3s, color 0.3s;
  -webkit-font-smoothing: antialiased;
}

button  { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
ul { list-style: none; }

/* ----------------------------------------------------------
   Sticky Header
   ---------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--color-header-bg);
  border-bottom: 1px solid var(--color-border);
  transition: background 0.3s, border-color 0.3s;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 1.25rem;
  gap: 1rem;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-shrink: 0;
}

.game-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-accent-deep);
  letter-spacing: 0.01em;
}

.header-subtitle {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  font-weight: 400;
}

.live-price-status {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  padding: 0.5rem 0.9rem;
  margin-bottom: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 6px);
  color: var(--color-text-muted);
  background: var(--color-surface, transparent);
}

.live-price-status.is-ok {
  color: var(--color-text-muted);
}

.live-price-status.is-error {
  color: var(--color-danger);
  border-color: var(--color-danger);
}

/* ------------------------------------------------------------------------
   Item detail popup — opened by clicking any item name in the Calculator,
   RNG Meter, or Simulate tabs. Shows the resolved price, its source, and
   whatever bazaar/AH stats the price service returned for it.
   ---------------------------------------------------------------------- */
.is-item-name {
  cursor: pointer;
}

.is-item-name:hover {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-color: var(--color-border-bright);
}

.item-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

/* The [hidden] attribute normally just sets display:none, but that has the
   same specificity as the display:flex rule above, so without this explicit
   override the popup could render (position:fixed and all) even while
   `hidden` is true — this guarantees `hidden` always wins. */
.item-popup-overlay[hidden] {
  display: none;
}

.item-popup-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--color-surface-raised, var(--color-surface));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg, 12px);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow-pop);
}

.item-popup-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.item-popup-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
}

.item-popup-subtitle {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  margin-top: 0.2rem;
}

.item-popup-close {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm, 4px);
  flex-shrink: 0;
}

.item-popup-close:hover {
  color: var(--color-text);
  background: var(--color-well);
}

.item-popup-price-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0.7rem 0.9rem;
  background: var(--color-well);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 8px);
  margin-bottom: 0.9rem;
}

.item-popup-price-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-accent);
  font-variant-numeric: tabular-nums;
}

.item-popup-price-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
}

.item-popup-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.item-popup-stat-cell {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.5rem 0.7rem;
  background: var(--color-well);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 6px);
  transition: background 0.12s, border-color 0.12s;
}

.item-popup-stat-cell.is-active-price {
  background: var(--color-accent-glow);
  border-color: var(--color-accent);
}

.item-popup-stat-cell.is-active-price .item-popup-stat-cell-label {
  color: var(--color-accent-deep);
  font-weight: 700;
}

.item-popup-stat-cell-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
}

.item-popup-stat-cell-value {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.item-popup-note {
  font-size: 0.76rem;
  color: var(--color-text-muted);
  margin-top: 0.8rem;
  line-height: 1.4;
}

/* ── Price-basis control (item popup) ── */
.price-mode-control {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--color-border);
}

.price-mode-btn-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.45rem;
}

.price-mode-btn {
  flex: 1;
  background: var(--color-well);
  border: 1.5px solid var(--color-border);
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.45rem 0.6rem;
  border-radius: 999px;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.price-mode-btn:not(:disabled):hover {
  border-color: var(--color-accent);
  color: var(--color-accent-deep);
}

.price-mode-btn.is-active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-accent-ink);
}

.price-mode-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ── Advanced-mode price-basis notation tag (stat tables + RNG Meter header) ── */
.price-mode-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-success);
  background: var(--color-success-glow);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
  vertical-align: middle;
}

.price-mode-tag--buy {
  color: var(--color-danger);
  background: var(--color-danger-glow);
}

/* ── Global price-basis note under the Calculator input row ── */
.price-mode-note {
  margin: -0.5rem 0 1rem;
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: 0.78rem;
  line-height: 1.5;
}

.price-mode-note strong {
  color: var(--color-text);
}

/* ── Craft Flip tab — spacing between each item's flip breakdown ── */
.craft-flip-divider {
  height: 1.25rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* ── Advanced mode toggle switch ── */
.mode-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-right: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.mode-toggle-text {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.mode-toggle input[type="checkbox"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.mode-toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--color-bg);
  border: 1px solid var(--color-border-bright);
  border-radius: 999px;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.mode-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-text-muted);
  transition: transform 0.15s, background 0.15s;
}

.mode-toggle input:checked + .mode-toggle-track {
  background: var(--color-accent-glow);
  border-color: var(--color-accent);
}

.mode-toggle input:checked + .mode-toggle-track .mode-toggle-thumb {
  transform: translateX(16px);
  background: var(--color-accent);
}

.mode-toggle input:focus-visible + .mode-toggle-track {
  box-shadow: 0 0 0 3px var(--color-accent-glow);
}

.mode-toggle:hover .mode-toggle-text {
  color: var(--color-text);
}

/* Toolbar buttons */
.toolbar-btn {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  color: var(--color-text);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  letter-spacing: 0.01em;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.toolbar-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent-deep);
  background: var(--color-accent-glow);
}

.toolbar-btn--danger:hover {
  border-color: var(--color-danger);
  color: var(--color-danger);
  background: var(--color-danger-glow);
}

/* Overall progress bar — runs along the bottom of the header */
.progress-bar-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-border);
}

.progress-bar-fill {
  height: 100%;
  background: var(--color-accent);
  width: 0%;
  transition: width 0.5s ease;
}

/* Floating progress label (no longer inside the bar wrap) */
.progress-label-float {
  position: absolute;
  bottom: 6px;
  right: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ----------------------------------------------------------
   Tab Navigation — a rounded capsule bar; the active tab floats
   as its own white pill rather than an underline indicator.
   ---------------------------------------------------------- */
.tab-nav {
  position: sticky;
  top: var(--header-height);
  z-index: 90;
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  background: var(--color-tab-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 0.4rem 1rem;
  scrollbar-width: none;
  transition: background 0.3s;
}

.tab-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  flex: 0 0 auto;
  padding: 0 1.1rem;
  height: calc(var(--tab-height) - 0.8rem);
  background: transparent;
  border: none;
  border-radius: 999px;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}

.tab-btn:hover {
  color: var(--color-text);
  background: var(--color-tab-hover-bg);
}

.tab-btn.active {
  color: var(--color-accent-deep);
  background: var(--color-tab-active-bg);
  box-shadow: var(--shadow-card);
}

.tab-btn--disabled {
  opacity: 0.4;
  pointer-events: none;
  text-decoration: line-through;
}

.tab-btn .tab-count {
  display: inline-block;
  margin-left: 0.3em;
  font-size: 0.68rem;
  font-family: var(--font-mono);
  opacity: 0.5;
}

.tab-btn.active .tab-count { opacity: 0.75; }

/* ----------------------------------------------------------
   Main Content
   ---------------------------------------------------------- */
.main-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 5rem;
}

/* Section header */
.section-header {
  margin-bottom: 1.25rem;
}

.section-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: 0.01em;
}

.section-type-badge {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border-bright);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-sm);
}

.section-progress-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.progress-bar-track {
  flex: 1;
  max-width: 260px;
  height: 4px;
  background: var(--color-border);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar-fill--section {
  height: 100%;
  background: var(--color-accent);
  border-radius: 99px;
  width: 0%;
  transition: width 0.4s ease;
}

.progress-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ----------------------------------------------------------
   Search Bar
   ---------------------------------------------------------- */
.search-row {
  margin-bottom: 0.75rem;
}

.search-input {
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border-bright);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 400;
  padding: 0.55rem 0.9rem;
  transition: border-color 0.12s, box-shadow 0.12s;
  appearance: none;
  -webkit-appearance: none;
}

.search-input::placeholder { color: var(--color-text-dim); }

.search-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-glow);
}

/* hide browser-native clear button in search inputs */
.search-input::-webkit-search-cancel-button { display: none; }

/* ----------------------------------------------------------
   Autocomplete Dropdown
   ---------------------------------------------------------- */
.ac-dropdown {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border-bright);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(46, 53, 39, 0.16);
  list-style: none;
  margin: 0;
  max-height: 240px;
  overflow-y: auto;
  padding: 0.2rem;
  z-index: 9999;
}

.ac-option {
  border-radius: 3px;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 400;
  overflow: hidden;
  padding: 0.45rem 0.65rem;
  text-overflow: ellipsis;
  transition: background 0.08s, color 0.08s;
  white-space: nowrap;
}

.ac-option:hover,
.ac-option.is-active {
  background: var(--color-accent-glow);
  color: var(--color-text);
}

/* Highlighted match portion */
mark.ac-match {
  background: transparent;
  color: var(--color-accent);
  font-weight: 700;
}

/* Item hint option at bottom of dropdown */
.ac-option.ac-hint-option {
  border-top: 1px solid var(--color-border);
  color: var(--color-text-dim);
  font-style: italic;
  margin-top: 0.2rem;
  padding-top: 0.6rem;
}

.ac-option.ac-hint-option:hover,
.ac-option.ac-hint-option.is-active {
  background: var(--color-accent-glow);
  color: var(--color-text);
}

.ac-option.ac-hint-option strong {
  font-style: normal;
  font-weight: 700;
  color: var(--type-enemy);
}

/* ----------------------------------------------------------
   Filter Row
   ---------------------------------------------------------- */
.filter-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.7rem;
  color: var(--color-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.filter-group {
  display: flex;
  gap: 0.2rem;
  margin-right: 0.6rem;
}

.filter-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}

.filter-btn:hover {
  border-color: var(--color-border-bright);
  color: var(--color-text);
}

.filter-btn.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-accent-ink);
  font-weight: 700;
}

/* ----------------------------------------------------------
   Entry List
   ---------------------------------------------------------- */
.entry-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ── entry-item: stripe on left, right column stacked ── */
.entry-item {
  display: flex;
  align-items: stretch;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  overflow: hidden;
  transition: border-color 0.12s, background 0.12s;
}

.entry-item:hover       { border-color: var(--color-border-bright); background: var(--color-surface-raised); }
.entry-item.is-expanded { border-color: var(--color-accent);        background: var(--color-surface-raised); }

/* Type color stripe */
.entry-type-stripe               { width: 3px; flex-shrink: 0; }
.entry-type-stripe--Enemy        { background: var(--type-enemy);   }
.entry-type-stripe--Mission      { background: var(--type-mission); }
.entry-type-stripe--Other        { background: var(--type-other);   }

/* Right column: row + panel stacked */
.entry-right {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Clickable row */
.entry-row {
  display: flex;
  align-items: center;
  cursor: pointer;
  min-height: 44px;
}

.entry-body {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.75rem;
  min-width: 0;
}

.entry-type-badge {
  flex-shrink: 0;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.12rem 0.4rem;
  border-radius: var(--radius-sm);
  width: 54px;
  text-align: center;
}

.entry-type-badge--Enemy   { background: rgba(217,172,84,0.14); color: var(--type-enemy);   }
.entry-type-badge--Mission { background: rgba(69,194,184,0.14); color: var(--type-mission); }
.entry-type-badge--Other   { background: rgba(207,126,163,0.14); color: var(--type-other);   }

.entry-source-name {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Logged item name */
.entry-slot {
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  font-style: italic;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-slot--filled {
  font-style: normal;
  font-weight: 600;
  color: var(--color-success);
}

.entry-slot--hint {
  font-style: italic;
  font-weight: 500;
  color: var(--type-enemy);
}

/* Completion check */
.entry-check {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--color-border-bright);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  color: transparent;
  transition: all 0.15s;
}

.is-complete .entry-check {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
}

/* Expand chevron */
.entry-chevron {
  flex-shrink: 0;
  font-size: 0.65rem;
  color: var(--color-text-dim);
  display: inline-block;
  transition: transform 0.2s ease, color 0.15s;
  margin-left: 0.1rem;
}

.entry-chevron::before { content: '›'; }

.entry-item.is-expanded .entry-chevron {
  transform: rotate(90deg);
  color: var(--color-accent);
}

/* ── Expand panel ── */
.entry-panel {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.22s ease, padding 0.22s ease;
  padding: 0 0.75rem;
  border-top: 1px solid transparent;
}

.entry-item.is-expanded .entry-panel {
  max-height: 150px;
  padding: 0.65rem 0.75rem;
  border-top-color: var(--color-border);
}

/* Tag pills row */
.entry-tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.6rem;
}

.entry-tag-pill {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--color-border);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border-bright);
  white-space: nowrap;
}

/* Log row inside panel */
.entry-log-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.entry-input {
  flex: 1;
  background: var(--color-bg);
  border: 1px solid var(--color-border-bright);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.4rem 0.65rem;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.entry-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-glow);
}

.entry-input--invalid {
  border-color: var(--color-danger) !important;
  box-shadow: 0 0 0 3px rgba(224, 112, 95, 0.2) !important;
}

.entry-save-btn {
  background: var(--color-accent);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-accent-ink);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.4rem 0.85rem;
  transition: opacity 0.12s;
  white-space: nowrap;
}
.entry-save-btn:hover { opacity: 0.85; }

.entry-clear-btn {
  background: transparent;
  border: 1px solid var(--color-border-bright);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  transition: border-color 0.12s, color 0.12s;
  white-space: nowrap;
}
.entry-clear-btn:hover {
  border-color: var(--color-danger);
  color: var(--color-danger);
}

.entry-item[hidden] { display: none; }

/* ----------------------------------------------------------
   Run Manager Modal
   ---------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop[hidden] { display: none; }

.run-modal {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border-bright);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-pop);
}

.run-page { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.run-page[hidden] { display: none; }

.modal-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.modal-title {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.modal-close,
.modal-back {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.15rem 0.35rem;
  border-radius: var(--radius-sm);
  transition: color 0.12s, background 0.12s;
}
.modal-close:hover,
.modal-back:hover {
  color: var(--color-text);
  background: var(--color-border);
}

/* ── Run list (page 1) ── */
.run-list-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.run-list-empty {
  color: var(--color-text-dim);
  font-size: 0.875rem;
  text-align: center;
  padding: 2rem 1rem;
}

.run-list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.run-list-item:hover { border-color: var(--color-border-bright); background: var(--color-surface-raised); }
.run-list-item.is-active { border-color: var(--color-accent); }

.run-list-item-info { flex: 1; min-width: 0; }

.run-list-item-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.run-list-item-meta {
  font-size: 0.72rem;
  color: var(--color-text-dim);
  margin-top: 0.1rem;
}

.run-list-item-active-badge {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.45rem;
  white-space: nowrap;
}

.run-delete-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--color-text-dim);
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  transition: border-color 0.12s, color 0.12s;
  white-space: nowrap;
}
.run-delete-btn:hover {
  border-color: var(--color-danger);
  color: var(--color-danger);
}

/* ── Setup wizard (page 2) ── */
.run-setup-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.setup-name-row {
  margin-bottom: 0.85rem;
}

.setup-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-dim);
  margin-top: 0.85rem;
  margin-bottom: 0.35rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--color-border);
}

.setup-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.2rem 0.5rem;
}

.setup-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.25rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
}
.setup-check:hover { background: var(--color-surface); }

.setup-check input[type="checkbox"] {
  accent-color: var(--color-accent);
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  cursor: pointer;
}

.setup-check span {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  line-height: 1.2;
}

/* ── Modal footer ── */
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.9rem 1.25rem;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.setup-footer { justify-content: flex-end; }

.setup-footer .btn-secondary:first-child { margin-right: auto; }

/* ----------------------------------------------------------
   Scrollbar
   ---------------------------------------------------------- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-bright); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-accent); }

/* ----------------------------------------------------------
   Utility
   ---------------------------------------------------------- */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

/* ----------------------------------------------------------
   Skyblock — Slayer Calculator
   Reuses the same tokens/components as the BL2 tracker rather
   than introducing a second visual language.
   ---------------------------------------------------------- */
.tool-panel {
  padding: 1.5rem 1.25rem;
}

.scaffold-note {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  border: 1px dashed var(--color-border-bright);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.header-subtitle {
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

/* ── Input row (Magic Find, kill count, dye toggle) ── */
.calc-input-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1rem;
}

.calc-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.calc-field .filter-label {
  white-space: nowrap;
}

.calc-number-input {
  width: 90px;
  background: var(--color-well);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.4rem 0.6rem;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.calc-number-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-glow);
}

/* ── Perk card (Aatrox perks + Pity Shard) — deliberately quieter than the
   results cards below: this is an optional settings panel, not a primary
   result, so it shouldn't compete for attention. No shadow, a soft dashed-
   free well tone, so it visually recedes under the floating result cards. ── */
.calc-card {
  background: var(--color-well);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem 1.1rem;
  margin-bottom: 1.25rem;
}

.calc-card-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-dim);
  margin-bottom: 0.6rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.calc-perk-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1.5rem;
}

/* Reuses .setup-check (checkbox + label) verbatim, no new pattern needed. */

/* ── Results containers — soft floating cards, no hairline
   border needed since the shadow does the separating work. ── */
.calc-results {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.25rem;
}

.calc-section-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--color-text);
  margin: 0 0 0.9rem;
}

.section-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
  position: relative;
}

.section-title-row .calc-section-title {
  margin-bottom: 0;
}

.info-btn {
  position: relative;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--color-border-bright);
  background: transparent;
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-style: italic;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s, border-color 0.12s;
}

.info-btn:hover, .info-btn[aria-expanded="true"] {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

.info-popover {
  position: absolute;
  z-index: 500;
  margin-top: 0.5rem;
  width: min(320px, 80vw);
  background: var(--color-surface-raised, var(--color-surface));
  border: 1px solid var(--color-border-bright);
  border-radius: var(--radius-md, 8px);
  padding: 0.8rem 0.95rem;
  box-shadow: var(--shadow-pop);
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--color-text-muted);
}

/* ── Per-item stat table ── */
.stat-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.stat-table th {
  text-align: left;
  color: var(--color-text-dim);
  font-weight: 700;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.5rem 0.7rem;
  border-bottom: 2px solid var(--color-border);
  font-family: var(--font-body);
}

.stat-table td {
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

.stat-table tbody tr:hover td {
  background: var(--color-well);
  color: var(--color-text);
}

.stat-table tfoot td {
  font-weight: 700;
  color: var(--color-accent-deep);
  border-top: 2px solid var(--color-border-bright);
  border-bottom: none;
  padding-top: 0.65rem;
}

.stat-table td.is-item-name {
  font-family: var(--font-body);
  color: var(--color-text);
  font-weight: 500;
}

/* ── Profit summary ── */
.profit-summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 2.5rem;
  margin: 1rem 0 1.25rem;
  font-family: var(--font-mono);
}

.profit-stat .filter-label {
  display: block;
  margin-bottom: 0.25rem;
}

.profit-stat-value {
  display: inline-block;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
}

.profit-stat-value.is-positive { color: var(--color-success); background: var(--color-success-glow); }
.profit-stat-value.is-negative { color: var(--color-danger); background: var(--color-danger-glow); }

.is-unsellable {
  color: var(--color-text-dim);
  font-style: italic;
  font-weight: 400;
}

/* ── Craft Flip: clickable "craft into" name + its popup breakdown ── */
.craft-flip-name-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--color-accent-deep);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.12s, color 0.12s;
}

.craft-flip-name-btn:hover {
  color: var(--color-text);
  text-decoration-color: var(--color-accent-deep);
}

.item-popup-craft-breakdown {
  list-style: none;
  margin: 0.8rem 0 0;
  padding: 0.6rem 0.75rem;
  background: var(--color-well);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 6px);
  font-size: 0.78rem;
  line-height: 1.7;
}

.item-popup-craft-breakdown li em {
  font-style: normal;
  color: var(--color-text-dim);
}

.item-popup-craft-sub {
  list-style: none;
  margin: 0.3rem 0 0.2rem 1rem;
  padding: 0.35rem 0.5rem;
  border-left: 2px solid var(--color-border-bright);
  color: var(--color-text-dim);
}

.item-popup-price-value.is-positive { color: var(--color-success); }
.item-popup-price-value.is-negative { color: var(--color-danger); }

.craft-unresolved-note {
  border: 1px solid var(--color-border-bright);
  background: var(--color-well);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
}

.craft-unresolved-note ul {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* Percentile grid */
.calc-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 0.75rem 1rem;
}

.calc-stat-cell {
  background: var(--color-well);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
}

.calc-stat-cell .filter-label {
  display: block;
  margin-bottom: 0.3rem;
  letter-spacing: 0.02em;
}

.calc-stat-cell-value {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.calc-stat-cell-value.is-positive { color: var(--color-success); }
.calc-stat-cell-value.is-negative { color: var(--color-danger); }

/* ── RNG Meter fill bar — reuses the same progress bar as section headers ── */
.rng-meter-fill-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0 1.1rem;
}

.rng-meter-fill-row .progress-bar-track {
  max-width: none;
  flex: 1;
  height: 6px;
}

.rng-meter-stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 2.5rem;
  font-family: var(--font-mono);
  margin-bottom: 0.5rem;
}

/* ── Ranked best-selection table reuses .stat-table, with a rank pill ── */
.rank-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.stat-table tr.is-top-rank .rank-pill {
  background: var(--color-accent);
  color: var(--color-accent-ink);
}

/* ── Simulate tab histogram ── */
.hist-svg {
  width: 100%;
  height: auto;
  display: block;
}

.hist-axis-label {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--color-text-dim);
}

.hist-axis-label--accent {
  fill: var(--color-accent-deep);
  font-weight: 700;
}

.hist-chart-wrap {
  position: relative;
}

.hist-bar-hitarea {
  cursor: pointer;
}

.hist-bar {
  transition: filter 0.1s ease;
  pointer-events: none; /* hitarea rect handles hover, so zero-height bars are still hoverable */
}

.hist-bar-group.is-hovered .hist-bar {
  filter: brightness(1.08) saturate(1.15);
}

.hist-tooltip {
  position: absolute;
  z-index: 10;
  pointer-events: none;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--color-text);
  box-shadow: var(--shadow-card-hover);
  white-space: nowrap;
}

.hist-tooltip-range {
  font-weight: 600;
}

.hist-tooltip-prob {
  color: var(--color-text-muted);
}

@media (max-width: 640px) {
  .calc-input-row, .calc-perk-row, .profit-summary-row, .rng-meter-stat-row {
    gap: 0.75rem;
  }
}
