:root {
  --bg: #0b0f12;
  --bg-raised: #11171c;
  --panel: #151b21;
  --panel-2: #192128;
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.2);
  --text: #f4f1eb;
  --muted: #9da6ad;
  --soft: #d8d0c2;
  --gold: #d8aa64;
  --gold-2: #f0c987;
  --blue: #65a9ff;
  --violet: #b58cff;
  --green: #7ad6a5;
  --red: #ff7f79;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.36);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(circle at 50% 8%, rgba(216, 170, 100, 0.12), transparent 34%),
    linear-gradient(135deg, #ddd8d1, #bcb5ae);
  color: var(--text);
}

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

button {
  border: 0;
}

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

button,
.clickable {
  -webkit-tap-highlight-color: transparent;
}

#app {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
}

.app-frame {
  width: min(100vw, 468px);
  min-height: 100dvh;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 160px),
    var(--bg);
  box-shadow: var(--shadow);
}

@media (min-width: 560px) {
  #app {
    padding: 18px 0;
    align-items: center;
  }

  .app-frame {
    min-height: min(880px, calc(100dvh - 36px));
    max-height: min(880px, calc(100dvh - 36px));
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 28px;
  }
}

.screen {
  min-height: inherit;
  max-height: inherit;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 18px calc(104px + var(--safe-bottom));
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.24) transparent;
}

.screen.no-nav {
  padding-bottom: calc(26px + var(--safe-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 48px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand-name {
  display: flex;
  align-items: baseline;
  gap: 9px;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 9vw, 42px);
  font-style: italic;
  line-height: 0.95;
  letter-spacing: 0;
  white-space: nowrap;
}

.brand-name span {
  font-family: var(--app-font, Inter, sans-serif);
  font-size: 18px;
  font-style: normal;
  font-weight: 650;
}

.subtitle {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: #111;
  font-weight: 800;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.65), transparent 38%),
    linear-gradient(145deg, #f2c879, #879edb 55%, #171f26);
  border: 1px solid rgba(255, 255, 255, 0.36);
}

.icon-btn,
.back-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  cursor: pointer;
}

.back-btn {
  flex: 0 0 auto;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 22px 0 12px;
}

.section-title h1,
.section-title h2 {
  margin: 0;
  font-size: 21px;
  letter-spacing: 0;
}

.section-title small {
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  min-height: 82px;
  padding: 12px 9px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    var(--panel);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}

.stat-icon {
  color: var(--gold-2);
  font-size: 18px;
  line-height: 1;
}

.stat-label {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.stat-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
  color: var(--text);
  font-size: 25px;
  font-weight: 750;
  line-height: 1;
}

.stat-value small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 13px;
}

.search-field,
.select-field,
.text-field,
.textarea-field {
  width: 100%;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.search-field,
.select-field,
.text-field {
  min-height: 44px;
  padding: 0 12px;
}

.select-field {
  cursor: pointer;
}

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

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

.life-card {
  position: relative;
  aspect-ratio: 63 / 88;
  overflow: hidden;
  border-radius: 8px;
  background: #0f151a;
  border: 1px solid var(--line-strong);
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
}

.life-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.life-card.forging {
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: default;
}

.card-fade {
  position: absolute;
  inset: auto 0 0;
  min-height: 48%;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.86));
}

.card-meta {
  position: absolute;
  inset: auto 11px 11px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 2;
}

.card-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.card-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.rarity-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 24px;
  padding: 0 8px;
  border-radius: 8px;
  font-weight: 800;
  line-height: 1;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
}

.rarity-badge.N {
  color: #c7cbd0;
}

.rarity-badge.R {
  color: #81bcff;
}

.rarity-badge.SR {
  color: #c79cff;
}

.rarity-badge.SSR {
  color: #ffd088;
}

.card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 3;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  max-width: 100%;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--soft);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  font-size: 12px;
  white-space: nowrap;
}

.chip.gold {
  color: #f7d89f;
  background: rgba(216, 170, 100, 0.13);
  border-color: rgba(216, 170, 100, 0.34);
}

.chip.warn {
  color: #ffb9b4;
  background: rgba(255, 127, 121, 0.12);
  border-color: rgba(255, 127, 121, 0.3);
}

.floating-cta {
  position: fixed;
  left: 50%;
  bottom: calc(76px + var(--safe-bottom));
  transform: translateX(-50%);
  width: min(78vw, 340px);
  min-height: 64px;
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 14px;
  padding: 0 26px;
  border-radius: 999px;
  color: #1e160b;
  background: linear-gradient(180deg, #f1ca8c, #d3a25c);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.36);
  cursor: pointer;
  z-index: 20;
}

@media (min-width: 560px) {
  .floating-cta {
    bottom: calc(94px + var(--safe-bottom));
  }
}

.floating-cta strong {
  display: block;
  font-size: 17px;
  line-height: 1.1;
}

.floating-cta small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 500;
}

