:root {
  --night-line: rgba(170, 214, 255, 0.16);
  --night-line-strong: rgba(170, 214, 255, 0.28);
  --night-text: #eef7ff;
  --night-muted: #9ebcd8;
  --night-accent: #7be4ff;
  --night-accent-2: #94f3d0;
  --night-danger: #ff9aa6;
  --night-shadow: 0 24px 56px rgba(2, 8, 20, 0.34);
}

body.nightmare-modal-open {
  overflow: hidden;
}

.nightmare-shell {
  display: grid;
  gap: 14px;
}

.nightmare-card {
  border: 1px solid var(--night-line);
  border-radius: 24px;
  background:
    radial-gradient(circle at top left, rgba(123, 228, 255, 0.12), transparent 30%),
    linear-gradient(165deg, rgba(17, 33, 58, 0.96), rgba(9, 18, 31, 0.94));
  box-shadow: var(--night-shadow);
  backdrop-filter: blur(12px);
}

.nightmare-hero,
.nightmare-toolbar,
.nightmare-summary-panel,
.nightmare-list-panel,
.nightmare-empty-card,
.nightmare-pool-card,
.nightmare-export-card {
  padding: 16px;
}

.nightmare-hero,
.nightmare-search-row,
.nightmare-search-actions,
.nightmare-section-head,
.nightmare-pool-top,
.nightmare-progress-head,
.nightmare-quick-head,
.nightmare-export-head {
  display: flex;
  gap: 10px;
  align-items: center;
}

.nightmare-hero,
.nightmare-section-head,
.nightmare-pool-top,
.nightmare-progress-head,
.nightmare-quick-head,
.nightmare-export-head {
  justify-content: space-between;
}

.nightmare-hero-copy,
.nightmare-notice-main,
.nightmare-pool-copy,
.nightmare-pet-copy,
.nightmare-empty-card,
.nightmare-quick-switch,
.nightmare-export-card {
  display: grid;
  gap: 8px;
}

.nightmare-eyebrow {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #d2ebff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nightmare-hero h1,
.nightmare-section-head h2,
.nightmare-pet-name,
.nightmare-notice-title,
.nightmare-pool-title,
.nightmare-empty-card p,
.nightmare-export-tip {
  margin: 0;
}

.nightmare-hero h1 {
  font-size: clamp(24px, 4.4vw, 38px);
  line-height: 1.05;
  word-break: keep-all;
}

.nightmare-hero-meta,
.nightmare-notice-top,
.nightmare-export-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.nightmare-hero-meta {
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-self: start;
}

.nightmare-meta-pill,
.nightmare-chip,
.nightmare-chip-main,
.nightmare-chip-count,
.nightmare-type-badge,
.nightmare-result-pill,
.nightmare-summary-count-badge {
  border-radius: 999px;
}

.nightmare-meta-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--night-line);
  background: rgba(255, 255, 255, 0.08);
  color: #e5f4ff;
  font-size: 12px;
  font-weight: 800;
}

.nightmare-meta-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
}

.nightmare-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.nightmare-hero-copy {
  min-width: 0;
}

.nightmare-toolbar {
  display: grid;
  gap: 10px;
}

.nightmare-search-row {
  align-items: stretch;
}

.nightmare-search-field {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--night-line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--night-muted);
}

.nightmare-search-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--night-text);
  font: inherit;
}

.nightmare-search-field input::placeholder {
  color: rgba(237, 247, 255, 0.5);
}

.nightmare-search-actions {
  flex: 0 0 auto;
}

.nightmare-primary-btn,
.nightmare-ghost-btn,
.nightmare-danger-btn,
.nightmare-pet-main,
.nightmare-pet-toggle,
.nightmare-chip-main,
.nightmare-chip-remove,
.nightmare-pool-reset {
  font: inherit;
  color: var(--night-text);
  border-radius: 16px;
}

.nightmare-primary-btn,
.nightmare-ghost-btn,
.nightmare-danger-btn,
.nightmare-pet-toggle,
.nightmare-chip-remove,
.nightmare-pool-reset {
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background-color 0.16s ease;
}

.nightmare-primary-btn:hover,
.nightmare-ghost-btn:hover,
.nightmare-danger-btn:hover,
.nightmare-pet-toggle:hover,
.nightmare-chip-remove:hover,
.nightmare-pool-reset:hover {
  transform: translateY(-1px);
}

.nightmare-primary-btn {
  background: linear-gradient(135deg, var(--night-accent), var(--night-accent-2));
  color: #042131;
  font-weight: 900;
}

.nightmare-ghost-btn {
  border-color: var(--night-line);
  background: rgba(255, 255, 255, 0.08);
}

.nightmare-danger-btn {
  border-color: rgba(255, 154, 166, 0.24);
  background: rgba(255, 154, 166, 0.14);
}

.nightmare-primary-btn,
.nightmare-ghost-btn,
.nightmare-danger-btn {
  min-height: 40px;
  padding: 0 14px;
  white-space: nowrap;
}

