* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  background: #ffffff;
  color: #202124;
  line-height: 1.5;
  font-size: 0.95rem;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
}

.chat-wrapper {
  flex: 1;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

.chat-section {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1200px;
  height: 100%;
  padding: 0 20px;
}

.chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: 20px 20px 12px 24px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
}

.message-wrapper {
  display: flex;
  margin-bottom: 12px;
}

.message {
  margin-bottom: 8px;
  display: flex;
}

.message.assistant {
  justify-content: flex-start;
  gap: 10px;
  align-items: flex-start;
}

.message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e711dd 0%, #8ab4f8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 600;
  color: white;
  font-size: 12px;
  border: 1.5px solid #e711dd;
}

.assistant .message-content {
  background: #f3f3f3;
  color: #202124;
  border-radius: 4px 18px 18px 18px;
  padding: 10px 16px 10px 14px;
  max-width: 85%;
  position: relative;
  overflow-wrap: break-word;
  white-space: normal;
  font-size: 0.93rem;
  line-height: 1.45;
}

.input-section {
  background: transparent;
  padding: 10px 0 16px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  min-height: 0;
}

.input-container {
  width: 100%;
  max-width: 920px;
}

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

.toggle-row .form-toggle-btn {
  flex: 1;
  width: auto;
  margin-bottom: 0;
}

.toggle-row .send-btn {
  background: #8ab4f8;
  border: none;
  border-radius: 10px;
  color: #fff;
  padding: 10px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.toggle-row .send-btn:hover:not(:disabled) {
  background: #6a9fd8;
}

.toggle-row .send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.form-toggle-btn {
  width: 100%;
  border: 1px solid #dadce0;
  border-radius: 10px;
  background: #f8f9fa;
  color: #202124;
  padding: 10px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  margin-bottom: 8px;
  transition: background 0.2s ease, border-color 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-toggle-btn:hover {
  background: #f1f3f4;
  border-color: #c9cdd1;
}

.toggle-arrow {
  font-size: 0.78rem;
  line-height: 1;
  transition: transform 0.2s ease;
}

.form-toggle-btn[aria-expanded="true"] .toggle-arrow {
  transform: rotate(180deg);
}

.toggle-label {
  color: #5f6368;
  font-size: 0.85rem;
}

.form-panel {
  max-height: 1400px;
  opacity: 1;
  overflow: hidden;
  transition: max-height 0.28s ease, opacity 0.2s ease;
}

.form-panel.collapsed {
  max-height: 0;
  opacity: 0;
}

.grade-form {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 10px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: #5f6368;
}

.form-grid {
  display: grid;
  gap: 10px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

input,
textarea,
select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #dadce0;
  border-radius: 10px;
  font-size: 0.92rem;
  font-family: inherit;
  color: #202124;
  background: #ffffff;
}

textarea {
  resize: vertical;
  min-height: 72px;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #8ab4f8;
  box-shadow: 0 0 0 2px rgba(138, 180, 248, 0.2);
}

.input-wrapper {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  background: #f5f5f5;
  border-radius: 24px;
  padding: 8px 12px;
  border: 1px solid #dadce0;
  transition: all 0.2s ease;
}

.input-wrapper:focus-within {
  border-color: #8ab4f8;
  background: #fafafa;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.send-btn {
  background: none;
  border: none;
  color: #8ab4f8;
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  color: #5f6368;
}

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

.thinking-indicator {
  text-align: center;
  padding: 6px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.8rem;
  color: #5f6368;
}

.thinking-indicator .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5f6368;
  animation: bounce 1.4s infinite;
}

.thinking-indicator .dot:nth-child(1) {
  animation-delay: -0.32s;
}

.thinking-indicator .dot:nth-child(2) {
  animation-delay: -0.16s;
}

.thinking-indicator .dot:nth-child(3) {
  animation-delay: 0s;
}

.thinking-text {
  margin-left: 4px;
  font-size: 0.8rem;
}

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.footer-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.footer-text {
  text-align: center;
  font-size: 0.72rem;
  color: #9aa0a6;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}

.footer-divider {
  color: #dadce0;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #d33b27;
  animation: pulse 2s infinite;
  display: inline-block;
}

.status-dot.online {
  background: #188038;
  animation: none;
}

.status-text,
.session-id-text {
  font-size: 0.72rem;
  color: #9aa0a6;
  display: inline;
  font-weight: 500;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.result-block {
  margin-top: 8px;
  border: 1px solid #dadce0;
  border-radius: 12px;
  background: #f8f9fa;
  padding: 10px;
  max-height: 320px;
  overflow: auto;
  font-size: 0.84rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 900px) {
  .form-grid.two,
  .form-grid.three {
    grid-template-columns: 1fr;
  }

  .chat-section {
    padding: 0 10px;
  }
}
