:root {
  color-scheme: dark;
  --bg: #111827;
  --bg-deep: #0b1120;
  --panel: #1f2937;
  --panel-soft: #263244;
  --line: #374151;
  --line-strong: #4b5563;
  --ink: #f8fafc;
  --muted: #a8b3c4;
  --yellow: #facc15;
  --yellow-soft: rgba(250, 204, 21, 0.13);
  --green: #4ade80;
  --green-soft: rgba(74, 222, 128, 0.12);
  --blue: #3b82f6;
  --blue-dark: #2563eb;
  --danger: #fb7185;
  --warning: #fbbf24;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, "Noto Sans KR", sans-serif;
  background:
    linear-gradient(180deg, rgba(17, 24, 39, 0.86), rgba(17, 24, 39, 0.96)),
    url("public/base/top.png") center / cover fixed,
    var(--bg);
  color: var(--ink);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 7px;
  font-size: 20px;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 12px;
  font-size: 26px;
  font-style: italic;
  letter-spacing: 0;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 24px clamp(18px, 4vw, 42px);
  background: rgba(31, 41, 55, 0.92);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--yellow);
  font-weight: 800;
  font-size: 13px;
}

nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-link,
.nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  white-space: nowrap;
}

.nav-link {
  background: #111827;
  border: 1px solid var(--line);
}

.nav-button {
  background: var(--blue);
  border: 1px solid var(--blue);
}

.nav-link.active,
.nav-button.active,
.nav-button:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.mypage-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 430px);
  gap: 18px;
  width: min(1480px, calc(100% - 28px));
  margin: 18px auto 40px;
  align-items: start;
}

.publish-form-shell {
  padding: 0;
  border: 0;
}

.listings-page {
  width: min(1120px, calc(100% - 28px));
  margin: 18px auto 40px;
}

.profile-stack,
.control-stack {
  display: grid;
  gap: 18px;
}

.panel,
.panel-dark {
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.22);
}

.panel {
  background: rgba(31, 41, 55, 0.9);
  backdrop-filter: blur(3px);
  padding: 20px;
}

.panel-dark {
  background:
    linear-gradient(rgba(11, 17, 32, 0.9), rgba(11, 17, 32, 0.94)),
    url("public/base/top.png") center / cover;
  min-height: clamp(420px, calc(100vh - 146px), 680px);
  padding: clamp(18px, 3vw, 32px);
  overflow: hidden;
}

.disabled-panel {
  opacity: 0.72;
}

.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-title p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #111827;
  border: 1px solid var(--line-strong);
  color: #dbeafe;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.dark {
  background: rgba(255, 255, 255, 0.07);
}

.field {
  display: grid;
  gap: 8px;
  font-weight: 800;
  color: #e5e7eb;
}

textarea,
input[type="text"],
input[type="url"],
input[type="file"],
select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 11px 12px;
  font: inherit;
  background: #111827;
  color: var(--ink);
  outline: none;
}

input[type="file"] {
  color: var(--muted);
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.12);
}

textarea {
  resize: vertical;
  min-height: 128px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}

