:root {
  --p:#008b8b;
  --pd:#066;
  --pl:#20b2aa;
  --o:#e97540;

  --bg:#faf8f3;
  --ink:#2c2420;
  --mut:#5a534d;
  --bd:#e8e3da;

  --ser:'Crimson Text',Georgia,serif;
  --sans:'Work Sans',sans-serif
}

* {
  box-sizing:border-box
}


.character-chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.65);
}

.character-chat-modal {
  position: relative;
  width: min(720px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  border-radius: 14px;
  background: #fff;
  text-align: center;
}

.character-chat-close {
  position: absolute;
  top: 10px;
  right: 14px;
  border: 0;
  background: transparent;
  font-size: 32px;
  cursor: pointer;
}

.character-chat-modal h2 {
  margin: 0 35px 4px;
}

.character-chat-title {
  margin-bottom: 22px;
  font-style: italic;
}

.character-chat-cast {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.character-chat-choice {
  overflow: hidden;
  padding: 0 0 14px;
  border: 1px solid #ddd;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
}

.character-chat-portrait {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.character-chat-name {
  display: block;
  padding: 14px 12px 0;
  font-size: 1.1rem;
  font-weight: 700;
}

@media (max-width: 520px) {
  .character-chat-modal {
    padding: 22px 14px;
  }

  .character-chat-cast {
    gap: 10px;
  }

  .character-chat-name {
    font-size: 0.95rem;
  }
}

.character-chat-conversation-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 42%);
  gap: 20px;
  min-height: 430px;
}

.character-chat-conversation {
  min-height: 350px;
  max-height: 520px;
  overflow-y: auto;
  padding: 18px;
  border: 1px solid #ddd;
  border-radius: 10px;
  text-align: left;
}

.character-chat-media {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.character-chat-conversation-portrait {
  display: block;
  width: 100%;
  border-radius: 10px;
}

.character-chat-mic {
  min-height: 54px;
  border: 0;
  border-radius: 9px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.character-chat-mic-active {
  transform: scale(0.98);
}

.character-chat-turn {
  margin-bottom: 16px;
  line-height: 1.45;
}

.character-chat-user {
  padding-right: 12px;
}

.character-chat-character {
  padding-left: 12px;
}

@media (max-width: 600px) {
  .character-chat-overlay {
    padding: 0;
    align-items: stretch;
  }

  .character-chat-modal {
    width: 100%;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    overflow: hidden;
  }

  .character-chat-conversation-layout {
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  .character-chat-conversation {
    display: none;
  }

  .character-chat-media {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .character-chat-conversation-portrait {
    flex: 0 1 auto;
    width: 100%;
    max-height: calc(100dvh - 170px);
    object-fit: contain;
  }

  .character-chat-mic {
    flex: 0 0 auto;
    margin-top: 4px;
  }
}

button.feral-pressed {
    transform: scale(0.96);
    opacity: 0.75;
}

body {
  margin:0;
  min-height:100vh;
  background:var(--bg);
  color:var(--ink);
  font:16px/1.6 var(--sans)
}

button {
  font:inherit
}

.header {
  position:sticky;
  top:0;
  z-index:20;
  background:linear-gradient(
    135deg,
    var(--p),
    var(--pd)
  );
  color:#fff;
  box-shadow:0 6px 16px #0002
}

.header-container {
  width:min(1400px,calc(100% - 4rem));
  margin:auto;
  padding:1rem 0;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:2rem
}

.back-button {
  color:#fff;
  text-decoration:none;
  font-weight:600
}

.brand {
  display:flex;
  align-items:baseline;
  gap:.75rem
}

.brand strong {
  font:700 1.4rem var(--ser)
}

.brand span {
  font-size:.8rem;
  opacity:.8;
  text-transform:uppercase;
  letter-spacing:.1em
}

.detail-container {
  width:min(1200px,calc(100% - 4rem));
  margin:3rem auto
}

.status {
  padding:4rem;
  text-align:center;
  color:var(--mut)
}

.detail-content {
  display:grid;
  grid-template-columns:400px 1fr;
  gap:3rem;
  background:#fff;
  padding:3rem;
  border:1px solid var(--bd);
  border-radius:16px;
  box-shadow:0 10px 24px #0001
}

.portrait-section {
  position:sticky;
  top:100px;
  height:fit-content
}

.portrait-wrapper {
  width:100%;
  aspect-ratio:1;
  overflow:hidden;
  border-radius:12px;
  background:linear-gradient(
    145deg,
    #eee7dc,
    #d4c8b8
  );
  box-shadow:0 18px 30px #0002
}

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

.info-section {
  min-width:0
}

.kicker {
  color:var(--p);
  font-size:.72rem;
  font-weight:700;
  letter-spacing:.12em
}

.character-name {
  margin:.15rem 0 0;
  font:700 2.8rem/1.1 var(--ser)
}

.character-source {
  margin:.4rem 0 0;
  color:var(--mut);
  font-style:italic
}

.action-buttons {
  display:flex;
  gap:1rem;
  padding:1.75rem 0;
  border-bottom:2px solid var(--bd)
}

.character-button {
  min-width:150px;
  border-radius:8px;
  padding:.9rem 1.5rem;
  font-weight:700;
  cursor:pointer
}

.character-button.primary {
  border:2px solid var(--o);
  background:var(--o);
  color:#fff
}

.character-button.secondary {
  border:2px solid var(--p);
  background:#fff;
  color:var(--p)
}

.detail-section {
  padding:1.75rem 0;
  border-bottom:1px solid var(--bd)
}

.detail-section:last-child {
  border-bottom:0
}

.detail-section h2 {
  margin:0 0 .75rem;
  color:var(--p);
  font:700 1.7rem var(--ser)
}

.character-definition {
  margin:0;
  white-space:pre-line
}

.source-card {
  padding:1.2rem 0;
  border-bottom:1px solid var(--bd)
}

.source-card:last-child {
  border-bottom:0
}

.source-card h3 {
  margin:0;
  font:700 1.3rem var(--ser)
}

.source-authors {
  margin:.15rem 0 .75rem;
  color:var(--mut);
  font-size:.85rem
}

.source-context {
  margin:0
}

footer {
  margin-top:3rem;
  padding:2rem;
  text-align:center;
  background:var(--ink);
  color:#8b8279
}

@media(max-width:900px) {

  .header-container,
  .detail-container {
    width:calc(100% - 2rem)
  }

  .detail-content {
    grid-template-columns:1fr;
    padding:1.5rem;
    gap:2rem
  }

  .portrait-section {
    position:static
  }

  .portrait-wrapper {
    max-width:400px;
    margin:auto
  }

}

@media(max-width:600px) {

  .header-container {
    align-items:flex-start
  }

  .brand span {
    display:none
  }

  .detail-container {
    margin:1rem auto
  }

  .character-name {
    font-size:2.2rem
  }

  .action-buttons {
    flex-direction:column
  }

  .character-button {
    width:100%
  }

}