.scan-mark {
  width: 32px;
  height: 32px;
  position: relative;
}

.scan-mark::before,
.scan-mark::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-bottom-color: transparent;
  border-radius: 5px;
}

.scan-mark::after {
  transform: rotate(90deg);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100vw, 468px);
  min-height: calc(72px + var(--safe-bottom));
  padding: 8px 22px calc(8px + var(--safe-bottom));
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background:
    linear-gradient(180deg, rgba(11, 15, 18, 0), rgba(11, 15, 18, 0.92) 16%),
    rgba(15, 21, 26, 0.94);
  backdrop-filter: blur(18px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 18;
}

.nav-item {
  color: var(--muted);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  cursor: pointer;
}

.nav-item.active {
  color: var(--gold-2);
}

.empty-state,
.panel,
.form-card,
.detail-block {
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02)),
    var(--panel);
  border-radius: 8px;
}

.empty-state {
  min-height: 380px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 32px 22px;
  overflow: hidden;
}

.empty-inner {
  display: grid;
  gap: 14px;
  justify-items: center;
  max-width: 100%;
  min-width: 0;
}

.empty-icon {
  width: 96px;
  height: 134px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--gold-2);
  background:
    linear-gradient(135deg, rgba(216, 170, 100, 0.22), transparent),
    #0d1318;
  border: 1px dashed rgba(216, 170, 100, 0.45);
}

.empty-state h2,
.panel h2 {
  margin: 0;
  font-size: 22px;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.empty-state p,
.panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  width: min(100%, 300px);
  overflow-wrap: anywhere;
}

.primary-btn,
.secondary-btn,
.danger-btn,
.ghost-btn {
  min-height: 46px;
  padding: 0 16px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  cursor: pointer;
}

.primary-btn {
  color: #1d150a;
  background: linear-gradient(180deg, #efca8c, #d5a35c);
}

.secondary-btn {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
}

.danger-btn {
  color: #ffe8e5;
  background: rgba(255, 127, 121, 0.14);
  border: 1px solid rgba(255, 127, 121, 0.34);
}

.ghost-btn {
  color: var(--soft);
  background: transparent;
  border: 1px solid var(--line);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.button-row.single {
  grid-template-columns: 1fr;
}

.scanner-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.camera-box {
  position: relative;
  aspect-ratio: 3 / 4;
  min-height: 420px;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02)),
    #05080b;
  border: 1px solid var(--line-strong);
}

.camera-box video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #05080b;
}

.camera-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  pointer-events: none;
}

.scan-window {
  width: min(78%, 330px);
  aspect-ratio: 1.72 / 1;
  justify-self: center;
  align-self: center;
  border: 1px solid rgba(240, 201, 135, 0.7);
  border-radius: 8px;
  box-shadow:
    0 0 0 999px rgba(0, 0, 0, 0.48),
    inset 0 0 28px rgba(240, 201, 135, 0.13);
  position: relative;
}

.scan-window::after {
  content: "";
  position: absolute;
  left: 10%;
  right: 10%;
  top: 50%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-2), transparent);
  transform: translateY(-50%);
  animation: scanline 1.8s ease-in-out infinite;
}

@keyframes scanline {
  0%,
  100% {
    opacity: 0.35;
    transform: translateY(-36px);
  }
  50% {
    opacity: 1;
    transform: translateY(36px);
  }
}

.camera-status {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(7, 10, 13, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--soft);
  line-height: 1.5;
}

.form-card {
  padding: 16px;
}

.form-grid {
  display: grid;
  gap: 13px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--soft);
  font-size: 13px;
  font-weight: 650;
}

.field small {
  color: var(--muted);
  line-height: 1.5;
}

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

.metadata-item {
  min-height: 64px;
  padding: 11px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  min-width: 0;
}

.metadata-item small {
  display: block;
  color: var(--muted);
  margin-bottom: 5px;
}

.metadata-item strong {
  color: var(--text);
  overflow-wrap: anywhere;
}

.mood-row,
.category-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill-option {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--soft);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  cursor: pointer;
}

.pill-option.active {
  color: #1d150a;
  background: var(--gold-2);
  border-color: var(--gold-2);
}

.product-summary {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.product-thumb {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--gold-2);
  background: #0c1217;
  border: 1px solid var(--line);
  overflow: hidden;
}

