:root {
  color-scheme: light;
  --bg: #f9f8f9;
  --surface: #ffffff;
  --text: #231d33;
  --muted: #6b6679;
  --border: #e6e5e8;
  --primary: #6239c6;
  --primary-dark: #5130a3;
  --assistant-bg: #ffffff;
  --user-bg: #6239c6;
  --user-text: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top right, #efe9ff 0%, var(--bg) 48%);
  color: var(--text);
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.header {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-nav {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.header-link {
  text-decoration: none;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.header-btn {
  border: 1px solid #d7cffa;
  background: #f4f1ff;
  color: #4a3792;
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.header-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.title {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.debug-context-wrap {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.86);
}

.debug-context-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 10px 16px 12px;
}

.debug-context {
  border: 1px solid #d6d2e8;
  border-radius: 12px;
  background: #f8f7ff;
  padding: 10px;
}

.debug-context > summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: #443a63;
}

.debug-context-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.debug-context-actions {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.debug-context-btn {
  border: 1px solid #d7cffa;
  background: #f2efff;
  color: #4a3792;
  border-radius: 9px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.debug-context-select {
  border: 1px solid #d7cffa;
  background: #fff;
  color: #3f3360;
  border-radius: 9px;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 700;
}

.debug-context-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.debug-context-select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.debug-context-textarea {
  margin-top: 8px;
  width: 100%;
  min-height: 220px;
  max-height: 420px;
  padding: 10px 11px;
  border: 1px solid #d5cdee;
  border-radius: 10px;
  background: #fff;
  color: #2a2240;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  resize: vertical;
}

.debug-context-status {
  margin-top: 8px;
  min-height: 18px;
  font-size: 12px;
  color: #6d6780;
}

.debug-context-status.error {
  color: #a32121;
}

.debug-context-status.success {
  color: #1f6f38;
}

.debug-context-status.warning {
  color: #8a5b12;
}

.chat-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.chat {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.day {
  align-self: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: #f2effb;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.row {
  display: flex;
  gap: 10px;
}

.row.user {
  justify-content: flex-end;
}

.bubble {
  max-width: min(780px, 90vw);
  border-radius: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  line-height: 1.5;
  font-size: 14px;
  word-wrap: break-word;
}

.row.assistant .bubble {
  background: var(--assistant-bg);
  color: var(--text);
}

.row.user .bubble {
  background: var(--user-bg);
  color: var(--user-text);
  border-color: var(--user-bg);
}

.bubble strong {
  font-weight: 700;
}

.bubble a {
  color: var(--primary);
  text-decoration: underline;
  word-break: break-word;
}

.row.user .bubble a {
  color: #fff;
}

.bubble-attachments {
  margin-top: 10px;
  border-top: 1px dashed rgba(96, 82, 130, 0.35);
  padding-top: 8px;
}

.bubble-attachment {
  display: block;
  font-size: 12px;
}

.row.user .bubble-attachments {
  border-top-color: rgba(255, 255, 255, 0.55);
}

.time {
  color: #8b8698;
  font-size: 10px;
  margin-top: 3px;
}

.row.user .time {
  text-align: right;
}

.translation {
  background: #eef7ff;
  border: 1px solid #cde2ff;
  border-radius: 14px;
  padding: 12px;
  max-width: min(780px, 90vw);
}

.cta-card {
  background: #eefcf3;
  border: 1px solid #c5ebd3;
  border-radius: 14px;
  padding: 12px;
  max-width: min(780px, 90vw);
}

.cta-title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
}

.cta-description {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

.cta-actions {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cta-actions .btn {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.translation-title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
}

.translation-meta {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

.download {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  border-radius: 10px;
  background: #2063c8;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 11px;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 8px 11px;
  font-weight: 700;
  cursor: pointer;
}

.btn-submit {
  background: #2f8f4e;
  color: #fff;
}

.btn-cancel {
  background: #ebe7f7;
  color: #413a53;
}

.btn-neutral {
  background: #d8e6f6;
  color: #24466d;
}

.composer {
  border-top: 1px solid var(--border);
  background: #fff;
}

.composer-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 16px;
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.attach {
  border: 1px solid #d8d2ea;
  background: #f5f2ff;
  color: #4c3e70;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.attach.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

.voice-toggle.recording {
  background: #ffe9e9;
  border-color: #f2b7b7;
  color: #8f1f1f;
}

.voice-status {
  font-size: 12px;
  color: var(--muted);
}

.voice-status:empty {
  display: none;
}

.voice-status.error {
  color: #a32222;
}

.voice-status.success {
  color: #1f6f38;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #d8d2ea;
  background: #faf8ff;
  color: #40355d;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
}

.file-chip.hidden {
  display: none;
}

.file-chip button {
  border: 0;
  border-radius: 999px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  background: #e0d8f6;
  color: #493e67;
  font-size: 12px;
  line-height: 1;
}

.file-chip button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.field {
  position: relative;
}

textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  resize: none;
  min-height: 48px;
  max-height: 150px;
  padding: 12px 50px 12px 12px;
  font: inherit;
  color: var(--text);
  background: #fbfaff;
}

textarea:focus {
  outline: 2px solid #8160d1;
  border-color: #8160d1;
}

textarea:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.send {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

.send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.typing {
  display: none;
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

.typing.visible {
  display: block;
}

@media (max-width: 640px) {
  .header-inner {
    align-items: flex-start;
    flex-direction: column;
  }
}
