@font-face {
  font-family: "Opague";
  src: url("./assets/fonts/Opague-Regular-Desktop.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Suisse Intl";
  src: url("./assets/fonts/SuisseIntl-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --background: #050505;
  --surface: #12110f;
  --surface-hover: #1a1917;
  --surface-active: #242320;
  --line: #2d2c2a;
  --line-strong: #4b4946;
  --text: #dedbd7;
  --text-muted: #a6a3a4;
  --text-dim: #747170;
  --accent: #d7d2c9;
}

:root[data-theme="light"] {
  --background: #f5f6f9;
  --surface: #eeebee;
  --surface-hover: #dedade;
  --surface-active: #c5c5c7;
  --line: #c5c5c7;
  --line-strong: #a3a3a3;
  --text: #292929;
  --text-muted: #5e5e5e;
  --text-dim: #7a7a7a;
  --accent: #292929;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--background);
  color: var(--text);
  font-family: "Suisse Intl", sans-serif;
  font-weight: 400;
  letter-spacing: 0;
}

button,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(260px, 25vw) minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  padding: 16px;
  gap: 16px;
  background: var(--background);
}

.sidebar,
.chat {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--background);
}

.sidebar {
  display: flex;
  flex-direction: column;
  padding: 20px 16px 16px;
}

.brand {
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 0 10px 18px;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.brand__logo {
  display: block;
  width: 66px;
  height: 40px;
  object-fit: contain;
}

.brand__name {
  margin-left: auto;
  color: var(--text);
  font-family: "Opague", sans-serif;
  font-size: 18px;
  text-align: right;
  white-space: nowrap;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 14px;
  padding: 3px;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.mode-switch__button {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.mode-switch__button.is-active {
  border-color: var(--line-strong);
  background: var(--surface-active);
  color: var(--text);
}

.persona-list {
  display: grid;
  grid-auto-rows: minmax(66px, auto);
  gap: 8px;
  margin-top: 16px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.persona.is-selected {
  border-color: var(--line-strong);
  background: var(--surface-active);
}

.persona__check {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 14px;
}

.council-actions {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.council-actions__hint {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}

.council-actions__hint code {
  color: var(--text);
}

.council-actions__start {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface-active);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.council-actions__start:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.message__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--text-dim);
  font-size: 12px;
}

.message__avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
}

.message--summary {
  border-color: var(--line-strong);
}

.message--debate {
  opacity: 0.92;
}

.settings-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  margin-top: auto;
  padding: 12px;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--background);
}

.export-button {
  flex: 0 0 auto;
  border-color: var(--line);
  background: var(--surface);
  font-size: 18px;
  line-height: 1;
}