.nightmare-primary-btn:disabled,
.nightmare-ghost-btn:disabled,
.nightmare-danger-btn:disabled,
.nightmare-pet-toggle:disabled,
.nightmare-pool-reset:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
}

.nightmare-result-meta,
.nightmare-section-head span,
.nightmare-quick-head span,
.nightmare-notice-subtitle,
.nightmare-pool-hint,
.nightmare-pool-status,
.nightmare-empty-card p,
.nightmare-empty-state,
.nightmare-pet-meta-line,
.nightmare-export-tip {
  color: var(--night-muted);
  font-size: 12px;
  line-height: 1.5;
}

.nightmare-layout,
.nightmare-workspace,
.nightmare-list-panel,
.nightmare-list-body,
.nightmare-pet-list,
.nightmare-pool-list {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.nightmare-list-panel[hidden],
.nightmare-list-body[hidden],
.nightmare-export-modal[hidden] {
  display: none;
}

.nightmare-pet-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 20px;
  border: 1px solid rgba(170, 214, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
}

.nightmare-pet-card.is-active {
  border-color: rgba(123, 228, 255, 0.42);
  background: rgba(123, 228, 255, 0.12);
}

.nightmare-pet-card.is-picked {
  box-shadow: inset 0 0 0 1px rgba(148, 243, 208, 0.16);
}

.nightmare-pet-main {
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  min-width: 0;
}

.nightmare-pet-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.nightmare-pet-name {
  min-width: 0;
  font-size: 16px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nightmare-pet-meta-line {
  display: inline-flex;
  gap: 8px;
}

.nightmare-pet-toggle {
  min-width: 64px;
  min-height: 34px;
  padding: 0 12px;
  border-color: rgba(170, 214, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
}

.nightmare-pet-toggle.is-picked {
  border-color: rgba(148, 243, 208, 0.26);
  background: rgba(148, 243, 208, 0.14);
}

.nightmare-type-row,
.nightmare-result-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.nightmare-type-row {
  flex: 0 0 auto;
}

.nightmare-type-badge {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: color-mix(in srgb, var(--type-color) 18%, rgba(255, 255, 255, 0.06));
}

.nightmare-type-badge img {
  width: 13px;
  height: 13px;
  object-fit: contain;
}

.nightmare-type-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--type-color) 90%, white 10%);
}

.nightmare-summary-panel {
  position: sticky;
  top: 18px;
  z-index: 2;
  display: grid;
  gap: 12px;
}

.nightmare-notice-top {
  align-items: flex-start;
  justify-content: space-between;
}

.nightmare-notice-main {
  min-width: 0;
}

.nightmare-notice-title {
  font-size: 18px;
  line-height: 1.2;
}

.nightmare-summary-count-badge {
  flex: 0 0 auto;
  min-width: 94px;
  padding: 9px 12px;
  border: 1px solid var(--night-line);
  background:
    linear-gradient(160deg, rgba(123, 228, 255, 0.12), rgba(255, 255, 255, 0.05)),
    rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 2px;
  text-align: right;
  justify-items: end;
}

.nightmare-summary-count-badge span {
  font-size: 11px;
  color: var(--night-muted);
  letter-spacing: 0.02em;
}

