:root {
  --ink: #1a1a1a;
  --muted: #5a5a5a;
  --panel: #262a30;
  --panel-ink: #ffffff;
  --paper: #ffffff;
  --canvas: #f1eee7;
  --line: #cfcfcf;
  --accent: #f4b047;
  --accent-ink: #1b1b1b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Calibri", "Segoe UI", Tahoma, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--panel);
  color: var(--panel-ink);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.logo {
  width: 40px;
  height: 40px;
  display: inline-block;
  flex: 0 0 auto;
  background: url("icon.png") center/contain no-repeat;
  border-radius: 0;
  box-shadow: none;
}

.topbar__nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 14px;
  text-decoration: none;
  color: var(--panel-ink);
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.12);
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.nav-link:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.16);
}

.nav-link.is-active {
  background: rgba(244, 176, 71, 0.16);
  border-color: rgba(244, 176, 71, 0.7);
  box-shadow: 0 0 0 2px rgba(244, 176, 71, 0.35);
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: block;
  background-color: var(--panel-ink);
  -webkit-mask: var(--nav-icon) center / contain no-repeat;
  mask: var(--nav-icon) center / contain no-repeat;
}

.nav-icon--doc {
  --nav-icon: url("icondoc.png");
}

.nav-icon--chat {
  --nav-icon: url("iconchat.png");
}

.page {
  max-width: 980px;
  margin: 24px auto;
  padding: 40px 48px;
  background: var(--paper);
  border: 1px solid #dedede;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.08);
  border-radius: 6px;
}

.content {
  font-size: 15px;
  line-height: 1.35;
}

.docx-p {
  margin: 0 0 10px;
}

.docx-spacer {
  height: 12px;
}

.docx-figure {
  margin: 12px 0 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.docx-img {
  width: 50%;
  max-width: 100%;
  height: auto;
  display: block;
}

.docx-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 18px;
}

.docx-table td,
.docx-table th {
  border: 1px solid var(--line);
  padding: 6px 8px;
  vertical-align: top;
}

.cell-p {
  margin: 0 0 6px;
}

.cell-p:last-child {
  margin-bottom: 0;
}

.cell-images {
  margin: 6px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

@media (max-width: 900px) {
  .page {
    margin: 16px;
    padding: 24px 20px;
  }

  .topbar__inner {
    padding: 8px 16px;
  }

  .logo {
    width: 36px;
    height: 36px;
  }

  .nav-link {
    width: 42px;
    height: 42px;
  }

  .nav-icon {
    width: 20px;
    height: 20px;
  }

  .content {
    font-size: 14px;
    line-height: 1.4;
  }

  .docx-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .docx-table td,
  .docx-table th {
    padding: 6px;
    white-space: normal;
    word-break: break-word;
  }

  .docx-img {
    width: 80%;
  }
}

@media (max-width: 640px) {
  .page {
    margin: 0;
    padding: 18px 14px;
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow: none;
  }

  .docx-spacer {
    height: 10px;
  }

  .docx-figure {
    margin: 10px 0 14px;
  }
}

@media (max-width: 480px) {
  .topbar__inner {
    padding: 6px 12px;
  }

  .logo {
    width: 32px;
    height: 32px;
  }

  .topbar__nav {
    gap: 6px;
  }

  .nav-link {
    width: 38px;
    height: 38px;
  }

  .nav-icon {
    width: 18px;
    height: 18px;
  }

  .content {
    font-size: 13px;
  }

  .docx-img {
    width: 100%;
  }
}

.theme-chat {
  font-family: "Trebuchet MS", "Gill Sans", "Verdana", sans-serif;
  color: #15171a;
  background:
    radial-gradient(circle at 20% 20%, rgba(244, 176, 71, 0.2), transparent 55%),
    radial-gradient(circle at 80% 10%, rgba(71, 163, 255, 0.18), transparent 45%),
    linear-gradient(135deg, #f4f2ee, #e6eef5);
}

.chat-shell {
  max-width: 1200px;
  margin: 24px auto 60px;
  padding: 0 20px 40px;
}

.chat-hero {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr);
  gap: 24px;
  margin-bottom: 26px;
}

.chat-hero__headline h1 {
  margin: 0 0 12px;
  font-size: 30px;
  letter-spacing: 0.2px;
}

.chat-eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  font-size: 12px;
  color: #5c6a79;
}

