/* history.css - history bar, selection mode, history dropdown, search, collection dropdown, type filter. Part of the split-up style.css; see index.html for load order. */
  /* ── HISTORY BAR ── */
  .history-bar {
    position: relative;
    z-index: 2;
    background: rgba(12, 6, 2, 0.95);
    border-bottom: 1px solid rgba(180,130,60,0.18);
    display: flex;
    align-items: stretch;
    height: 48px;
    flex-shrink: 0;
  }

  /* Fixed left label */
  .history-label {
    font-family: 'Cinzel', serif;
    font-size: medium;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #ffdeb9;
    padding: 0 0.85rem;
    display: flex;
    align-items: center;
    white-space: nowrap;
    flex-shrink: 0;
    gap: 0.4rem;
  }

  /* Scrollable track — the cards strip (formerly flanked by « Prev / Next » arrows) */
  .history-track {
    flex: 1;
    display: flex;
    align-items: stretch;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    /* Hide scrollbar visually but keep it functional */
    scrollbar-width: none;
    min-width: 0;
  }
  .history-track::-webkit-scrollbar { display: none; }

  .history-empty {
    font-family: 'Crimson Pro', serif;
    font-style: italic;
    font-size: small;
    color: #dabb80;
    padding: 0.55rem 1rem;
    display: flex;
    align-items: center;
    white-space: nowrap;
  }

  #historyItems {
    display: flex;
    align-items: stretch;
  }

  .history-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.8rem 0.4rem 0.6rem;
    border-right: 1px solid rgba(180,130,60,0.1);
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
    max-width: 300px;
    position: relative;
  }

  .history-item:hover { background: rgba(180,130,60,0.08); }
  /* Active card: gold outline "chip" highlight within the strip */
  .history-item.history-active {
    background: rgba(180,130,60,0.14);
    box-shadow: inset 0 0 0 1.5px var(--arc-gold);
    border-radius: var(--arc-r-surface);
    border-right-color: transparent;
  }
  .history-item.history-active .history-name { color: var(--gold-light); }

  /* ── SELECTION MODE (cards strip) ── */
  .bar-select-btn {
    flex-shrink: 0;
    border: none;
    border-left: 1px solid rgba(180,130,60,0.15);
    padding: 0 0.85rem;
    background: transparent;
    color: var(--arc-muted);
    font-family: var(--arc-display);
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
  }
  .bar-select-btn:hover { color: var(--arc-gold); }
  .bar-select-btn.active { color: var(--arc-gold-hi); background: rgba(180,130,60,0.12); }

  .history-track.selection-mode { background: rgba(180,130,60,0.06); }
  .history-check {
    display: none;
    width: 15px; height: 15px;
    flex-shrink: 0;
    border: 1.5px solid var(--arc-rule);
    border-radius: 50%;
    position: relative;
  }
  .history-track.selection-mode .history-check { display: inline-block; }
  .history-track.selection-mode .history-delete { display: none; }
  .history-track.selection-mode .history-item.selected .history-check {
    background: var(--arc-gold);
    border-color: var(--arc-gold);
  }
  .history-track.selection-mode .history-item.selected {
    box-shadow: inset 0 0 0 1.5px var(--arc-gold);
    border-radius: var(--arc-r-surface);
    border-right-color: transparent;
    background: rgba(180,130,60,0.14);
  }

  .history-thumb {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(180,130,60,0.3);
    flex-shrink: 0;
    background: rgba(90,60,30,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #5a3e28;
    overflow: hidden;
  }

  .history-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

  .history-meta {
    min-width: 0;
    flex: 1;
  }

  .history-name {
    font-family: 'Cinzel', serif;
    font-size: medium;
    font-weight: 700;
    color: #dabb80;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 225px;
    display: block;
  }

  .history-rarity {
    font-size: small;
    font-family: 'Crimson Pro', serif;
    font-style: italic;
    color: #6a4e2e;
    display: block;
    margin-top: 1px;
  }

  .history-delete {
    width: 16px;
    height: 16px;
    background: none;
    border: none;
    color: #4a3520;
    cursor: pointer;
    font-size: small;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
    padding: 0;
    line-height: 1;
  }

  .history-delete:hover { color: #c0392b; background: rgba(192,57,43,0.12); }

  /* ── HISTORY DROPDOWN ── */
  .history-label-wrap {
    position: relative;
    flex-shrink: 0;
    display: flex;
    align-items: stretch;
    border-right: 1px solid rgba(180,130,60,0.15);
  }

  .history-label {
    background: none;
    border: none;
    cursor: pointer;
  }

  .history-label:hover { background: rgba(180,130,60,0.07); }

  .dropdown-caret {
    font-size: 0.55rem;
    letter-spacing: -0.05em;
    opacity: 0.7;
    margin-left: 0.3rem;
    line-height: 1;
    vertical-align: middle;
  }

  .history-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 230px;
    background: rgba(12, 6, 2, 0.98);
    border: 1px solid rgba(180,130,60,0.25);
    border-top: none;
    z-index: 200;
    max-height: 320px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(180,130,60,0.2) transparent;
  }

  .history-dropdown.open { display: block; }

  .history-dropdown-empty {
    font-family: 'Crimson Pro', serif;
    font-style: italic;
    font-size: small;
    color: #6a4e2e;
    padding: 0.75rem 1rem;
  }

  .history-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(180,130,60,0.08);
    transition: background 0.12s;
  }

  .history-dropdown-new {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid rgba(180,130,60,0.15);
    cursor: pointer;
    font-family: 'Cinzel', serif;
    font-size: small;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--gold-light);
    transition: background 0.12s;
  }

  .history-dropdown-new:hover { background: rgba(180,130,60,0.1); }

  .history-dropdown-item:last-child { border-bottom: none; }
  .history-dropdown-item:hover { background: rgba(180,130,60,0.1); }
  .history-dropdown-item.history-active { background: rgba(180,130,60,0.14); }
  .history-dropdown-item.history-active .history-name { color: var(--gold-light); }

  .history-dropdown-item .history-thumb {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
  }

  .history-dropdown-item .history-name {
    max-width: 140px;
  }

  .history-dropdown-item .history-delete {
    margin-left: auto;
    flex-shrink: 0;
  }

  .history-save-btn {
    font-family: 'Cinzel', serif;
    font-size: small;

    letter-spacing: 0.1em;
    padding: 0.3rem 0.8rem;
    background: transparent;
    border: none;
    border-left: 1px solid rgba(180,130,60,0.2);
    border-radius: 0;
    color: #ffdeb9;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    text-transform: uppercase;
    flex-shrink: 0;
    align-self: stretch;
    display: flex;
    align-items: center;
  }

  .history-save-btn:hover {
    color: var(--gold-light);
    background: rgba(180,130,60,0.08);
  }

  .history-save-btn.flash {
    color: var(--gold-light);
    background: rgba(180,130,60,0.15);
  }

  /* ── HISTORY SEARCH ── */
  .history-search-wrap {
    display: flex;
    align-items: center;
    position: relative;
    padding: 0 0.5rem;
    border-left: 1px solid rgba(180,130,60,0.15);
    border-right: 1px solid rgba(180,130,60,0.15);
    align-self: stretch;
    flex-shrink: 0;
  }

  .history-search-input {
    background: transparent;
    border: 1px solid rgba(180,130,60,0.25);
    border-radius: 3px;
    color: #dabb80;
    font-family: 'Crimson Pro', serif;
    font-size: small;
    padding: 0.18rem 0.5rem;
    width: 130px;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
  }
  .history-search-input::placeholder { color: rgba(180,130,60,0.38); }
  .history-search-input:focus {
    border-color: rgba(180,130,60,0.6);
    background: rgba(180,130,60,0.05);
  }

  .history-search-clear {
    background: none;
    border: 1px solid rgba(180,130,60,0.3);
    border-radius: 3px;
    color: rgba(180,130,60,0.55);
    cursor: pointer;
    font-size: 0.7rem;
    padding: 0.15rem 0.3rem;
    margin-left: 0.5rem;
    line-height: 1;
    flex-shrink: 0;
    display: none;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
  }
  .history-search-clear.visible { display: flex; }
  .history-search-clear:hover { color: #dabb80; border-color: rgba(180,130,60,0.65); background: rgba(180,130,60,0.08); }

  /* Desktop: results drop down beneath the search box (mobile overrides below). */
  .history-search-results {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0.5rem;
    right: 0.5rem;
    min-width: 240px;
    z-index: 300;
    background: rgba(18,9,2,0.98);
    border: 1px solid var(--arc-rule);
    border-radius: var(--arc-r-control);
    max-height: 60vh;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  }
  .history-search-results.open { display: block; }
  .history-search-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.7rem;
    cursor: pointer;
    border-bottom: 1px solid var(--arc-rule-soft);
    color: var(--arc-parchment);
    font-family: 'Crimson Pro', serif;
    font-size: small;
  }
  .history-search-result-item:last-child { border-bottom: none; }
  .history-search-result-item:hover { background: rgba(180,130,60,0.1); }
  .history-search-result-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .history-search-result-meta {
    font-size: small;
    color: var(--arc-muted);
    flex-shrink: 0;
    text-transform: capitalize;
  }

  /* ── COLLECTION DROPDOWN ── */
  .collection-dropdown-divider {
    height: 1px;
    background: rgba(180,130,60,0.15);
    margin: 0.2rem 0;
  }
  .collection-dropdown-item {
    gap: 0;
    justify-content: space-between;
  }
  .collection-dd-name {
    flex: 1;
    font-family: 'Cinzel', serif;
    font-size: small;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .collection-dd-count {
    font-family: 'Crimson Pro', serif;
    font-size: small;
    color: var(--text-muted);
    margin-left: 0.5rem;
    flex-shrink: 0;
  }
  body.light .collection-dd-name { color: #2c1a0e; }

  /* ── TYPE FILTER ── */
  .history-type-filter {
    display: flex;
    align-items: stretch;
    flex-shrink: 0;
    border-left: 1px solid rgba(180,130,60,0.15);
  }
  .type-filter-btn {
    background: none;
    border: none;
    border-right: 1px solid rgba(180,130,60,0.12);
    color: rgba(210,160,70,0.5);
    font-family: 'Cinzel', serif;
    font-size: small;
    letter-spacing: 0.04em;
    padding: 0 0.55rem;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
  }
  .type-filter-btn:last-child { border-right: none; }
  .type-filter-btn.active {
    color: var(--gold-light);
    background: rgba(180,130,60,0.1);
  }
  .type-filter-btn.type-filter-disabled {
    opacity: 0.35;
    cursor: not-allowed;
  }
  .type-filter-btn:not(.type-filter-disabled):hover {
    color: var(--gold-light);
    background: rgba(180,130,60,0.07);
  }
  body.light .type-filter-btn { color: rgba(90,56,16,0.45); }
  body.light .type-filter-btn.active { color: #3a2008; background: rgba(120,80,30,0.1); }
  body.light .type-filter-btn:not(.type-filter-disabled):hover { color: #3a2008; background: rgba(120,80,30,0.07); }

