/* ── Overlay ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.open {
  display: flex;
  animation: overlayIn 0.2s ease forwards;
}

/* ── Modal shell ── */
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(520px, 90vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.modal-overlay.open .modal {
  animation: modalIn 0.2s ease forwards;
}

.modal-overlay.closing {
  display: flex;
  animation: overlayOut 0.18s ease forwards;
}

.modal-overlay.closing .modal {
  animation: modalOut 0.18s ease forwards;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.4rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

.modal-header h2 { font-size: 14px; font-weight: 600; flex: 1; min-width: 0; }

.modal-close {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  transition: color 0.1s, background 0.1s;
  flex-shrink: 0;
}

.modal-close:hover { color: var(--text); background: var(--bg3); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0.85rem 1.4rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Settings tabs nav ── */
.settings-tabs-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.settings-tab-btn {
  flex: 1;
  text-align: center;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font);
  padding: 0.65rem 0.9rem;
  margin-bottom: -1px;
  transition: color 0.1s, border-color 0.1s;
}

.settings-tab-btn:hover { color: var(--text); }

.settings-tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Settings tab panels ── */
.settings-tab-panels {
  display: grid;
  grid-template-columns: 1fr;
  overflow-x: hidden;
  overflow-y: auto;
  flex: 1;
}

.settings-tab-panel {
  grid-area: 1 / 1;
  padding: 1.1rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  z-index: 0;
}

.settings-tab-panel:not(.active) {
  visibility: hidden;
  pointer-events: none;
}

@keyframes tab-exit-left  { from { transform: translateX(0);    opacity: 1; } to { transform: translateX(-15%); opacity: 0; } }
@keyframes tab-exit-right { from { transform: translateX(0);    opacity: 1; } to { transform: translateX(15%);  opacity: 0; } }
@keyframes tab-enter-right{ from { transform: translateX(15%);  opacity: 0; } to { transform: translateX(0);    opacity: 1; } }
@keyframes tab-enter-left { from { transform: translateX(-15%); opacity: 0; } to { transform: translateX(0);    opacity: 1; } }

.settings-tab-panel.tab-exit-left   { animation: tab-exit-left   0.22s ease-in  forwards; }
.settings-tab-panel.tab-exit-right  { animation: tab-exit-right  0.22s ease-in  forwards; }
.settings-tab-panel.tab-enter-right { animation: tab-enter-right 0.22s ease-out forwards; z-index: 1; }
.settings-tab-panel.tab-enter-left  { animation: tab-enter-left  0.22s ease-out forwards; z-index: 1; }

/* ── Settings sections ── */
.settings-section { display: flex; flex-direction: column; gap: 0.75rem; }

.settings-section h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
}

.settings-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.settings-grid select {
  width: 100%;
  height: var(--control-h);
  padding: 0 28px 0 9px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s;
}

.settings-grid select:focus { outline: none; border-color: var(--accent); }

/* ── Accounts list ── */
.accounts-list { display: flex; flex-direction: column; gap: 6px; }

.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--bg3);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}

.account-row-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.account-row-name { font-size: 13px; font-weight: 500; }
.account-row-key  { font-size: 11px; color: var(--muted); font-family: monospace; }

.account-row-delete {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  transition: color 0.1s, background 0.1s;
  flex-shrink: 0;
}

.account-row-delete:hover { color: var(--red); background: var(--danger-hover-bg); }

/* ── Add account form ── */
.add-account-form {
  margin-top: 10px;
  padding: 12px;
  background: var(--bg3);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}

.form-row { display: flex; gap: 10px; margin-bottom: 0.75rem; }
.form-row .form-field { flex: 1; margin-bottom: 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 10px; }

/* ── Cache row ── */
.cache-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

/* ── Legal modal ── */
.legal-body { padding: 1.1rem 1.4rem; display: flex; flex-direction: column; gap: 1.25rem; }

.legal-body section h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.legal-body section p { color: var(--muted); line-height: 1.65; font-size: 13px; margin-bottom: 0.35rem; }
.legal-body section a { color: var(--accent); }

/* ── Achievement detail modal ── */
.ach-modal { width: min(490px, 92vw); }

.ach-modal .modal-header h2 {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  flex: 1;
  min-width: 0;
}

.ach-modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ach-modal-body { gap: 16px; }

.ach-modal-flags { display: flex; flex-wrap: wrap; gap: 6px; }

.ach-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 600;
  background: var(--bg4);
  border: 1px solid var(--border);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ach-modal-desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
  font-style: italic;
  opacity: 0.85;
}

.ach-modal-req {
  color: var(--text);
  font-size: 13px;
  line-height: 1.65;
}

.ach-modal-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 10px;
}

.ach-modal-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.ach-modal-bar-label {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.ach-modal-tiers { display: flex; gap: 6px; flex-wrap: wrap; }

.ach-tier {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 7px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 60px;
  opacity: 0.45;
  transition: opacity 0.15s, border-color 0.15s;
}

.ach-tier.tier-reached {
  opacity: 1;
  border-color: var(--accent-dim);
  background: var(--accent-glow);
}

.tier-count { font-size: 14px; font-weight: 700; color: var(--text); line-height: 1; }
.tier-pts   { font-size: 11px; color: var(--muted); margin-top: 3px; }

.ach-bits-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 2px;
}

