* {
  box-sizing: border-box;
}

:root {
  --page-bg: #eaf8fe;
  --panel-bg: #f6fcff;
  --panel-border: #82c8e8;
  --panel-line: #bae5f5;
  --title-blue: #0799ca;
  --deep-blue: #075984;
  --button-blue: #168bd3;
  --button-blue-dark: #0873b9;
  --button-yellow: #fff7bf;
  --button-yellow-border: #d7bd43;
  --accent-pink: #ff6aa8;
  --text: #17496a;
  --soft-text: #5b91a9;
  --card-bg: #f8fdff;
  --white: #ffffff;
}

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

html {
  overflow-y: scroll;
  scrollbar-gutter: stable;
  scrollbar-width: auto;
  scrollbar-color: var(--button-blue) #dff6ff;
}

html::-webkit-scrollbar {
  width: 14px;
}

html::-webkit-scrollbar-track {
  background: #dff6ff;
  border-left: 1px solid var(--panel-border);
}

html::-webkit-scrollbar-thumb {
  min-height: 56px;
  border: 2px solid #dff6ff;
  border-radius: 8px;
  background: linear-gradient(180deg, #35bde9, var(--button-blue-dark));
}

html::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #20aee0, #0567a6);
}

html::-webkit-scrollbar-thumb:active {
  background: var(--deep-blue);
}

body {
  margin: 0;
  font-family: "Microsoft YaHei", Arial, sans-serif;
  color: var(--text);
  overflow-x: clip;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(234, 248, 254, 0.52)),
    repeating-linear-gradient(135deg, #e5f6fc 0 18px, #f4fcff 18px 36px);
}

button {
  font: inherit;
}

.app-window {
  width: 100%;
  max-width: 1320px;
  min-height: 100vh;
  margin: 0 auto;
  background: #dff6ff;
  border-left: 1px solid #48b7dc;
  border-right: 1px solid #48b7dc;
}

.window-bar {
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  background: linear-gradient(180deg, #21c7e5, #08a8d0);
  border-bottom: 1px solid #0187b3;
  color: #ffffff;
  overflow: hidden;
}

.window-title {
  font-size: 12px;
  font-weight: 700;
  line-height: 14px;
  text-shadow: 0 1px 0 rgba(0, 87, 126, 0.6);
}

.window-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.window-actions span {
  width: 10px;
  height: 2px;
  display: block;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 0 rgba(0, 80, 120, 0.35);
}

.workspace {
  height: calc(100vh - 14px);
  min-height: 560px;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  gap: 14px;
  padding: 7px 13px 14px 0;
}

.preview-panel {
  padding-left: 0;
  border-right: 1px solid #8fd4ee;
}

.panel-card,
.closet-panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(238, 250, 255, 0.92));
  border: 1px solid var(--panel-border);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 4px 12px rgba(19, 129, 177, 0.12);
}

.panel-card {
  width: 262px;
  margin: 7px 14px 0 15px;
  padding: 12px 0 11px;
  border-radius: 6px;
}