.product-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.product-thumb-empty {
  font-size: 24px;
  font-weight: 800;
}

.product-summary h2,
.product-summary h3 {
  margin: 0 0 6px;
  font-size: 18px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.progress-card {
  padding: 18px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 22%, rgba(216, 170, 100, 0.18), transparent 38%),
    var(--panel);
  border: 1px solid var(--line);
}

.forge-orbit {
  width: min(64vw, 260px);
  aspect-ratio: 63 / 88;
  margin: 16px auto 20px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid rgba(240, 201, 135, 0.32);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.08), transparent 44%),
    #0e1419;
  position: relative;
  overflow: hidden;
}

.forge-orbit::before {
  content: "";
  position: absolute;
  width: 68%;
  height: 68%;
  border: 1px solid rgba(240, 201, 135, 0.28);
  border-radius: 50%;
  animation: rotate 4s linear infinite;
}

.forge-orbit::after {
  content: "";
  position: absolute;
  inset: 22px;
  border-radius: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
}

@keyframes rotate {
  to {
    transform: rotate(360deg);
  }
}

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

.progress-line span {
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--gold-2));
  transition: width 0.35s ease;
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  margin-top: 9px;
  color: var(--muted);
  font-size: 13px;
}

.result-card-wrap {
  perspective: 1200px;
  display: grid;
  justify-items: center;
}

.result-card {
  width: min(78vw, 330px);
  aspect-ratio: 63 / 88;
  position: relative;
  transform-style: preserve-3d;
  animation: reveal 1.2s ease forwards;
}

@keyframes reveal {
  0% {
    transform: rotateY(180deg) translateY(12px);
  }
  62% {
    transform: rotateY(8deg) translateY(0);
  }
  100% {
    transform: rotateY(0);
  }
}

.result-card-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 8px;
  backface-visibility: hidden;
  border: 1px solid var(--line-strong);
  background: #0d1318;
}

.result-card-back {
  transform: rotateY(180deg);
  display: grid;
  place-items: center;
  color: var(--gold-2);
}

.result-card-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-card-image {
  width: min(100%, 360px);
  aspect-ratio: 63 / 88;
  margin: 0 auto;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: #0d1318;
}

.detail-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 4px;
  margin: 16px 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
}

.segmented button {
  min-height: 40px;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.segmented button.active {
  color: #1d150a;
  background: var(--gold-2);
}

.detail-block {
  padding: 15px;
  margin-top: 12px;
}

.detail-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  min-height: 34px;
  align-items: start;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  padding: 9px 0;
}

.detail-row:last-child {
  border-bottom: 0;
}

.detail-row small {
  color: var(--muted);
}

.detail-row strong,
.detail-row span {
  overflow-wrap: anywhere;
}

.poster-wrap {
  display: grid;
  justify-items: center;
  gap: 14px;
}

#posterImage {
  width: min(100%, 360px);
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: #111;
}

#posterCanvas {
  width: min(100%, 360px);
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: #111;
}

.switch-row {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.switch-row:last-child {
  border-bottom: 0;
}

.switch-row span {
  color: var(--muted);
  font-size: 13px;
}

.switch {
  width: 46px;
  height: 28px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid var(--line);
  display: flex;
  justify-content: flex-start;
  cursor: pointer;
}

.switch.on {
  justify-content: flex-end;
  background: rgba(216, 170, 100, 0.44);
  border-color: rgba(216, 170, 100, 0.58);
}

.switch::before {
  content: "";
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
}

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

.setting-item {
  padding: 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
}

.setting-item h3 {
  margin: 0 0 5px;
  font-size: 15px;
}

.setting-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.toast-show {
  transform: translate(-50%, 0) !important;
  opacity: 1 !important;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translate(-50%, 14px);
  z-index: 80;
  max-width: min(88vw, 380px);
  padding: 12px 14px;
  border-radius: 8px;
  color: var(--text);
  background: rgba(13, 19, 24, 0.94);
  border: 1px solid var(--line);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.34);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 12px;
}

.tight {
  margin-top: 8px;
}

.divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 14px 0;
}

@media (max-width: 390px) {
  .screen {
    padding-left: 14px;
    padding-right: 14px;
  }

  .stats-grid {
    gap: 8px;
  }

  .stat-card {
    padding: 10px 7px;
  }

  .stat-value {
    font-size: 22px;
  }

  .brand-name {
    font-size: 31px;
  }

  .brand-name span {
    font-size: 16px;
  }

  .floating-cta {
    width: min(86vw, 330px);
    padding: 0 22px;
  }
}
