:root {
  color-scheme: dark;
  --bg: #0d1324;
  --bg-2: #172a45;
  --panel: rgba(18, 27, 48, 0.88);
  --panel-2: rgba(27, 43, 72, 0.9);
  --surface: #f7ead0;
  --surface-2: #f0d8a8;
  --text: #fff8e8;
  --ink: #2f2340;
  --muted: #c9d8ef;
  --line: rgba(244, 210, 132, 0.34);
  --gold: #f4d284;
  --gold-2: #bf7c30;
  --aqua: #71d8ff;
  --violet: #a58cff;
  --rose: #ff7f9b;
  --green: #85f2a9;
  --red: #ff6b78;
  --shadow: 0 18px 48px rgba(4, 10, 26, 0.36);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(113, 216, 255, 0.14), transparent 28%),
    linear-gradient(315deg, rgba(255, 127, 155, 0.12), transparent 32%),
    radial-gradient(circle at 50% 0, rgba(244, 210, 132, 0.2), transparent 34%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 48%, #10172d);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(244, 210, 132, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(244, 210, 132, 0.06) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent 78%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(13, 19, 36, 0.78);
  backdrop-filter: blur(18px);
  box-shadow: 0 10px 28px rgba(4, 10, 26, 0.24);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(244, 210, 132, 0.72);
  border-radius: 8px;
  color: #1d2744;
  background: linear-gradient(135deg, var(--gold), #fff2bc 45%, var(--aqua));
  box-shadow: inset 0 0 0 2px rgba(255, 248, 232, 0.38), 0 8px 24px rgba(113, 216, 255, 0.16);
  font-weight: 900;
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.18rem, 2vw, 1.55rem);
  line-height: 1.1;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid rgba(113, 216, 255, 0.42);
  border-radius: 8px;
  color: var(--text);
  background: rgba(27, 43, 72, 0.76);
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--green);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 28px;
  padding: 30px clamp(18px, 4vw, 56px) 56px;
}

.creator-panel,
.gallery-panel {
  min-width: 0;
}

.creator-panel {
  position: sticky;
  top: 90px;
  align-self: start;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-title {
  margin: 0 0 16px;
  font-size: 1rem;
  color: var(--gold);
  text-transform: uppercase;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid rgba(244, 210, 132, 0.28);
  border-radius: 8px;
  color: var(--text);
  background: rgba(6, 12, 27, 0.82);
  outline: none;
}

.field input,
.field select {
  height: 44px;
  padding: 0 12px;
}

.field textarea {
  min-height: 142px;
  resize: vertical;
  padding: 12px;
  line-height: 1.45;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--aqua);
  box-shadow: 0 0 0 3px rgba(113, 216, 255, 0.16);
}

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

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  margin-top: 4px;
  border: 1px solid rgba(255, 248, 232, 0.34);
  border-radius: 8px;
  color: #22172f;
  background: linear-gradient(135deg, var(--gold), #fff1b6 48%, #8de7ff);
  box-shadow: 0 10px 24px rgba(113, 216, 255, 0.18);
  font-weight: 900;
}

.primary-action:disabled {
  opacity: 0.65;
  cursor: wait;
}

.message {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.message.error {
  color: var(--red);
}

.gallery-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.gallery-header h2 {
  margin: 0;
  font-size: clamp(1.65rem, 3vw, 2.45rem);
  text-shadow: 0 2px 16px rgba(113, 216, 255, 0.22);
}

.gallery-header p {
  margin: 5px 0 0;
  color: var(--muted);
}

.gallery-tools {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.view-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  min-height: 42px;
  border: 1px solid rgba(244, 210, 132, 0.34);
  border-radius: 8px;
  background: rgba(13, 19, 36, 0.74);
  overflow: hidden;
}

.view-button {
  min-width: 78px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.view-button.active {
  color: #22172f;
  background: linear-gradient(135deg, var(--gold), #fff1b6);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(113, 216, 255, 0.38);
  border-radius: 8px;
  background: rgba(27, 43, 72, 0.82);
  color: var(--text);
}

.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 20px;
}

.items-grid.full-view {
  grid-template-columns: 1fr;
}

.item-card {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  border: 1px solid rgba(244, 210, 132, 0.42);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(34, 25, 52, 0.95), rgba(13, 19, 36, 0.96));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-view .item-card {
  position: relative;
}

.card-view .item-card::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(255, 248, 232, 0.14);
  border-radius: 6px;
  pointer-events: none;
}

.full-view .item-card {
  grid-template-columns: minmax(220px, 32%) 1fr;
  grid-template-rows: auto;
}

.item-art {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--panel-2);
}

.card-view .item-art {
  aspect-ratio: 4 / 3;
  border-bottom: 1px solid rgba(244, 210, 132, 0.38);
}

.item-body {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.card-view .item-body {
  align-content: start;
  grid-template-rows: auto auto auto auto 1fr auto;
  min-height: 406px;
}

.item-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.card-view .item-kicker {
  color: var(--gold);
  font-weight: 900;
}

.item-card h3 {
  margin: 0;
  font-size: 1.22rem;
  line-height: 1.2;
}

.card-view .item-card h3 {
  color: #fff9eb;
  font-size: 1.38rem;
  text-shadow: 0 2px 14px rgba(244, 210, 132, 0.18);
}

.item-summary,
.item-history,
.item-balance {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.card-view .item-summary,
.card-view .ability-box span {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
}

.card-view .item-summary {
  -webkit-line-clamp: 3;
}

.card-view .ability-box span {
  -webkit-line-clamp: 4;
}

.card-view .item-history,
.card-view .item-balance,
.card-view .full-only {
  display: none;
}

.stat-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.stat-list li {
  padding: 7px 10px;
  border: 1px solid rgba(113, 216, 255, 0.28);
  border-radius: 8px;
  background: rgba(6, 12, 27, 0.62);
  color: #eaf8ff;
  font-size: 0.84rem;
  font-weight: 700;
}

.stat-list .more-stat {
  border-color: rgba(244, 210, 132, 0.48);
  color: var(--gold);
}

.ability-box {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid rgba(165, 140, 255, 0.3);
  border-left: 4px solid var(--violet);
  border-radius: 8px;
  background: rgba(16, 23, 45, 0.78);
}

.ability-box strong {
  color: #d8ccff;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
}

.download-card-button {
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(255, 248, 232, 0.34);
  border-radius: 8px;
  color: #15233d;
  background: linear-gradient(135deg, var(--aqua), #d5f6ff 48%, var(--gold));
  font-weight: 900;
}

.download-card-button:disabled {
  opacity: 0.68;
  cursor: wait;
}

.full-view .card-actions {
  display: none;
}

.detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-list div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid rgba(244, 210, 132, 0.24);
  border-radius: 8px;
  background: rgba(6, 12, 27, 0.58);
}

.detail-list span {
  color: var(--gold);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.detail-list p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 360px;
  border: 1px dashed rgba(244, 210, 132, 0.4);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 28px;
  background: rgba(18, 27, 48, 0.44);
}

@media (max-width: 860px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .creator-panel {
    position: static;
  }
}

@media (max-width: 700px) {
  .full-view .item-card {
    grid-template-columns: 1fr;
  }

  .detail-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .gallery-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .gallery-tools {
    width: 100%;
  }

  .view-toggle {
    flex: 1;
  }

  .view-button {
    min-width: 0;
  }
}
