:root {
  --studio-navy: #081d35;
  --studio-gold: #e6c776;
  --studio-paper: #fffdf5;
}
body[data-page='thantai'],
body[data-page='collection'] {
  background: radial-gradient(ellipse at 50% 0, #163755, #041429 80%);
  color: #fff;
}
body[data-page='thantai'] .tier-chip,
body[data-page='collection'] .tier-chip {
  display: none !important;
}
.studio-shell {
  max-width: 1680px;
  margin: auto;
  padding: 22px 26px 60px;
}
.studio-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
}
.studio-heading h1 {
  font: 700 clamp(27px, 3vw, 44px) var(--app-font);
  color: #f0d590;
  margin: 0 0 6px;
}
.studio-heading p {
  margin: 0;
  color: #e3e8ee;
}
.studio-heading nav {
  display: flex;
  gap: 8px;
}
.studio-shell button,
.studio-dialog button {
  cursor: pointer;
  font: inherit;
  border: 1px solid #c8ae7455;
  border-radius: 9px;
  padding: 10px 13px;
  min-height: 40px;
  background: transparent;
  color: inherit;
}
.studio-shell button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.studio-shell button.active {
  background: #c70030;
  color: #fff;
  border-color: #e13755;
}
.studio-columns {
  display: grid;
  grid-template-columns: 245px minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}
.studio-side {
  background: #071e36;
  border: 1px solid #caae69;
  border-radius: 15px;
  padding: 18px;
  color: #f7f1df;
}
.studio-side h2 {
  font-size: 22px;
}
.studio-side a,
.studio-side > button {
  display: block;
  width: 100%;
  color: inherit;
  text-align: left;
  margin: 8px 0;
}
.studio-side p,
.studio-side small {
  font-size: 13px;
  color: #d2dce7;
}
.companion {
  width: 100%;
  height: 200px;
  object-fit: contain;
  background: radial-gradient(#a4813c33, transparent);
  border-radius: 10px;
}
.studio-paper {
  background: var(--studio-paper);
  color: #16253a;
  border-radius: 14px;
  padding: 18px;
  border: 1px solid #eddfbf;
}
.studio-paper h2 {
  font-size: 20px;
  margin: 0 0 15px;
}
.studio-paper header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.studio-paper header button {
  font-size: 12px;
}
.studio-summary {
  display: grid;
  gap: 14px;
}
.studio-summary label {
  display: block;
  margin: 12px 0;
  font-size: 13px;
}
.studio-summary label input:not([type='checkbox']) {
  width: 100%;
}
.studio-shell input,
.studio-dialog input,
.studio-dialog textarea {
  font: inherit;
  padding: 10px;
  border: 1px solid #ccd2db;
  border-radius: 8px;
  background: white;
  color: #14243b;
  max-width: 100%;
}
.studio-primary {
  background: #df0033 !important;
  color: #fff !important;
  font-weight: 700 !important;
  display: block;
  width: 100%;
  margin: 12px 0;
}
.studio-paper small {
  display: block;
  font-size: 12px;
  color: #5b6270;
}
.game-tabs {
  display: flex;
  gap: 4px;
}
.game-tabs button {
  flex: 1;
  padding: 7px;
  font-size: 12px;
}
.game-tabs img {
  width: 52px;
  height: 30px;
  object-fit: contain;
  display: block;
  margin: auto;
}
#chat-log {
  min-height: 260px;
  max-height: 410px;
  overflow: auto;
  padding: 18px 0;
}
.chat-message {
  max-width: 85%;
  padding: 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e4e3df;
  margin: 10px 0;
  font-size: 14px;
  white-space: pre-wrap;
}
.chat-message.me {
  margin-left: auto;
  background: #eeebff;
}
.suggestion {
  padding: 18px;
  background: #fff4de;
  border: 1px solid #e4c984;
  border-radius: 12px;
}
.studio-balls {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 15px 0;
}
.studio-balls span {
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 20%, #ff8084, #e2002d 65%, #a40026);
  color: white;
  font-weight: 800;
  box-shadow: 0 2px 3px #77002122;
}
.prompt-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.prompt-row button {
  font-size: 12px;
  padding: 6px 10px;
  min-height: 32px;
}
#chat-form {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}
#chat-input {
  flex: 1;
  min-width: 0;
}
#chat-form button {
  background: #d80030;
  color: white;
}
.studio-dialog {
  width: min(580px, 92vw);
  max-height: 85vh;
  overflow: auto;
  border: 1px solid #c4a761;
  border-radius: 16px;
  padding: 22px;
  background: #fffdf5;
  color: #14243b;
}
.studio-dialog::backdrop {
  background: #061324aa;
}
.studio-dialog header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.studio-dialog label {
  display: block;
  margin: 14px 0;
}
.studio-dialog input,
.studio-dialog textarea {
  display: block;
  width: 100%;
  margin-top: 7px;
}
.collection-heading {
  text-align: center;
  justify-content: center;
}
.collection-columns {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 260px;
  gap: 18px;
}
.mascot-detail {
  text-align: center;
}
.mascot-art {
  background-image: url('../img/brand/collection-sheet.webp');
  background-size: 400% 200%;
  background-position: var(--mx) var(--my);
  aspect-ratio: 1;
  border-radius: 12px;
  width: 100%;
}
.mascot-detail .mascot-art {
  border: 1px solid #dabc76;
}
.mascot-detail small {
  display: block;
  margin-top: 12px;
}
.gallery header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.gallery h2 {
  margin: 0;
}
.gallery progress {
  width: 100%;
  accent-color: #efcb71;
  height: 8px;
  margin: 12px 0;
}
.gallery nav {
  display: flex;
  gap: 7px;
  justify-content: flex-end;
  margin-bottom: 12px;
}
.gallery nav button {
  font-size: 12px;
  padding: 6px 10px;
  min-height: 32px;
}
.mascot-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.studio-shell .mascot-card {
  padding: 5px;
  background: #fff9e9;
  color: #273346;
  border: 2px solid #b39760;
  overflow: hidden;
}
.mascot-card.selected {
  box-shadow: 0 0 0 3px #ffeab5;
}
.mascot-card b {
  display: block;
  font: 700 14px var(--app-font);
  margin: 9px 0 5px;
}
.mascot-card small {
  display: block;
  font-size: 11px;
  color: #485743;
  margin-bottom: 7px;
}
.gift-panel {
  text-align: center;
}
.gift-panel img {
  width: 140px;
  height: 155px;
  object-fit: contain;
  display: block;
  margin: 8px auto;
}
.gift-panel strong {
  color: #bd1639;
}
.studio-dialog .mascot-art {
  max-width: 270px;
  margin: 15px auto;
}
.studio-shell a {
  color: inherit;
}
.studio-shell h3 {
  font-size: 17px;
}
body[data-page='results'] .wrap {
  max-width: 1680px;
  width: 96%;
}
body[data-page='results'] .buy {
  margin-bottom: 12px;
}
body[data-page='results'] .buy-h {
  font-size: 28px;
}
body[data-page='results'] #result-panel {
  max-width: none;
  display: grid;
  grid-template-columns: minmax(300px, 32%) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