button:hover {
  background: var(--blue-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button.secondary {
  background: #374151;
  color: #f3f4f6;
}

button.secondary:hover {
  background: #4b5563;
}

.message {
  margin: 12px 0 0;
  min-height: 20px;
  color: var(--muted);
  line-height: 1.5;
}

.message.compact {
  margin: 0;
  min-height: auto;
  font-size: 13px;
}

.message.error {
  color: var(--danger);
  font-weight: 800;
}

.message.success {
  color: var(--green);
  font-weight: 800;
}

.warning {
  border: 1px solid rgba(251, 191, 36, 0.6);
  background: rgba(251, 191, 36, 0.12);
  color: var(--warning);
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 18px;
  font-weight: 800;
  line-height: 1.5;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 300px;
  border: 3px dashed rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 24px;
  line-height: 1.6;
}

.empty-state.light {
  min-height: 190px;
  background: #111827;
  border-width: 1px;
}

.trade-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(16px, 3vw, 26px);
  height: 100%;
}

.trade-column {
  min-width: 0;
}

.trade-column.wanted h3 {
  color: var(--yellow);
  text-shadow: 0 0 16px rgba(250, 204, 21, 0.42);
}

.trade-column.owned h3 {
  color: var(--green);
  text-shadow: 0 0 16px rgba(74, 222, 128, 0.38);
}

.group-list {
  display: grid;
  gap: 12px;
}

.import-group {
  border: 3px dashed rgba(255, 255, 255, 0.17);
  border-radius: 8px;
  padding: 13px;
  background: rgba(255, 255, 255, 0.045);
}

.wanted .import-group {
  background: var(--yellow-soft);
  border-color: rgba(250, 204, 21, 0.34);
}

.owned .import-group {
  background: var(--green-soft);
  border-color: rgba(74, 222, 128, 0.32);
}

.group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.subtitle-input {
  max-width: 190px;
  min-height: 32px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #e5e7eb;
  background: rgba(17, 24, 39, 0.7);
}

.search-results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
  margin-top: 12px;
}

.result-button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  background: #1f2937;
  color: #f8fafc;
  font-size: 12px;
  text-align: left;
  overflow-wrap: anywhere;
}

.result-button img {
  display: block;
  width: 34px;
  height: 34px;
  object-fit: contain;
  object-position: left center;
}

.result-button span {
  min-width: 0;
}

.result-button:hover {
  border-color: var(--yellow);
  background: rgba(250, 204, 21, 0.13);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  max-width: 100%;
  padding: 5px 6px 5px 9px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f8fafc;
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.chip-remove {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  min-height: 20px;
  padding: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
  line-height: 1;
  font-size: 14px;
}

.chip-remove:hover {
  background: rgba(251, 113, 133, 0.45);
}

.chip.empty {
  color: var(--muted);
  padding-right: 9px;
}

.chip.bad {
  background: rgba(244, 63, 94, 0.14);
  border-color: rgba(251, 113, 133, 0.45);
  color: var(--danger);
}

.chip.duplicate {
  background: rgba(251, 191, 36, 0.14);
  border-color: rgba(251, 191, 36, 0.45);
  color: var(--warning);
}

.publish-form,
.post-fields {
  display: grid;
  gap: 14px;
}

.trainer-info-panel {
  align-self: start;
}

.trainer-fields {
  display: grid;
  grid-template-columns: minmax(170px, 0.8fr) minmax(260px, 1.2fr) minmax(230px, max-content);
  gap: 14px;
  align-items: end;
}

.control-stack .trainer-fields {
  grid-template-columns: 1fr;
  align-items: stretch;
}

.trainer-fields .checkbox-row {
  min-height: 44px;
}

.profile-stack .post-fields {
  grid-template-columns: minmax(0, 1.1fr) minmax(240px, 0.9fr);
  align-items: start;
}

.profile-stack .post-fields .field:first-child {
  grid-row: span 3;
}

.profile-stack .post-fields .image-preview,
.profile-stack .post-fields #publishButton {
  grid-column: 2;
}

.post-panel textarea {
  min-height: 156px;
}

.profile-stack .post-panel textarea {
  min-height: 220px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
}

.image-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
}

.image-preview-item {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.image-preview-thumb {
  position: relative;
  min-width: 0;
}

.image-preview-thumb img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  background: #0b1120;
}

.image-preview-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  display: inline-grid;
  place-items: center;
  width: 28px;
  min-height: 28px;
  padding: 0;
  border: 1px solid rgba(248, 250, 252, 0.35);
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.86);
  color: #fff;
  font-size: 18px;
  line-height: 1;
}

.image-preview-remove:hover {
  background: var(--danger);
  border-color: var(--danger);
}