.chat-subtitle {
  margin: 0;
  max-width: 520px;
  color: #485462;
  font-size: 15px;
  line-height: 1.5;
}

.chat-hero__card {
  background: rgba(255, 255, 255, 0.84);
  border-radius: 16px;
  padding: 18px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.08);
}

.chat-card__title {
  font-weight: 600;
  margin-bottom: 10px;
}

.chat-card__line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin-bottom: 12px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4ac27d;
  box-shadow: 0 0 10px rgba(74, 194, 125, 0.6);
}

.chat-card__note {
  font-size: 13px;
  color: #5b6875;
  line-height: 1.4;
}

.chat-app {
  display: grid;
  grid-template-columns: minmax(200px, 280px) minmax(0, 1fr);
  gap: 20px;
}

.chat-panel {
  background: #11151b;
  color: #eef2f7;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.15);
}

.chat-panel h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.chat-panel ul {
  padding-left: 18px;
  margin: 0 0 20px;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.5;
  font-size: 14px;
}

.panel-button {
  width: 100%;
  margin-bottom: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.panel-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(244, 176, 71, 0.35);
}

.panel-button.ghost {
  background: rgba(255, 255, 255, 0.08);
  color: #eef2f7;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: none;
}

.chat-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-window {
  min-height: 360px;
  max-height: 520px;
  overflow-y: auto;
  padding: 20px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: inset 0 1px 6px rgba(0, 0, 0, 0.06);
}

.chat-empty {
  text-align: center;
  padding: 60px 20px;
  color: #5a6674;
}

.chat-empty__title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 6px;
}

.chat-empty__text {
  font-size: 14px;
}

.chat-message {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 16px;
  align-items: flex-start;
}

.chat-message--user {
  grid-template-columns: minmax(0, 1fr) auto;
}

.chat-message--user .chat-avatar {
  grid-column: 2;
  background: #2b313a;
  color: #f5f7fa;
}

.chat-message--user .chat-bubble {
  grid-column: 1;
  background: #1c2430;
  color: #eef2f7;
}

.chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #f1f4f8;
  color: #1b1f24;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.12);
}

.chat-bubble {
  background: #ffffff;
  border-radius: 16px;
  padding: 14px 16px;
  line-height: 1.5;
  font-size: 14px;
  color: #1c2127;
  white-space: pre-wrap;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
}

.chat-citations {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chat-citation {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  color: #1d4ed8;
  text-decoration: none;
  background: rgba(29, 78, 216, 0.12);
}

.chat-citation:hover {
  background: rgba(29, 78, 216, 0.2);
}

.chat-typing {
  display: inline-flex;
  gap: 6px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  margin: 4px 0 12px;
}

.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4a5c70;
  animation: chatPulse 1.2s infinite ease-in-out;
}

.chat-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.chat-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes chatPulse {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  50% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

.chat-input {
  background: rgba(255, 255, 255, 0.94);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.06);
}

.chat-label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #586473;
  margin-bottom: 8px;
}

.chat-input__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: end;
}

#chat-input {
  width: 100%;
  resize: none;
  min-height: 44px;
  max-height: 160px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
}

.chat-send,
.chat-stop {
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-send {
  background: #1c2430;
  color: #f5f7fa;
}

.chat-stop {
  background: rgba(0, 0, 0, 0.08);
  color: #1f2a38;
}

.chat-send:disabled,
.chat-stop:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
}

.chat-send:hover:not(:disabled),
.chat-stop:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.chat-hint {
  margin-top: 10px;
  font-size: 12px;
  color: #5a6674;
}

@media (max-width: 1000px) {
  .chat-hero {
    grid-template-columns: 1fr;
  }

  .chat-app {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .chat-shell {
    margin-top: 16px;
    padding: 0 16px 32px;
  }

  .chat-window {
    max-height: none;
  }

  .chat-input__row {
    grid-template-columns: 1fr;
  }

  .chat-send,
  .chat-stop {
    width: 100%;
  }
}