#analysis-studio {
  grid-column: 2;
  grid-row: 1 / span 6;
  background: #fffdf7;
  padding: 16px;
  border: 1px solid #e2dccf;
  border-radius: 13px;
  min-width: 0;
}
#latest {
  grid-column: 1;
}
body[data-page='results'] #latest > .audit-panel {
  display: none;
}
body[data-page='results'] #latest .kq-card {
  background: #10283f;
  color: white;
  border-radius: 13px;
}
body[data-page='results'] #latest .audit-meta,
body[data-page='results'] #latest .kq-h time {
  color: #d6e1eb;
}
body[data-page='results'] #latest .audit-scroll,
body[data-page='results'] #latest .audit-message,
body[data-page='results'] #latest h3 {
  display: none;
}
body[data-page='results'] #latest .kq-jp b {
  color: #ffb0bf;
}
body[data-page='results'] #rbody,
body[data-page='results'] #history-heading {
  grid-column: 1;
}
body[data-page='results'] #retention-stats {
  display: none;
}
#analysis-studio h2 {
  font-size: 21px;
  margin: 0 0 6px;
}
.analysis-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.analysis-toolbar button,
.analysis-toolbar select {
  padding: 8px;
  border: 1px solid #c6d2df;
  border-radius: 7px;
  background: white;
  min-height: 36px;
}
.analysis-toolbar button.active {
  background: #185f92;
  color: white;
}
.analysis-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0;
}
.analysis-metrics span {
  background: #eef4fa;
  padding: 10px;
  border-radius: 7px;
  font-size: 13px;
}
.analysis-metrics b {
  display: block;
  font-size: 20px;
}
.analysis-bars {
  height: 225px;
  display: flex;
  align-items: stretch;
  gap: 3px;
  padding: 10px 4px;
  border-bottom: 1px solid #aab5c1;
  overflow: auto;
}
.analysis-bars > div {
  min-width: 8px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
}
.analysis-bars i {
  width: 75%;
  min-height: 2px;
  background: #58a7d7;
  border-radius: 3px 3px 0 0;
}
.analysis-bars small {
  font-size: 9px;
  writing-mode: vertical-rl;
  margin-top: 5px;
}
.analysis-bars b {
  font-size: 10px;
}
.heatmap {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  margin: 15px 0;
}
.heatmap span {
  padding: 8px 2px;
  border-radius: 5px;
  text-align: center;
  background: var(--heat);
  font-size: 12px;
  color: #45231d;
}
.analysis-note {
  background: #edf4fa;
  color: #31435b;
  font-size: 13px;
  padding: 12px;
  border-radius: 8px;
  line-height: 1.5;
}
.analysis-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.analysis-table td,
.analysis-table th {
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid #e0e5eb;
}
.analysis-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.analysis-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.analysis-controls input,
.analysis-controls select {
  max-width: 100%;
  padding: 8px;
}
.analysis-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.analysis-actions button {
  padding: 8px;
  border: 1px solid #bbc9d8;
  background: white;
  border-radius: 6px;
  min-height: 36px;
}
@media (max-width: 1150px) {
  .studio-columns {
    grid-template-columns: 200px minmax(0, 1fr);
  }
  .studio-summary {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, 1fr);
  }
  .collection-columns {
    grid-template-columns: 220px minmax(0, 1fr);
  }
  .mascot-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