.theme-switch {
  display: grid;
  grid-template-columns: repeat(2, 42px);
  padding: 3px;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.settings-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition:
    transform 120ms ease,
    color 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

.settings-button:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.settings-button:active {
  transform: scale(0.94);
}

.settings-button:focus-visible {
  outline: 1px solid var(--text-muted);
  outline-offset: 2px;
}

.theme-button span {
  font-family: Georgia, serif;
  font-size: 25px;
  line-height: 1;
}

.theme-button.is-active,
.sound-button[aria-pressed="true"] {
  border-color: var(--line-strong);
  background: var(--surface-active);
  color: var(--text);
}

.sound-button {
  flex: 0 0 auto;
  border-color: var(--line);
  background: var(--surface);
}

.sound-icon {
  width: 22px;
  height: 22px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sound-icon path:not(:first-child) {
  fill: none;
}

.sound-icon--off {
  display: none;
}

.sound-button[aria-pressed="false"] .sound-icon--on {
  display: none;
}

.sound-button[aria-pressed="false"] .sound-icon--off {
  display: block;
}

:root[data-theme="light"] .brand__logo {
  filter: invert(1);
}

.persona {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  min-height: 66px;
  padding: 9px 12px;
  gap: 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition:
    transform 120ms ease,
    background 140ms ease,
    border-color 140ms ease,
    box-shadow 180ms ease;
}

.persona:hover {
  background: var(--surface-hover);
}

.persona:active {
  transform: scale(0.975);
}

.persona:focus-visible {
  outline: 1px solid var(--text-muted);
  outline-offset: 2px;
}

.persona.is-active {
  border-color: #66625d;
  background: var(--surface-active);
  box-shadow:
    inset 0 0 0 1px rgba(222, 219, 215, 0.05),
    0 0 18px rgba(222, 219, 215, 0.06);
}

.persona.is-clicked {
  animation: persona-click 280ms ease-out;
}

@keyframes persona-click {
  0% {
    transform: scale(1);
  }

  42% {
    transform: scale(0.965);
    background: #2b2926;
    box-shadow: inset 0 0 0 1px rgba(222, 219, 215, 0.14);
  }

  100% {
    transform: scale(1);
  }
}

.persona__avatar {
  width: 46px;
  height: 46px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface);
}

.persona__name {
  min-width: 0;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.persona.is-active .persona__name {
  color: var(--text);
}

.chat {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 160px;
  padding: 24px 30px;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.chat-header__identity {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 20px;
}

.avatar-inspector {
  position: relative;
  flex: 0 0 auto;
  width: 112px;
  height: 112px;
  cursor: zoom-in;
}

.chat-header__avatar {
  width: 112px;
  height: 112px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface);
}

.avatar-lens {
  position: absolute;
  z-index: 12;
  top: 0;
  left: calc(100% + 18px);
  width: 190px;
  height: 190px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background-color: var(--background);
  background-repeat: no-repeat;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.34);
  opacity: 0;
  visibility: hidden;
  transform: scale(0.92);
  transform-origin: top left;
  transition:
    opacity 140ms ease,
    transform 140ms ease,
    visibility 140ms ease;
  pointer-events: none;
}

.avatar-inspector:hover .avatar-lens {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

.chat-header__copy {
  min-width: 0;
}

.chat-header h1,
.chat-header p {
  margin: 0;
}

.chat-header h1 {
  color: var(--text);
  font-family: "Opague", sans-serif;
  font-size: 25px;
  line-height: 1.15;
}

.chat-header p {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 15px;
}

.chat-header__status {
  flex: 0 0 auto;
  color: #61c783;
  font-size: 14px;
}

.messages {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 28px 7%;
  gap: 16px;
  overflow-y: auto;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.message {
  width: fit-content;
  max-width: min(680px, 82%);
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.message--assistant {
  align-self: flex-start;
  background: var(--surface);
}

.message--user {
  align-self: flex-end;
  border-color: var(--line-strong);
  background: var(--surface-active);
  color: var(--text);
}

.message.is-pending {
  color: var(--text-dim);
}

.message.is-typing {
  min-width: 58px;
  padding-block: 18px;
}

.message__typing-label {
  color: var(--text-dim);
  font-size: 14px;
  font-style: italic;
}

.message__attachment {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface-active);
}

.message__attachment-copy {
  min-width: 0;
}

.message__attachment-copy strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.message__attachment-copy p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}

.message__attachment-download {
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
}

.message__attachment-download:hover {
  background: var(--surface-hover);
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: typing-bounce 1.1s ease-in-out infinite;
}

@keyframes typing-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }

  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.message.is-error {
  border-color: #7b4d4d;
  color: #d7aaaa;
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  align-items: end;
  margin: 0 22px 22px;
  padding: 8px 8px 8px 16px;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
}

.composer__quota {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0 4px 4px;
  font-size: 0.75rem;
  line-height: 1.3;
  color: var(--text-muted);
}

.composer__quota.is-exhausted {
  color: #d7aaaa;
}

.composer:focus-within {
  border-color: #696662;
}

.composer textarea {
  width: 100%;
  max-height: 160px;
  padding: 10px 0;
  resize: none;
  overflow-y: auto;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
}

.composer textarea::placeholder {
  color: var(--text-muted);
}

.composer__send {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #1d1c1a;
  color: var(--text);
  cursor: pointer;
  transition:
    background 140ms ease,
    color 140ms ease;
}

.composer__send:hover {
  background: var(--text);
  color: var(--background);
}

.composer textarea:disabled,
.composer__send:disabled {
  cursor: progress;
  opacity: 0.62;
}

:root[data-theme="light"] .composer__send {
  border-color: var(--line-strong);
  background: #ffffff;
  color: var(--text);
}

:root[data-theme="light"] .composer__send:hover {
  background: #f5f6f9;
  color: var(--text);
}

.composer__send span {
  font-family: Arial, sans-serif;
  font-size: 23px;
  line-height: 1;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 104px minmax(0, 1fr);
    padding: 10px;
    gap: 10px;
  }

  .sidebar {
    padding: 14px 10px;
  }

  .brand {
    justify-content: center;
    padding-inline: 0;
  }

  .brand__name,
  .persona__name {
    display: none;
  }

  .persona__check {
    display: none;
  }

  .persona {
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 8px;
  }

  .persona__avatar {
    width: 52px;
    height: 52px;
  }

  .messages {
    padding: 22px 18px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100dvh;
    padding: 0;
    gap: 0;
  }

  .sidebar,
  .chat {
    border-radius: 0;
  }

  .sidebar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    min-height: 82px;
    padding: 10px 12px;
    border-width: 0 0 1px;
  }

  .brand {
    min-height: auto;
    padding: 0 12px 0 0;
    border: 0;
  }

  .brand__logo {
    width: 42px;
  }

  .persona-list {
    display: flex;
    margin: 0;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .settings-panel {
    min-height: auto;
    margin: 0 0 0 8px;
    padding: 5px;
    gap: 5px;
    border: 0;
  }

  .theme-switch {
    grid-template-columns: repeat(2, 36px);
  }

  .settings-button {
    width: 36px;
    height: 36px;
  }

  .persona {
    flex: 0 0 auto;
    min-height: 56px;
    padding: 5px;
  }

  .persona__avatar {
    width: 44px;
    height: 44px;
  }

  .chat {
    border-width: 0;
  }

  .chat-header {
    min-height: 82px;
    padding: 10px 14px;
  }

  .chat-header__avatar {
    width: 54px;
    height: 54px;
  }

  .avatar-inspector {
    width: 54px;
    height: 54px;
  }

  .avatar-lens {
    display: none;
  }

  .chat-header h1 {
    font-size: 17px;
  }

  .chat-header__status {
    display: none;
  }

  .messages {
    padding: 18px 14px;
  }

  .message {
    max-width: 92%;
    font-size: 14px;
  }

  .composer {
    margin: 0 12px 12px;
  }
}
