:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #fbf7f2;
  color: #24202a;
}

html {
  height: 100%;
  overflow: hidden;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100%;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(139, 92, 246, 0.14), transparent 34rem),
    linear-gradient(135deg, #fffaf5 0%, #f7f1ff 48%, #fbf7f2 100%);
}

.shell {
  width: min(960px, calc(100% - 32px));
  height: 100dvh;
  margin: 0 auto;
  padding: 36px 0;
  overflow: hidden;
}

.chat-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(167, 139, 250, 0.28);
  border-radius: 24px;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(88, 63, 124, 0.16);
  backdrop-filter: blur(14px);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 26px;
  border-bottom: 1px solid rgba(167, 139, 250, 0.2);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(247, 241, 255, 0.9));
}

.chat-header h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.12;
  letter-spacing: 0;
  color: #251c35;
}

.chat-header p {
  margin: 7px 0 0;
  color: #71677d;
  font-size: 14px;
}

select,
input,
textarea,
button {
  font: inherit;
}

select {
  min-width: 160px;
  border: 1px solid rgba(139, 92, 246, 0.26);
  border-radius: 14px;
  padding: 10px 38px 10px 13px;
  background: #ffffff;
  color: #30273d;
  box-shadow: 0 8px 20px rgba(88, 63, 124, 0.08);
}

select:focus,
input:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(139, 92, 246, 0.22);
  outline-offset: 2px;
  border-color: #8b5cf6;
}

.messages {
  min-height: 0;
  padding: 24px 26px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.54), rgba(255, 250, 245, 0.72));
}

.message {
  max-width: 92%;
  padding: 12px 15px;
  border-radius: 18px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 10px 24px rgba(88, 63, 124, 0.08);
}

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #7c3aed, #9f67ff);
  color: #ffffff;
  border-bottom-right-radius: 7px;
}

.message.assistant {
  align-self: flex-start;
  background: #ffffff;
  color: #24202a;
  white-space: normal;
  border: 1px solid rgba(167, 139, 250, 0.2);
  border-bottom-left-radius: 7px;
}

.message.assistant h3,
.message.assistant h4 {
  margin: 10px 0 4px;
  font-size: 16px;
  line-height: 1.3;
  color: #2d2140;
}

.message.assistant h3:first-child,
.message.assistant h4:first-child {
  margin-top: 0;
}

.message.assistant p {
  margin: 0 0 4px;
}

.message.assistant ul,
.message.assistant ol {
  margin: 4px 0 8px;
  padding-left: 16px;
}

.message.assistant p + ul,
.message.assistant p + ol {
  margin-top: -3px;
}

.message.assistant li > ul,
.message.assistant li > ol {
  margin: 3px 0 6px;
}

.message.assistant table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 14px;
  font-size: 14px;
}

.message.assistant th,
.message.assistant td {
  border-bottom: 1px solid rgba(167, 139, 250, 0.24);
  padding: 7px 8px;
  text-align: left;
  vertical-align: top;
}

.message.assistant th {
  font-weight: 700;
  color: #2d2140;
  background: rgba(243, 232, 255, 0.45);
}

.message.assistant td:not(:first-child),
.message.assistant th:not(:first-child) {
  text-align: right;
}

.message.assistant li {
  margin: 2px 0;
}

.message.intro-message,
.message.loading-message {
  align-self: flex-start;
  width: auto;
  max-width: fit-content;
  padding: 13px 15px;
  text-align: left;
}