.image-preview-item span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.listing-list {
  display: grid;
  gap: 14px;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.pagination-bar[hidden] {
  display: none;
}

.pagination-bar p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.pagination-bar button {
  min-width: 112px;
}

.pagination-controls,
.page-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pagination-controls {
  justify-content: flex-end;
}

.pagination-controls button,
.page-number {
  min-width: 36px;
  min-height: 36px;
  padding: 0 10px;
}

.page-number.active {
  border-color: var(--yellow);
  background: var(--yellow);
  color: #111827;
}

.page-ellipsis {
  min-width: 22px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

.listing-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #111827;
}

.listing-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.listing-card h3 {
  margin: 0;
  color: var(--yellow);
  font-size: 20px;
  font-style: normal;
}

.listing-card header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.listing-body {
  display: grid;
  gap: 16px;
}

.listing-gallery {
  display: grid;
  gap: 12px;
}

.listing-carousel {
  display: grid;
  gap: 9px;
  min-width: 0;
  outline: none;
}

.listing-carousel-viewport {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b1120;
  touch-action: pan-y;
}

.listing-carousel-frame {
  position: relative;
  display: block;
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #0b1120;
  overflow: hidden;
}

.listing-carousel-frame:hover {
  background: #0b1120;
}

.listing-image {
  display: block;
  width: 100%;
  height: auto;
  background: #0b1120;
}

.listing-fallback-preview {
  display: none;
  width: 100%;
  padding: 24px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.5;
  text-align: left;
}

.listing-fallback-preview > strong {
  display: block;
  margin-bottom: 12px;
  color: #e5e7eb;
  font-size: 14px;
}

.listing-fallback-preview > span {
  display: block;
  color: var(--muted);
  text-align: center;
}

.fallback-preview-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.fallback-preview-column {
  min-width: 0;
  padding: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.fallback-preview-column.wanted {
  border-color: rgba(250, 204, 21, 0.32);
  background: var(--yellow-soft);
}

.fallback-preview-column.owned {
  border-color: rgba(74, 222, 128, 0.3);
  background: var(--green-soft);
}

.fallback-preview-column > span {
  display: block;
  margin-bottom: 7px;
  color: #f8fafc;
  font-size: 12px;
}

.fallback-preview-column ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.fallback-preview-column li,
.fallback-preview-column em {
  display: block;
  min-width: 0;
  color: #d1d5db;
  font-size: 11px;
  font-style: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.listing-carousel-frame.missing-preview .listing-image {
  display: none;
}

.listing-carousel-frame.missing-preview .listing-fallback-preview {
  display: block;
}

.carousel-control {
  position: absolute;
  top: 50%;
  z-index: 5;
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 58px;
  min-height: 58px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.82);
  box-shadow: none;
  font-size: 0;
  line-height: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%);
  transition: opacity 120ms ease, color 120ms ease;
}

.carousel-control::before {
  content: "";
  display: block;
  width: 13px;
  height: 13px;
  border-top: 3px solid currentColor;
  border-right: 3px solid currentColor;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.9));
}

.carousel-control.previous {
  left: 12px;
}

.carousel-control.previous::before {
  transform: translateX(2px) rotate(-135deg);
}

.carousel-control.next {
  right: 12px;
}

.carousel-control.next::before {
  transform: translateX(-2px) rotate(45deg);
}

.carousel-control:hover {
  background: transparent;
  color: var(--yellow);
}

.listing-carousel:hover .carousel-control,
.listing-carousel:focus-within .carousel-control,
.listing-carousel.active .carousel-control {
  opacity: 1;
  pointer-events: auto;
}

.carousel-count {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  min-width: 48px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.88);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.listing-carousel:hover .carousel-count,
.listing-carousel:focus-within .carousel-count,
.listing-carousel.active .carousel-count {
  background: rgba(17, 24, 39, 0.96);
}

.carousel-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 12px;
}

.carousel-dot {
  flex: 0 0 auto;
  display: block;
  width: 10px;
  height: 10px;
  min-width: 10px;
  min-height: 10px;
  max-width: 10px;
  max-height: 10px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #4b5563;
  overflow: hidden;
  line-height: 0;
  text-indent: -999px;
}

.carousel-dot.active {
  width: 10px;
  height: 10px;
  min-width: 10px;
  max-width: 10px;
  border-color: var(--yellow);
  background: var(--yellow);
}

@media (hover: none) {
  .carousel-control {
    opacity: 0.95;
    pointer-events: auto;
  }
}