@media (max-width: 760px) {
  .studio-shell {
    padding: 14px 12px 50px;
  }
  .studio-heading {
    display: block;
  }
  .studio-heading nav {
    margin-top: 15px;
    flex-wrap: wrap;
  }
  .studio-heading nav button {
    font-size: 12px;
  }
  .studio-columns,
  .collection-columns {
    grid-template-columns: 1fr;
  }
  .studio-side .companion {
    height: 125px;
  }
  .studio-summary {
    grid-template-columns: 1fr;
    grid-column: auto;
  }
  .mascot-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .mascot-detail .mascot-art {
    max-width: 200px;
    margin: auto;
  }
  .game-tabs {
    flex-wrap: wrap;
  }
  .game-tabs button {
    min-width: 44%;
  }
  body[data-page='results'] #result-panel {
    display: block;
  }
  #analysis-studio {
    margin: 15px 0;
  }
  .analysis-two {
    grid-template-columns: 1fr;
  }
  .analysis-metrics {
    grid-template-columns: 1fr 1fr;
  }
  .studio-paper header {
    flex-wrap: wrap;
  }
}
.analysis-details-toggle {
  grid-column: 1;
  grid-row: 2;
  min-height: 40px;
  padding: 9px;
  border: 1px solid #ccd5df;
  border-radius: 8px;
  color: #16436b;
  background: white;
  cursor: pointer;
}
body[data-page='results'] #latest.show-details .audit-scroll {
  display: block;
  color: #14243b;
  background: white;
}
body[data-page='results'] #latest.show-details h3,
body[data-page='results'] #latest.show-details .audit-message,
body[data-page='results'] #latest.show-details > .audit-panel {
  display: block;
}
body[data-page='results'] #latest.show-details > .audit-panel:has(#frequency) {
  display: none;
}
.studio-shell button:focus-visible {
  outline: 3px solid #49b4ff;
  outline-offset: 3px;
}

body[data-page='results'] #rtabs {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  overflow: visible;
  gap: 8px;
  width: 100%;
}
body[data-page='results'] #rtabs button {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  color: #253449;
  padding: 12px 6px !important;
  min-height: 130px;
  justify-content: flex-start;
}
body[data-page='results'] #rtabs button.on {
  color: #bb0029;
  background: #fff0f3;
}
body[data-page='results'] #rtabs small {
  white-space: normal;
  font-size: 12px;
  line-height: 1.45;
}
body[data-page='results'] #latest .audit-linkrow button,
body[data-page='results'] #latest .audit-linkrow a {
  color: #173650;
}
.analysis-toolbar button,
.analysis-toolbar select,
.analysis-actions button {
  color: #173650;
  min-height: 44px;
}
.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.chart-panel {
  padding: 14px;
  border: 1px solid #dae3ec;
  border-radius: 12px;
  background: #fff;
  min-width: 0;
}
.chart-panel h3 {
  margin: 0 0 12px;
  font-size: 16px;
}
.chart-panel p {
  font-size: 12px;
  color: #566176;
}
.chart-panel svg {
  width: 100%;
  height: auto;
  display: block;
}
.chart-panel svg text {
  font: 12px var(--app-font);
  fill: #41546b;
}
.chart-panel.wide {
  grid-column: 1/-1;
}
.chart-rows {
  display: grid;
  gap: 7px;
}
.chart-row {
  display: grid;
  grid-template-columns: 65px minmax(0, 1fr) 40px;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}
.chart-track {
  background: #edf2f7;
  border-radius: 4px;
  height: 16px;
  overflow: hidden;
}
.chart-track i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #216da4, #61b3cf);
  border-radius: 4px;
}
.analysis-bars {
  overflow: visible;
  gap: 2px;
}
.analysis-bars > div {
  min-width: 0;
}
.analysis-bars small {
  font-size: 10px;
}
.analysis-bars b {
  font-size: 9px;
}
@media (max-width: 1250px) {
  body[data-page='results'] #rtabs {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
@media (max-width: 760px) {
  body[data-page='results'] #rtabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .chart-grid {
    grid-template-columns: 1fr;
  }
  .analysis-toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .analysis-toolbar label {
    grid-column: 1/-1;
  }
  .analysis-bars {
    flex-wrap: wrap;
    height: auto;
  }
  .analysis-bars > div {
    flex: 0 0 calc(10% - 2px);
  }
  .analysis-bars small {
    writing-mode: horizontal-tb;
  }
  .analysis-bars b {
    font-size: 11px;
  }
}
