html {
  height: 100%;
}

body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

.tool-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  background: var(--bg-primary);
}

.tool-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  flex-shrink: 0;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border-secondary);
  background: rgba(18, 18, 24, 0.92);
  backdrop-filter: blur(12px);
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.tool-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.125rem;
  line-height: 1.2;
  letter-spacing: 0.04em;
}

.tool-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: var(--panel-gap, 1rem);
}

.btn-back,
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.btn-back:hover,
.btn-icon:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-accent);
}

.btn-primary,
.btn-secondary {
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.42rem 0.78rem;
  font-size: 0.8125rem;
  line-height: 1.25;
  cursor: pointer;
  transition: transform var(--transition-fast), filter var(--transition-fast), background var(--transition-fast);
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  font-weight: 600;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-secondary);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-accent);
}

.panel {
  background: var(--bg-glass);
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-lg);
  padding: 0.85rem;
  box-shadow: var(--shadow-sm);
}

.tool-header .btn-primary,
.tool-header .btn-secondary {
  padding: 0.38rem 0.68rem;
}

.tool-header .field-input,
.tool-header select.field-input,
.tool-header select.field-select {
  min-height: 2rem;
  padding: 0.32rem 0.6rem;
  font-size: 0.8125rem;
}

.panel-title {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.03em;
}

.field-label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.field-input,
.field-textarea,
.field-select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
}

select.field-input,
select.field-select {
  min-height: 2.65rem;
  padding-right: 2.3rem;
  background-color: rgba(15, 23, 42, 0.94);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23cbd5e1' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  color: rgba(241, 245, 249, 0.96);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.35;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

select.field-input:hover:not(:disabled),
select.field-select:hover:not(:disabled) {
  background-color: rgba(20, 28, 48, 0.98);
  border-color: rgba(148, 163, 184, 0.38);
}

select.field-input:disabled,
select.field-select:disabled {
  opacity: 0.55;
  color: rgba(148, 163, 184, 0.8);
  cursor: not-allowed;
}

select.field-input option,
select.field-select option {
  background: #0f172a;
  color: #f1f5f9;
  font-size: 0.95rem;
  font-weight: 500;
}

.field-textarea {
  min-height: 120px;
  resize: vertical;
}

.field-input:focus,
.field-textarea:focus,
.field-select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(var(--accent-primary-rgb), 0.18);
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.list-item:hover,
.list-item.active {
  border-color: var(--border-accent);
  background: var(--bg-hover);
}

.list-item-meta {
  color: var(--text-tertiary);
  font-size: 0.82rem;
}

.empty-state {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-tertiary);
}

.wf-versatile-dialog {
  position: fixed;
  inset: 0;
  /* Above battle-table (500) and player-battle (150) modals */
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.wf-versatile-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
}

.wf-versatile-panel {
  position: relative;
  width: min(420px, 100%);
  padding: 1rem;
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  box-shadow: var(--shadow-lg);
}

.wf-versatile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.wf-versatile-head h3 {
  margin: 0;
  font-size: 1rem;
}

.wf-versatile-close {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
}

.wf-versatile-hint {
  margin: 0 0 0.85rem;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.wf-versatile-options {
  display: grid;
  gap: 0.55rem;
}

.wf-versatile-option {
  display: grid;
  gap: 0.2rem;
  width: 100%;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
}

.wf-versatile-option:hover {
  border-color: var(--border-accent);
  background: var(--bg-hover);
}

.wf-versatile-option-title {
  font-weight: 700;
}

.wf-versatile-option-hit,
.wf-versatile-option-damage {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

.wf-versatile-option.is-suggested {
  border-color: var(--border-accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--border-accent) 55%, transparent);
}

.wf-versatile-option-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.wf-versatile-option-badge {
  display: inline-block;
  padding: 0.12rem 0.4rem;
  border-radius: var(--radius-sm, 4px);
  background: color-mix(in srgb, var(--border-accent) 28%, transparent);
  color: var(--text-primary);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

@media (max-width: 1199px) {
  .tool-header {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .header-left {
    flex: 1 1 auto;
    min-width: 0;
  }

  .header-right {
    flex: 1 1 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .tool-title {
    font-size: 1.05rem;
  }
}

@media (max-width: 959px) {
  .tool-header {
    padding-inline: 1rem;
  }

  .header-right .search-input {
    width: 100%;
    max-width: none;
    min-width: 0;
  }
}

/* Multi-select filter dropdowns (sidebar browse tools) */
.qf-filter-dropdown {
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: var(--radius-sm, 6px);
  background: rgba(15, 23, 42, 0.72);
  margin-bottom: 0.4rem;
}

.qf-filter-dropdown-summary {
  cursor: pointer;
  padding: 0.4rem 0.55rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  user-select: none;
}

.qf-filter-dropdown-summary::-webkit-details-marker {
  display: none;
}

.qf-filter-dropdown-summary::after {
  content: '▾';
  opacity: 0.55;
  font-size: 0.7rem;
  flex-shrink: 0;
}

.qf-filter-dropdown[open] > .qf-filter-dropdown-summary::after {
  content: '▴';
}

.qf-filter-dropdown--active > .qf-filter-dropdown-summary {
  color: var(--text-primary);
  font-weight: 600;
}

.qf-filter-dropdown-menu {
  max-height: 11rem;
  overflow-y: auto;
  padding: 0.25rem 0.45rem 0.5rem;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.qf-filter-option {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  padding: 0.18rem 0.1rem;
  cursor: pointer;
}

.qf-filter-option:hover {
  color: var(--text-primary);
}

.qf-filter-option input {
  margin-top: 0.12rem;
  flex-shrink: 0;
}
