html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #f7f7f9;
  color: #222;
  overflow: auto;
  box-sizing: border-box;
}

* {
  box-sizing: inherit;
}

.page {
  width: 100vw;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden {
  display: none !important;
}

.login-container, .end-container {
  padding: 36px 36px 36px 36px;
  min-width: 340px;
  text-align: center;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-form input {
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid #ddd;
  font-size: 1.1em;
  width: 400px;
  margin: 0 auto;
  display: block;
  text-align: center;
}

.login-form button {
  padding: 12px 32px;
  border-radius: 8px;
  background: #1f3a93;
  color: #fff;
  border: none;
  font-size: 1.1em;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  width: auto;
  align-self: center;
}

.login-form button:hover {
  background: #2a4bb8;
}

.error-msg {
  color: #1f3a93;
  font-size: 1em;
  min-height: 1.5em;
}

.experiment-container {
  display: flex;
  width: 90vw;
  height: 90vh;
  max-width: 1400px;
  max-height: 900px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 4px 32px rgba(0,0,0,0.08);
  overflow: hidden;
}

.left-panel {
  flex: 2 1 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  border-right: 1px solid #f0f0f0;
  background: #f9fafb;
}

.left-content {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 16px;
}

.question-area, .answer-area {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
  padding: 24px 24px 0 32px;
}

.answer-area {
  padding: 0 24px 24px 32px;
  justify-content: flex-end;
}

#question-content {
  flex: 1 1 0;
  overflow: auto;
}

.question-progress {
  font-size: 1.1em;
  color: #888;
  margin-bottom: 8px;
}

.question-title {
  font-size: 1.4em;
  font-weight: bold;
  margin-bottom: 10px;
}

.question-label {
  font-size: 1em;
  font-weight: 600;
  margin-top: 12px;
  margin-bottom: 4px;
  color: #1f3a93;
}

.question-content-main, .question-task {
  font-size: 1.1em;
  margin-bottom: 8px;
  line-height: 1.6;
}

#answer-box {
  flex: 1 1 0;
  min-height: 60px;
  max-height: 200px;
  resize: vertical;
  font-size: 1.1em;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #ddd;
  margin-bottom: 12px;
  background: #fff;
  width: 100%;
}

#answer-box:focus {
  outline: none;
  border: 1px solid #ddd;
  box-shadow: none;
}

.answer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#timer {
  font-size: 1.1em;
  color: #1f3a93;
  font-weight: 600;
}

#submit-btn {
  padding: 10px 32px;
  border-radius: 10px;
  background: #1f3a93;
  color: #fff;
  border: none;
  font-size: 1.1em;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

#submit-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.right-panel {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 24px 24px;
  background: #f5f6fa;
  justify-content: stretch;
}

#ai-chat-area {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 0;
  overflow: auto;
}

#chat-messages {
  flex: 1 1 0;
  overflow-y: auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 1em;
  line-height: 1.4;
  word-wrap: break-word;
}

.chat-message.user {
  align-self: flex-end;
  background: #1f3a93;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-message.ai {
  align-self: flex-start;
  background: #fff;
  color: #333;
  border: 1px solid #e0e0e0;
  border-bottom-left-radius: 4px;
}

.chat-message.ai * {
  text-align: left !important;
}

.chat-input-area {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

#chat-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 0.95em;
  resize: none;
  font-family: inherit;
}

#chat-input:focus {
  outline: none;
  border: 1px solid #1f3a93;
}

#send-chat-btn {
  padding: 10px 16px;
  background: #1f3a93;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.95em;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

#send-chat-btn:hover {
  background: #2a4bb8;
}

#send-chat-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.ai-unavailable {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.ai-unavailable-text {
  color: #888;
  font-size: 1.1em;
  text-align: center;
}