.listing-content {
  display: grid;
  gap: 14px;
}

.listing-text {
  margin-bottom: 0;
  white-space: pre-wrap;
  line-height: 1.6;
  color: #e5e7eb;
}

.listing-card dl {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 9px 12px;
  margin: 0;
}

.listing-card dt {
  color: var(--muted);
  font-weight: 900;
}

.listing-card dd {
  margin: 0;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.listing-items {
  color: #e5e7eb;
}

.inline-more-button {
  display: inline;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--yellow);
  font: inherit;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.inline-more-button:hover {
  background: transparent;
  color: #fde68a;
}

.match-highlight {
  color: var(--yellow);
  font-weight: 900;
  text-shadow: 0 0 10px rgba(250, 204, 21, 0.25);
}

.item-separator {
  color: rgba(229, 231, 235, 0.62);
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding: 64px 18px 48px;
  overflow: auto;
  background: rgba(0, 0, 0, 0.82);
}

.image-modal img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(1080px, calc(100vw - 36px));
  max-height: calc(100vh - 112px);
  max-height: calc(100dvh - 112px);
  object-fit: contain;
  border-radius: 8px;
  background: #0b1120;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
}

.modal-close {
  position: fixed;
  top: 18px;
  right: 18px;
  background: #1f2937;
  border: 1px solid var(--line-strong);
}

.modal-nav {
  position: fixed;
  top: 50%;
  z-index: 1001;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 64px;
  min-height: 64px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.92);
  box-shadow: none;
  font-size: 0;
  line-height: 0;
  transform: translateY(-50%);
}

.modal-nav::before {
  content: "";
  display: block;
  width: 15px;
  height: 15px;
  border-top: 3px solid currentColor;
  border-right: 3px solid currentColor;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.92));
}

.modal-nav.previous {
  left: 18px;
}

.modal-nav.previous::before {
  transform: translateX(2px) rotate(-135deg);
}

.modal-nav.next {
  right: 18px;
}

.modal-nav.next::before {
  transform: translateX(-2px) rotate(45deg);
}

.modal-nav:hover {
  background: transparent;
  color: var(--yellow);
}

.modal-count {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 1001;
  min-width: 58px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.88);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  text-align: center;
  transform: translateX(-50%);
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .mypage-layout {
    grid-template-columns: 1fr;
  }

  .panel-dark {
    min-height: auto;
  }

  .trainer-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-stack .trainer-fields {
    grid-template-columns: 1fr;
  }

  .trainer-fields .checkbox-row {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .app-header,
  .section-title,
  .listing-card header,
  .listing-body {
    flex-direction: column;
    align-items: stretch;
  }

  .app-header {
    padding: 20px 14px;
  }

  nav {
    width: 100%;
  }

  .nav-link,
  .nav-button {
    flex: 1;
    padding: 0 10px;
  }

  .trade-board {
    grid-template-columns: 1fr;
  }

  .trainer-fields {
    grid-template-columns: 1fr;
  }

  .profile-stack .post-fields {
    grid-template-columns: 1fr;
  }

  .pagination-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .pagination-controls {
    justify-content: stretch;
  }

  .pagination-controls > button {
    flex: 1;
  }

  .page-buttons {
    justify-content: center;
    width: 100%;
  }

  .profile-stack .post-fields .field:first-child,
  .profile-stack .post-fields .image-preview,
  .profile-stack .post-fields #publishButton {
    grid-column: auto;
    grid-row: auto;
  }

  .carousel-control {
    width: 34px;
    height: 54px;
    min-height: 54px;
  }

  .carousel-control::before {
    width: 11px;
    height: 11px;
  }

  .carousel-control.previous {
    left: 8px;
  }

  .carousel-control.next {
    right: 8px;
  }

  .modal-nav {
    width: 38px;
    height: 58px;
    min-height: 58px;
  }

  .modal-nav::before {
    width: 12px;
    height: 12px;
  }

  .listing-card dl {
    grid-template-columns: 72px minmax(0, 1fr);
  }
}