.message.intro-message {
  background: linear-gradient(135deg, #f3e8ff, #fff7ed);
  border: 1px solid rgba(139, 92, 246, 0.24);
  color: #3b2b52;
  box-shadow: 0 14px 30px rgba(124, 58, 237, 0.11);
}

.message.loading-message {
  background: #ffffff;
  border: 1px solid rgba(167, 139, 250, 0.2);
  color: #71677d;
}

.message.intro-message p,
.message.loading-message p {
  margin: 0;
}

.result-section-title {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 2px solid #6b7280;
}

.final-amount {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 14px;
  background: #ecfdf5;
  border: 1px solid #86efac;
  color: #166534;
  font-size: 1.25rem;
  font-weight: 800;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 12px;
  padding: 18px 20px 16px;
  border-top: 1px solid rgba(167, 139, 250, 0.2);
  background: rgba(255, 255, 255, 0.96);
}

.chat-form textarea {
  min-width: 0;
  width: 100%;
  min-height: 49px;
  max-height: 180px;
  border: 1px solid rgba(139, 92, 246, 0.24);
  border-radius: 16px;
  padding: 13px 15px;
  background: #fffdfb;
  color: #24202a;
  box-shadow: inset 0 1px 2px rgba(88, 63, 124, 0.05);
  line-height: 1.35;
  resize: none;
  overflow-y: hidden;
}

.chat-form textarea::placeholder {
  color: #9a90a6;
}

.chat-form button {
  border: 0;
  border-radius: 16px;
  padding: 13px 22px;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: #ffffff;
  cursor: pointer;
  font-weight: 650;
  box-shadow: 0 12px 26px rgba(124, 58, 237, 0.26);
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.chat-form button:hover {
  background: linear-gradient(135deg, #6d28d9, #9333ea);
  box-shadow: 0 14px 30px rgba(124, 58, 237, 0.31);
  transform: translateY(-1px);
}

.chat-form button:active {
  transform: translateY(0);
}

.disclaimer {
  text-align: center;
  font-size: 13px;
  line-height: 1.35;
  color: #8b8197;
  padding: 0 20px 14px;
  margin-top: -4px;
  background: rgba(255, 255, 255, 0.96);
}

.disclaimer a {
  color: #7c3aed;
  text-decoration: none;
}

.disclaimer a:hover {
  text-decoration: underline;
}

.bot-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid rgba(167, 139, 250, 0.2);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 10px 26px rgba(88, 63, 124, 0.08);
}

.bot-picker label {
  font-size: 13px;
  color: #71677d;
  padding-left: 4px;
}

.info-tooltip {
  cursor: help;
  color: #7c3aed;
  font-weight: 650;
}

.tooltip {
  position: relative;
  cursor: pointer;
  color: #7c3aed;
  font-weight: 650;
}

.tooltip-text {
  visibility: hidden;
  width: 260px;
  background: #2d2140;
  color: #ffffff;
  text-align: left;
  padding: 9px 11px;
  border-radius: 12px;
  position: absolute;
  z-index: 10;
  top: 120%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  line-height: 1.4;
  box-shadow: 0 16px 36px rgba(45, 33, 64, 0.22);
}

.tooltip:hover .tooltip-text {
  visibility: visible;
}

.mini-guide {
  text-align: center;
  padding: 0;
  background: rgba(255, 255, 255, 0.96);
}

.mini-guide button {
  border: 1px solid rgba(139, 92, 246, 0.24);
  border-radius: 999px;
  padding: 9px 16px;
  background: #ffffff;
  color: #6d28d9;
  cursor: pointer;
  font-weight: 650;
  box-shadow: 0 10px 22px rgba(88, 63, 124, 0.1);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.mini-guide button:hover {
  border-color: rgba(124, 58, 237, 0.42);
  box-shadow: 0 12px 26px rgba(88, 63, 124, 0.14);
  transform: translateY(-1px);
}

.guide-box[hidden] {
  display: none !important;
}

.guide-box {
  position: fixed;
  top: 105px;
  left: 50%;
  transform: translateX(-50%);
  width: 520px;
  max-width: calc(100% - 40px);
  max-height: 70vh;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid rgba(139, 92, 246, 0.24);
  border-radius: 18px;
  padding: 16px;
  z-index: 9999;
  line-height: 1.45;
  text-align: left;
  color: #30273d;
  box-shadow: 0 24px 60px rgba(88, 63, 124, 0.2);
}

.new-chat-area {
  grid-column: 2;
  display: flex;
  justify-content: flex-end;
  justify-self: end;
  margin-top: -2px;
}

.secondary-button {
  width: 180px;
  min-height: 48px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: #edf8f1;
  color: #276044;
  border: 1px solid #b8dec6;
  border-radius: 14px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(39, 96, 68, 0.1);
  text-align: center;
}

.secondary-button:hover {
  background: #e2f3e9;
  border-color: #9dcfaf;
  box-shadow: 0 10px 22px rgba(39, 96, 68, 0.14);
}

.chat-form .secondary-button {
  background: #edf8f1;
  color: #276044;
  border: 1px solid #b8dec6;
}

.chat-form .secondary-button:hover {
  background: #e2f3e9;
  border-color: #9dcfaf;
  box-shadow: 0 10px 22px rgba(39, 96, 68, 0.14);
}

.chat-form .secondary-button:focus-visible {
  outline: 3px solid rgba(100, 185, 133, 0.24);
  border-color: #8cc7a1;
}

.secondary-button-title,
.secondary-button-note {
  display: block;
}

.secondary-button-title {
  line-height: 1.1;
}

.secondary-button-note {
  color: #5d806b;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.25;
}

.memory-note {
  font-size: 11px;
  color: #a49ab8;
  margin-top: 4px;
}

@media (max-width: 640px) {
  body {
    background: #fbf7f2;
  }

  .shell {
    width: 100%;
    height: 100dvh;
    padding: 0;
  }

  .chat-panel {
    height: 100%;
    min-height: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .chat-header {
    align-items: stretch;
    flex-direction: column;
    padding: 20px 18px;
  }

  .bot-picker {
    width: 100%;
    justify-content: space-between;
  }

  .bot-picker select {
    flex: 1;
    min-width: 0;
  }

  .messages {
    padding: 18px;
  }

  .message {
    max-width: 94%;
  }

  .message.assistant,
  .message.intro-message,
  .message.loading-message {
    max-width: 100%;
  }

  .chat-form {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .chat-form button {
    width: 100%;
  }

  .new-chat-area {
    grid-column: 1;
    justify-self: stretch;
    margin-top: 0;
  }

  .tooltip-text {
    left: auto;
    right: 0;
    transform: none;
    width: min(260px, calc(100vw - 36px));
  }

  .guide-box {
    top: 84px;
    max-width: calc(100% - 24px);
  }
}