.panel-title {
  width: calc(100% - 24px);
  height: 39px;
  margin: 0 auto 11px;
  padding: 0 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 4px;
  color: #ffffff;
  background: linear-gradient(180deg, #40c2ed, #0e9bd2);
  font-size: 17px;
  font-weight: 800;
  text-shadow: 0 1px 0 rgba(0, 84, 128, 0.48);
}

.panel-sun {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff17a;
  font-size: 18px;
}

.avatar-box {
  width: calc(100% - 28px);
  height: 260px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #a9daf0;
  border-radius: 4px;
  background: linear-gradient(180deg, #ffffff, #eaf8fe);
  box-shadow: inset 0 0 0 4px rgba(218, 243, 252, 0.72);
}

.avatar {
  position: relative;
  width: 140px;
  height: 226px;
  overflow: hidden;
  background: transparent;
  image-rendering: auto;
}

.layer {
  position: absolute;
  inset: 0;
  width: 140px;
  height: 226px;
  object-fit: contain;
  display: none;
  pointer-events: none;
}

#layer-background { z-index: 0; }
#layer-front { z-index: 10; }
#layer-wing { z-index: 20; }
#layer-hair-back { z-index: 25; }
#layer-clothes { z-index: 30; }
#layer-bottom { z-index: 31; }
#layer-top { z-index: 32; }
#layer-body { z-index: 40; }
#layer-neck { z-index: 50; }
#layer-hair { z-index: 60; }
#layer-hat { z-index: 70; }
#layer-glasses { z-index: 80; }
#layer-earring { z-index: 90; }
#layer-face-1 { z-index: 100; }
#layer-face-2 { z-index: 101; }
#layer-face-3 { z-index: 102; }
#layer-hand { z-index: 110; }
#layer-effect { z-index: 120; }
#layer-suit { z-index: 130; }
#layer-text { z-index: 140; }
#layer-frame { z-index: 150; }

.saved-preview {
  position: absolute;
  inset: 0;
  width: 140px;
  height: 226px;
  object-fit: contain;
  display: none;
  z-index: 200;
}

.account-status {
  margin: 10px 20px 0;
  padding: 7px 8px;
  border: 1px solid #9bd7ef;
  background: #f3fbff;
  color: #39728f;
  font-size: 12px;
  line-height: 1.5;
}

.account-status.success { border-color: #73c884; background: #effcf2; color: #26703a; }
.account-status.error { border-color: #e49595; background: #fff4f4; color: #a33838; }

.friend-preview {
  margin: 34px;
  padding: 28px;
  border: 1px solid #82c9e7;
  background: linear-gradient(#f7fdff, #e6f7ff);
  color: #235c78;
  text-align: center;
}

.friend-preview h1 { margin: 0 0 14px; color: #0b78ae; }
.friend-preview p { margin: 0 auto 22px; max-width: 420px; line-height: 1.8; }

.preview-edit-button {
  min-width: 150px;
  padding: 8px 18px;
  border: 1px solid #1688bd;
  border-radius: 4px;
  background: linear-gradient(#49c9f0, #159bd0);
  color: #fff;
  font-weight: bold;
  cursor: pointer;
}

.action-grid {
  width: calc(100% - 40px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px 6px;
}

.action-grid[hidden],
.friend-preview[hidden],
#editorPanel[hidden] {
  display: none !important;
}

.tool-btn {
  min-width: 0;
  min-height: 28px;
  padding: 5px 7px;
  border: 1px solid #0984bd;
  border-radius: 4px;
  color: #075984;
  background: linear-gradient(180deg, #ffffff, #c9effd);
  box-shadow: 0 2px 0 rgba(0, 119, 172, 0.18);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.tool-btn:hover:not(:disabled) {
  color: #ffffff;
  background: linear-gradient(180deg, #38bce9, #108fd0);
}

.tool-btn:disabled,
.tool-btn.is-muted:disabled {
  color: #7fa7b9;
  border-color: #b9d7e4;
  background: linear-gradient(180deg, #f7fbfd, #dfeef5);
  cursor: not-allowed;
  box-shadow: none;
}

.closet-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 7px;
  border-radius: 6px;
  overflow: hidden;
}

#editorPanel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.gender-switch {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border-bottom: 1px solid #d3edf8;
  background: linear-gradient(180deg, #ecfbff, #f9feff);
}

.gender-switch span {
  color: var(--deep-blue);
  font-size: 13px;
  font-weight: 800;
}

.gender-switch button,
.category-tabs button {
  min-height: 28px;
  border: 1px solid #1b9ed2;
  border-radius: 4px;
  color: #0a6093;
  background: linear-gradient(180deg, #ffffff, #d8f4ff);
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 2px 0 rgba(10, 117, 171, 0.16);
}

.gender-switch button {
  width: 40px;
  padding: 4px 0;
  font-size: 13px;
}

.gender-switch button.active,
.category-tabs button.active {
  color: #ffffff;
  border-color: #0476b5;
  background: linear-gradient(180deg, #20b8ea, #087dca);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 2px 0 rgba(8, 112, 173, 0.24);
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 9px 12px 10px;
  border-bottom: 1px solid #cce9f5;
  background: #eefaff;
}

.category-tabs button {
  padding: 5px 10px;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.category-tabs button.has-selection:not(.active) {
  border-color: var(--accent-pink);
  color: #b42165;
  background: linear-gradient(180deg, #ffffff, #ffe8f2);
}

.category-tabs button:first-child {
  border-color: var(--button-yellow-border);
  color: #745f00;
  background: linear-gradient(180deg, #fffdf0, var(--button-yellow));
}

.category-tabs button:first-child.active {
  border-color: #caa900;
  color: #5a4700;
  background: linear-gradient(180deg, #fff4a7, #ffd75e);
}

.category-head {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border-bottom: 1px solid #d3edf8;
  background: #f7fcff;
}

.category-meta {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.category-head h1 {
  margin: 0;
  color: var(--deep-blue);
  font-size: 20px;
  line-height: 1.2;
  white-space: nowrap;
}

.category-head span {
  color: var(--soft-text);
  font-size: 14px;
  white-space: nowrap;
}

.admin-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-actions[hidden] {
  display: none;
}

.admin-btn {
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid #0984bd;
  border-radius: 4px;
  color: #075984;
  background: linear-gradient(180deg, #ffffff, #c9effd);
  box-shadow: 0 2px 0 rgba(0, 119, 172, 0.16);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.admin-btn:hover:not(:disabled) {
  color: #ffffff;
  background: linear-gradient(180deg, #38bce9, #108fd0);
}

.admin-btn-danger {
  border-color: #e75f8d;
  color: #ad2258;
  background: linear-gradient(180deg, #ffffff, #ffe4ef);
}

.admin-btn-danger:hover:not(:disabled) {
  border-color: #cc2867;
  color: #ffffff;
  background: linear-gradient(180deg, #ff78aa, #db2d70);
}

.admin-btn:disabled {
  color: #7fa7b9;
  border-color: #b9d7e4;
  background: linear-gradient(180deg, #f7fbfd, #dfeef5);
  cursor: not-allowed;
  box-shadow: none;
}

.items-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  gap: 13px 14px;
  align-content: start;
  overflow-y: auto;
  padding: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(236, 249, 255, 0.92)),
    repeating-linear-gradient(90deg, rgba(164, 220, 241, 0.18) 0 1px, transparent 1px 28px);
}

@media (min-width: 861px) {
  .workspace {
    height: auto;
    min-height: calc(100vh - 14px);
    align-items: start;
  }

  .preview-panel {
    position: sticky;
    top: 14px;
    align-self: start;
  }

  .closet-panel {
    overflow: visible;
  }

  .items-grid {
    overflow-y: visible;
  }
}

.item-card {
  min-height: 198px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 8px 8px 9px;
  border: 1px solid #bde2f2;
  border-radius: 4px;
  background: linear-gradient(180deg, #ffffff, var(--card-bg));
  color: var(--text);
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.item-card:hover {
  border-color: #31aee1;
  transform: translateY(-1px);
  box-shadow: 0 5px 13px rgba(13, 121, 177, 0.16);
}

.item-card.selected {
  border-color: #087dca;
  background: linear-gradient(180deg, #effaff, #d7f1ff);
  box-shadow: inset 0 0 0 2px rgba(44, 170, 226, 0.22);
}

.item-card.uploaded-asset {
  justify-content: center;
}

.thumb,
.empty-thumb,
.hair-thumb {
  width: 96px;
  height: 155px;
  flex: 0 0 auto;
  border: 1px solid #bae0f0;
  border-radius: 3px;
  background: linear-gradient(180deg, #ffffff, #effaff);
}

.thumb {
  object-fit: contain;
}

.empty-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #76a7bf;
  font-size: 13px;
}

.hair-thumb {
  position: relative;
  overflow: hidden;
}

.hair-thumb img {
  position: absolute;
  inset: 0;
  width: 96px;
  height: 155px;
  object-fit: contain;
}

.hair-thumb .hair-back {
  z-index: 1;
}

.hair-thumb .hair-front {
  z-index: 2;
}

.item-name {
  width: 100%;
  margin-top: 8px;
  color: #1d5578;
  font-size: 13px;
  line-height: 1.3;
  text-align: center;
  word-break: break-word;
}

.notice-modal {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.notice-modal.show {
  display: flex;
}

.notice-mask {
  position: absolute;
  inset: 0;
  background: rgba(11, 76, 112, 0.38);
}

.notice-panel {
  position: relative;
  width: min(520px, 94vw);
  padding: 24px 24px 20px;
  border: 1px solid #82c8e8;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 42px rgba(6, 84, 130, 0.24);
}

.notice-panel h2 {
  margin: 0 0 14px;
  color: var(--deep-blue);
  font-size: 22px;
  text-align: center;
}

.notice-content {
  padding: 14px 15px;
  border: 1px solid #c6e9f6;
  border-radius: 6px;
  background: #f5fcff;
  color: #23536f;
  font-size: 15px;
  line-height: 1.75;
}

.notice-content p {
  margin: 0 0 8px;
}

.notice-content p:last-child {
  margin-bottom: 0;
}

.notice-close {
  position: absolute;
  top: 9px;
  right: 10px;
  width: 30px;
  height: 30px;
  border: 1px solid #bde2f2;
  border-radius: 50%;
  color: #0a6093;
  background: #eefaff;
  cursor: pointer;
  font-size: 22px;
  line-height: 25px;
}

.notice-ok {
  width: 150px;
  min-height: 34px;
  display: block;
  margin: 16px auto 0;
  border: 1px solid #0873b9;
  border-radius: 5px;
  color: #ffffff;
  background: linear-gradient(180deg, #20b8ea, #087dca);
  cursor: pointer;
  font-weight: 800;
}

.admin-login-panel {
  width: min(380px, 94vw);
}

.admin-login-form {
  display: grid;
  gap: 10px;
}

.admin-login-form label {
  color: var(--deep-blue);
  font-size: 14px;
  font-weight: 800;
}

.admin-login-form input {
  width: 100%;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid #9bd4ec;
  border-radius: 4px;
  color: var(--text);
  background: #f8fdff;
  font: inherit;
}

.admin-login-form input:focus {
  outline: 2px solid rgba(30, 166, 222, 0.28);
  border-color: #1b9ed2;
}

.admin-login-error {
  min-height: 18px;
  margin: 0;
  color: #b42165;
  font-size: 13px;
  line-height: 1.35;
}

@media (max-width: 860px) {
  .app-window {
    min-height: 100dvh;
  }

  .window-bar {
    height: 20px;
  }

  .workspace {
    height: auto;
    min-height: calc(100dvh - 20px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 8px 10px;
  }

  .preview-panel {
    border-right: 0;
  }

  .panel-card {
    width: 100%;
    margin: 0;
    padding: 8px 0 9px;
    border-radius: 0 0 6px 6px;
  }

  .panel-title {
    height: 32px;
    margin-bottom: 7px;
    font-size: 15px;
  }

  .avatar-box {
    height: 246px;
    margin-bottom: 8px;
  }

  .action-grid {
    grid-template-columns: repeat(3, minmax(74px, 1fr));
  }

  .tool-btn {
    min-height: 30px;
    padding: 5px 4px;
    white-space: normal;
  }

  .closet-panel {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-top: 0;
  }

  .gender-switch,
  .category-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .gender-switch::-webkit-scrollbar,
  .category-tabs::-webkit-scrollbar {
    display: none;
  }

  .category-tabs button {
    flex: 0 0 auto;
  }

  .category-head {
    min-height: 38px;
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
    padding: 7px 10px;
  }

  .category-meta {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }

  .category-head h1 {
    font-size: 17px;
  }

  .category-head span {
    font-size: 12px;
  }

  .admin-actions {
    width: 100%;
    gap: 7px;
  }

  .admin-btn {
    flex: 1 1 0;
    min-width: 0;
    white-space: normal;
  }

  .items-grid {
    flex: 1 1 auto;
    min-height: 260px;
    height: auto;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 10px;
    padding: 10px;
  }

  .item-card {
    min-height: 158px;
    padding: 7px 6px;
  }

  .thumb,
  .empty-thumb,
  .hair-thumb {
    width: 76px;
    height: 122px;
  }

  .hair-thumb img {
    width: 76px;
    height: 122px;
  }

  .item-name {
    font-size: 12px;
    margin-top: 6px;
  }
}
