:root {
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #302b48;
  background: #f5f3fb;
  font-size: 14px;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% -8%, #dfd8ff 0, transparent 28rem),
    radial-gradient(circle at 92% 4%, #d8f4ee 0, transparent 24rem),
    #f5f3fb;
}
main { max-width: 1160px; margin: auto; padding: 14px; }
.hero {
  position: relative;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 112px;
  padding: 10px 16px;
  overflow: hidden;
  border: 1px solid #ffffffb8;
  border-radius: 20px;
  background: linear-gradient(120deg, #ffffffed, #f9f7ffdf 62%, #f0fbf8e8);
  box-shadow: 0 12px 36px #4f416b12;
}
.hero::after {
  content: "";
  position: absolute;
  width: 160px;
  height: 160px;
  right: 14%;
  top: -110px;
  border-radius: 50%;
  background: #826cff16;
}
.pet-portrait {
  position: relative;
  width: 88px;
  height: 88px;
  display: grid;
  place-items: center;
  isolation: isolate;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: transparent;
  box-shadow: none;
}
.pet-portrait:hover { filter: none; background: #ffffff61; }
.personality-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: .7;
  z-index: -1;
}
.pet-avatar {
  width: 76px;
  height: 76px;
  object-fit: contain;
  opacity: 0;
  transform: translateY(3px) scale(.96);
  transition: opacity .2s, transform .2s;
  filter: drop-shadow(0 8px 8px #4e416e25);
}
.pet-avatar.loaded { opacity: 1; transform: translateY(2px) scale(1); }
.pet-avatar-fallback {
  position: absolute;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(145deg, #8a75f5, #5e49d8);
  color: white;
  font-size: 24px;
  font-weight: 800;
  box-shadow: 0 7px 16px #6752de35;
}
.eyebrow { color: #887da6; font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.eyebrow-line { display: flex; align-items: center; gap: 7px 10px; min-width: 0; flex-wrap: wrap; }
h1 { margin: 2px 0 1px; font-size: 23px; letter-spacing: -.03em; }
.pet-name { color: #6d58df; font-size: 16px; font-weight: 700; }
.hero-copy { min-width: 0; }
.hero-copy p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-line { display: flex; align-items: center; gap: 5px; min-width: 0; }
.account-line p { min-width: 0; }
.account-visibility {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 25px;
  height: 25px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #756b91;
  box-shadow: none;
}
.account-visibility:hover { background: #ece8fa; color: #5f4bc8; filter: none; }
.account-visibility svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.profile-facts { display: flex; align-items: center; gap: 5px 10px; min-width: 0; flex-wrap: wrap; color: #8a829e; font-size: 9px; }
.profile-facts span { white-space: nowrap; }
.profile-facts b { color: #5e5575; font-weight: 650; }
.profile-facts span:last-child { min-width: 0; max-width: 230px; overflow: hidden; text-overflow: ellipsis; }
.hero-status { display: grid; justify-items: end; gap: 6px; color: #8a829e; font-size: 10px; }
.automation-controls { display: flex; align-items: center; gap: 7px; }
.title, .actions, .counts { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
h2 { margin: 0 0 9px; color: #3b3451; font-size: 15px; }
p { margin: 3px 0; color: #7a728e; font-size: 11px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #ece8ff;
  color: #5b49ce;
  font-size: 11px;
  font-weight: 700;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: #e1f7ee; color: #187d53; }
.pill.warn { background: #fff0d7; color: #9b6109; }
.metrics {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 7px;
  margin: 10px 0;
}
.metrics article, .panel {
  border: 1px solid #e9e5f1;
  background: #fffffff0;
  box-shadow: 0 4px 16px #392e5610;
}
.metrics article {
  position: relative;
  min-width: 0;
  padding: 9px 11px;
  overflow: hidden;
  border-radius: 11px;
}
.metrics article::after {
  content: "";
  position: absolute;
  width: 35px;
  height: 35px;
  right: -14px;
  bottom: -16px;
  border-radius: 50%;
  background: var(--metric-accent, #7866e8);
  opacity: .1;
}
.metrics label { display: block; color: #837b95; font-size: 10px; }
.metrics strong { display: block; margin-top: 1px; font-size: 18px; line-height: 1.2; white-space: nowrap; }
.metric-art {
  position: absolute;
  right: 6px;
  top: 50%;
  width: 30px;
  height: 30px;
  object-fit: contain;
  opacity: .2;
  transform: translateY(-50%);
}
.metric-gold { --metric-accent: #e3a81e; }
.metric-gold strong { color: #a36e00; }
.metric-feel { --metric-accent: #f06c91; }
.metric-energy { --metric-accent: #52a768; }
.metric-clean { --metric-accent: #46a4d8; }
.metric-total { --metric-accent: #8b6fe8; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.panel { padding: 12px; border-radius: 13px; }
.span2 { grid-column: span 2; }
.actions { justify-content: flex-start; margin-top: 9px; flex-wrap: wrap; }
button {
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #7864e9, #634ed6);
  color: white;
  padding: 7px 13px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  box-shadow: 0 4px 10px #6753da28;
}
button:hover { filter: brightness(1.04); }
button.secondary { background: #efedf6; color: #4b445e; box-shadow: none; }
button.success { background: linear-gradient(135deg, #2aa56a, #218758); }
button.danger { background: linear-gradient(135deg, #e25858, #cc3f47); }
button.small { padding: 5px 10px; font-size: 11px; }
button:disabled { opacity: .5; cursor: wait; }
dl { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0; }
dt { color: #7c748a; font-size: 12px; }
dd { max-width: 280px; margin: 0; overflow: hidden; color: #3d374f; font-size: 12px; font-weight: 700; text-overflow: ellipsis; }
.task-content { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; }
.task-content dl { min-width: 0; }
.story-icon { width: 70px; height: 70px; object-fit: contain; filter: drop-shadow(0 5px 7px #3b315626); }
.inventory dd { min-height: 20px; }
.counts { justify-content: flex-start; flex-wrap: wrap; }
.counts span { padding: 5px 9px; border-radius: 7px; background: #f3f0fa; color: #665e78; font-size: 11px; }
.counts b { margin-left: 3px; color: #5543c4; }
.reward-count { display: inline-flex; align-items: center; }
.reward-count img { width: 18px; height: 18px; margin-right: 3px; object-fit: contain; }
.medals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.medal {
  position: relative;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px;
  border: 1px solid #e9e3f0;
  border-radius: 10px;
  background: linear-gradient(145deg, #fffdf8, #f8f4ff);
}
.medal img { width: 58px; height: 58px; object-fit: contain; filter: drop-shadow(0 4px 5px #4b3b6220); }
.medal.unowned { opacity: .48; filter: grayscale(1); }
.medal em { position: absolute; top: 5px; right: 6px; padding: 2px 5px; border-radius: 999px; background: #7d5ac7; color: #fff; font-size: 8px; font-style: normal; }
.medal b, .medal small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.medal b { font-size: 12px; }
.medal small { margin-top: 2px; color: #827991; font-size: 9px; }
.interactions { display: grid; gap: 6px; max-height: 340px; overflow: auto; }
.interaction { padding: 8px 10px; border: 1px solid #ebe6f2; border-radius: 9px; background: #fcfaff; }
.interaction div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.interaction b { color: #443a58; font-size: 12px; }
.interaction span { color: #8a8298; font-size: 9px; text-align: right; }
.interaction p { margin: 4px 0 0; color: #645b72; font-size: 11px; line-height: 1.45; }
.career-tree { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.career-branch { min-width: 0; padding: 9px 10px; border: 1px solid #e7e1ef; border-radius: 10px; background: linear-gradient(145deg, #fff, #faf8ff); }
.career-branch h3 { margin: 0; color: #473e59; font-size: 13px; }
.career-branch small { display: block; margin-top: 2px; color: #8a8296; font-size: 9px; }
.career-branch .career-reason { margin-top: 5px; color: #a05e42; white-space: normal; }
.settings-title { position: sticky; top: 0; z-index: 3; margin: -4px -4px 8px; padding: 4px; background: #fffffff2; backdrop-filter: blur(8px); }
.settings-title h2 { margin-bottom: 0; }
form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; align-items: start; }
fieldset {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 9px;
  min-width: 0;
  padding: 9px;
  border: 1px solid #ebe7f2;
  border-radius: 10px;
  background: #fbfaff;
}
fieldset.settings-wide { grid-column: span 2; grid-template-columns: repeat(4, minmax(0, 1fr)); }
legend { padding: 0 5px; color: #584d73; font-size: 12px; font-weight: 800; }
fieldset label:not(.check) { display: grid; gap: 3px; margin: 0; color: #6e667b; font-size: 11px; }
.check { display: flex; align-items: center; min-height: 29px; margin: 0; color: #514b60; font-size: 11px; }
fieldset p { grid-column: span 2; margin: 0; }
.settings-wide p { grid-column: span 4; }
.catalog-preview {
  grid-column: span 2;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 6px 7px;
  border: 1px solid #e7e2f0;
  border-radius: 8px;
  background: #fff;
}
.catalog-preview img { width: 42px; height: 42px; object-fit: contain; }
.catalog-preview b, .catalog-preview small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catalog-preview b { font-size: 11px; }
.catalog-preview small { margin-top: 2px; color: #81788f; font-size: 9px; }
.compat-warning { padding: 6px 8px; border-radius: 6px; background: #fff0e7; color: #a34b26; font-size: 10px; }
input, select {
  width: 100%;
  min-height: 31px;
  border: 1px solid #ddd8e8;
  border-radius: 7px;
  outline: none;
  padding: 5px 7px;
  background: white;
  color: #393348;
  font: inherit;
  font-size: 11px;
}
input:focus, select:focus { border-color: #8875e9; box-shadow: 0 0 0 2px #806be51f; }
.check input { width: auto; min-height: auto; margin-right: 5px; accent-color: #6e59df; }
pre {
  margin: 0;
  max-height: 200px;
  overflow: auto;
  border-radius: 8px;
  padding: 9px;
  background: #292638;
  color: #e8e5f5;
  white-space: pre-wrap;
  font: 10px/1.55 ui-monospace, "SFMono-Regular", Consolas, monospace;
}
.error { margin-top: 9px; padding: 7px; border-radius: 7px; background: #ffe8e8; color: #a32d2d; }
.hidden { display: none !important; }
#toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  padding: 8px 12px;
  border-radius: 8px;
  background: #292638;
  color: white;
  opacity: 0;
  pointer-events: none;
  transition: .2s;
}
#toast.show { opacity: 1; }
dialog {
  position: fixed;
  max-width: min(92vw, 620px);
  max-height: 90vh;
  overflow: visible;
  border: 1px solid #ffffffc7;
  border-radius: 20px;
  padding: 14px;
  background: linear-gradient(145deg, #ffffff, #f4f0ff);
  box-shadow: 0 30px 90px #261c4350;
}
dialog::backdrop { background: #231b3866; backdrop-filter: blur(5px); }
dialog > img { display: block; max-width: 100%; max-height: 72vh; margin: auto; object-fit: contain; }
dialog p { text-align: center; font-size: 12px; font-weight: 700; }
.dialog-close {
  position: absolute;
  right: -10px;
  top: -10px;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  background: #302943;
  font-size: 20px;
  line-height: 30px;
}
.announcement-dialog { width: min(92vw, 500px); overflow: hidden; padding: 22px; }
.announcement-dialog h2 { margin: 5px 0 12px; font-size: 20px; }
.announcement-content { max-height: 52vh; overflow: auto; color: #514960; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; }
.announcement-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
@media (max-width: 900px) {
  .metrics { grid-template-columns: repeat(4, 1fr); }
  .medals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 750px) {
  .hero { grid-template-columns: 72px minmax(0, 1fr); min-height: 94px; padding: 8px 11px; }
  .pet-portrait { width: 68px; height: 68px; }
  .pet-avatar { width: 60px; height: 60px; }
  .hero-status { grid-column: span 2; grid-row: 2; display: flex; justify-content: space-between; width: 100%; }
  .grid, form { grid-template-columns: 1fr; }
  .career-tree { grid-template-columns: 1fr; }
  .span2, fieldset.settings-wide { grid-column: auto; }
  fieldset.settings-wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-wide p { grid-column: span 2; }
}
@media (max-width: 480px) {
  main { padding: 8px; }
  .hero { border-radius: 14px; }
  h1 { font-size: 20px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  fieldset, fieldset.settings-wide { grid-template-columns: 1fr; }
  fieldset p, .settings-wide p { grid-column: auto; }
  .catalog-preview { grid-column: auto; }
  .medals { grid-template-columns: 1fr; }
  .career-legend small { width: 100%; margin-left: 0; }
  dd { max-width: 190px; }
}