.nightmare-summary-count-badge strong {
  font-size: 26px;
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.nightmare-action-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.nightmare-action-row > button {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.nightmare-quick-switch {
  gap: 8px;
}

.nightmare-quick-head strong {
  font-size: 13px;
}

.nightmare-selection-tray {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.nightmare-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--night-line);
  background: rgba(255, 255, 255, 0.08);
}

.nightmare-chip.is-active {
  border-color: rgba(123, 228, 255, 0.42);
  background: rgba(123, 228, 255, 0.14);
}

.nightmare-chip-main {
  border: 0;
  background: transparent;
  padding: 6px 8px 6px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.nightmare-chip-name {
  font-size: 13px;
  font-weight: 700;
}

.nightmare-chip-count {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
  font-size: 12px;
  font-weight: 800;
}

.nightmare-chip-remove {
  width: 30px;
  height: 30px;
  background: rgba(255, 255, 255, 0.06);
}

.nightmare-pool-card {
  display: grid;
  gap: 10px;
}

.nightmare-pool-card.family {
  background:
    radial-gradient(circle at top left, rgba(245, 200, 107, 0.14), transparent 28%),
    linear-gradient(165deg, rgba(18, 33, 58, 0.96), rgba(9, 18, 31, 0.94));
}

.nightmare-pool-card.type {
  background:
    radial-gradient(circle at top left, rgba(123, 228, 255, 0.12), transparent 28%),
    linear-gradient(165deg, rgba(18, 33, 58, 0.96), rgba(9, 18, 31, 0.94));
}

.nightmare-pool-card.chaos {
  background:
    radial-gradient(circle at top left, rgba(179, 149, 255, 0.16), transparent 28%),
    linear-gradient(165deg, rgba(18, 33, 58, 0.96), rgba(9, 18, 31, 0.94));
}

.nightmare-pool-title {
  font-size: 17px;
  line-height: 1.2;
}

.nightmare-pool-reset {
  min-width: 62px;
  min-height: 34px;
  border-color: rgba(170, 214, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
}

.nightmare-progress-block {
  display: grid;
  gap: 8px;
}

.nightmare-progress-head strong {
  font-size: 17px;
}

.nightmare-progress-bar {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.nightmare-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #72dfff, #9af7da);
}

.nightmare-pool-status {
  padding: 10px 12px;
  border-radius: 18px;
  border: 1px solid transparent;
}

.nightmare-pool-status.normal {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
}

.nightmare-pool-status.rise {
  border-color: rgba(123, 228, 255, 0.22);
  background: rgba(123, 228, 255, 0.12);
}

.nightmare-pool-status.high {
  border-color: rgba(245, 200, 107, 0.24);
  background: rgba(245, 200, 107, 0.12);
}

.nightmare-pool-status.full {
  border-color: rgba(137, 236, 168, 0.24);
  background: rgba(137, 236, 168, 0.13);
}

.nightmare-result-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(170, 214, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #f2f8ff;
  font-size: 12px;
}

.nightmare-empty-card strong,
.nightmare-empty-state strong {
  font-size: 16px;
}

.nightmare-empty-state {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-radius: 18px;
  border: 1px dashed var(--night-line-strong);
}

.nightmare-export-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 16px;
}

.nightmare-export-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(2, 10, 20, 0.68);
  backdrop-filter: blur(10px);
}

.nightmare-export-card {
  position: relative;
  z-index: 1;
  width: min(720px, calc(100vw - 24px));
}

.nightmare-export-text {
  width: 100%;
  min-height: 240px;
  resize: vertical;
  border: 1px solid var(--night-line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--night-text);
  padding: 12px 14px;
  font: 500 13px/1.6 ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  box-sizing: border-box;
}

.nightmare-export-text:focus {
  outline: 1px solid rgba(123, 228, 255, 0.44);
}

.nightmare-export-actions {
  justify-content: flex-end;
}

@media (min-width: 980px) {
  .nightmare-layout {
    grid-template-columns: 320px minmax(0, 1fr);
    align-items: start;
  }

  .nightmare-layout.is-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }

  .nightmare-list-panel {
    position: sticky;
    top: 18px;
    max-height: calc(100vh - 36px);
    overflow: hidden;
  }

  .nightmare-list-body {
    overflow: auto;
    padding-right: 4px;
  }

  .nightmare-pool-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 979px) {
  .shell-layout {
    width: min(100%, calc(100% - 14px));
  }

  .nightmare-summary-panel {
    top: calc(var(--shell-mobilebar-offset) + 8px);
  }
}

@media (max-width: 720px) {
  .nightmare-hero,
  .nightmare-toolbar,
  .nightmare-summary-panel,
  .nightmare-list-panel,
  .nightmare-empty-card,
  .nightmare-pool-card,
  .nightmare-export-card {
    padding: 14px;
    border-radius: 20px;
  }

  .nightmare-search-row {
    flex-direction: column;
  }

  .nightmare-search-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nightmare-search-actions > button {
    width: 100%;
  }

  .nightmare-hero {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .nightmare-pool-top {
    align-items: flex-start;
  }

  .nightmare-action-row > button span {
    font-size: 13px;
  }
}

@media (max-width: 560px) {
  .nightmare-primary-btn,
  .nightmare-ghost-btn,
  .nightmare-danger-btn {
    min-height: 38px;
    padding: 0 10px;
  }

  .nightmare-summary-count-badge {
    min-width: 82px;
    padding: 8px 10px;
  }

  .nightmare-summary-count-badge strong {
    font-size: 24px;
  }

  .nightmare-meta-pill {
    min-height: 32px;
    padding: 0 10px;
  }

  .nightmare-meta-btn {
    width: 34px;
    min-width: 34px;
    padding: 0;
    justify-content: center;
  }

  .nightmare-meta-btn span {
    display: none;
  }

  .nightmare-pet-card {
    padding: 10px;
  }

  .nightmare-pet-name {
    font-size: 15px;
  }

  .nightmare-pet-toggle {
    min-width: 58px;
    padding: 0 10px;
  }
}

@media (max-width: 480px) {
  .nightmare-shell {
    gap: 12px;
  }

  .nightmare-action-row > button {
    gap: 4px;
  }

  .nightmare-action-row > button i {
    font-size: 12px;
  }

  .nightmare-action-row > button span {
    font-size: 12px;
  }

  .nightmare-chip-main {
    padding: 5px 7px 5px 9px;
  }

  .nightmare-chip-remove {
    width: 28px;
    height: 28px;
  }

  .nightmare-export-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nightmare-export-actions > button {
    width: 100%;
  }
}