.ach-bit {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--muted);
  background: var(--bg3);
  border: 1px solid transparent;
}

.ach-bit.bit-done { color: var(--text); border-color: var(--border-soft); }

/* ── Bit checkbox ── */
.bit-checkbox {
  flex-shrink: 0;
  width: 13px;
  height: 13px;
  border-radius: 3px;
  border: 1.5px solid var(--border);
  background: var(--bg4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.15s, border-color 0.15s;
}

.ach-bit.bit-done .bit-checkbox {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.ach-bit.bit-done .bit-checkbox::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0px;
  width: 4px;
  height: 8px;
  border: 1.5px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.bit-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ach-modal-rewards { display: flex; flex-direction: column; gap: 4px; }

.ach-modal-reward-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg3);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
}
.ach-modal-reward-row .item-reward-icon {
  width: 28px;
  height: 28px;
  vertical-align: -7px;
  margin-right: 4px;
}

/* ── Notification volume slider ── */
.notif-volume-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.notif-volume-row input[type="range"] {
  flex: 1;
}

.notif-volume-label {
  font-size: 12px;
  color: var(--muted);
  min-width: 34px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Event detail modal ── */
.et-event-modal { max-width: 380px; }
.et-event-modal .modal-body { flex: none; gap: 0.35rem; }
.et-event-modal .modal-footer { justify-content: flex-start; }
.et-event-modal .et-remind-row { width: 100%; border-top: none; padding-top: 0; }

/* ── Event soon modal ── */
#et-soon-overlay .modal {
  max-width: 380px;
}

.et-soon-body {
  gap: 0.6rem;
}

.et-soon-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.et-soon-row {
  font-size: 12px;
  color: var(--muted);
}

.et-soon-time {
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ── All reminders modal ── */
.all-reminders-modal {
  max-width: 380px;
}

.all-reminders-body {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.all-reminders-empty {
  padding: 1.2rem 1.4rem;
  font-size: 13px;
  color: var(--muted);
}

.reminder-list-item {
  padding: 10px 14px 12px;
  border-bottom: 1px solid var(--border);
}

.reminder-list-item:last-child { border-bottom: none; }

.reminder-list-item-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
}

.reminder-list-item-name {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: transparent;
  border: none;
  padding: 0;
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
}

.reminder-list-item-name:hover { color: var(--accent); }

.reminder-list-item-cancel {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  transition: color 0.1s, background 0.1s;
}

.reminder-list-item-cancel:hover { color: var(--text); background: var(--bg3); }

.reminder-list-item-progress {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reminder-list-item-bar-bg {
  flex: 1;
  height: 4px;
  background: var(--bg4);
  border-radius: 99px;
  overflow: hidden;
}

.reminder-list-item-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 1s linear;
}

.reminder-list-item-time {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ── Modal action buttons ── */
.modal-action-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  width: var(--control-h);
  height: var(--control-h);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: color 0.1s, background 0.1s;
  flex-shrink: 0;
}

.modal-action-btn:hover { color: var(--text); background: var(--bg3); }
#ach-modal-fav-btn.active  { color: var(--gold); }
#ach-modal-fav-btn.active svg { fill: currentColor; }
#ach-modal-hide-btn.active { color: var(--red); }

/* ── ItemSet icon grid ── */
.ach-itemset-grid {
  display: grid;
  grid-template-columns: repeat(7, 60px);
  gap: 4px;
}

.ach-itemset-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg3);
  border: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
  opacity: 0.45;
  filter: saturate(0.2);
}

.ach-itemset-cell.empty {
  background: transparent;
  border-color: transparent;
  filter: none;
}

.ach-itemset-cell.bit-done {
  opacity: 1;
  filter: none;
}

.ach-itemset-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── ItemSet tooltip ── */
.ach-item-tooltip {
  position: fixed;
  z-index: 9999;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  max-width: 220px;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.ach-item-tooltip.hidden { display: none; }

.ach-item-tooltip .tip-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.ach-item-tooltip .tip-name[data-rarity="Junk"]       { color: #AAAAAA; }
.ach-item-tooltip .tip-name[data-rarity="Basic"]      { color: #FFFFFF; }
.ach-item-tooltip .tip-name[data-rarity="Fine"]       { color: #62A4DA; }
.ach-item-tooltip .tip-name[data-rarity="Masterwork"] { color: #1F9306; }
.ach-item-tooltip .tip-name[data-rarity="Rare"]       { color: #FCD00B; }
.ach-item-tooltip .tip-name[data-rarity="Exotic"]     { color: #FFA405; }
.ach-item-tooltip .tip-name[data-rarity="Ascended"]   { color: #FB3E8D; }
.ach-item-tooltip .tip-name[data-rarity="Legendary"]  { color: #A855F7; }

.ach-item-tooltip .tip-desc {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.4;
  white-space: pre-line;
}