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

body {
  font-family: "Segoe UI", "Noto Sans JP", system-ui, sans-serif;
  background: #f5f5f5;
  color: #222;
  min-height: 100vh;
}

.app {
  display: flex;
  gap: 12px;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: fit-content;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  position: sticky;
  top: 16px;
}

.sidebar h2 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.sidebar label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.sidebar label:has(select) { flex-wrap: wrap; }
.sidebar select {
  width: 100%;
  margin-top: 4px;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  cursor: pointer;
}
.sidebar input[type="checkbox"] { accent-color: #4a90d9; }

.sidebar button {
  margin-top: 8px;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: #4a90d9;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.sidebar button:hover { background: #3a7bc8; }

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.log-pane {
  flex: 1;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 500px;
  max-height: calc(100vh - 170px);
}

.log-entry {
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.log-entry.user  { color: #1565c0; }
.log-entry.bot   { color: #2e7d32; }
.log-entry.system { color: #616161; }
.log-entry.result { color: #c62828; font-weight: 600; }
.log-entry.error  { color: #b71c1c; }

.status-bar {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: #555;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row input[type="text"] {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 16px;
  outline: none;
  transition: border 0.15s;
}

.input-row input[type="text"]:focus { border-color: #4a90d9; }
.input-row input[type="text"]:disabled { background: #eee; color: #999; }

.input-row button {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn-submit { background: #4a90d9; color: #fff; }
.btn-submit:hover:not(:disabled) { background: #3a7bc8; }
.btn-submit:disabled { background: #ccc; cursor: not-allowed; }
.btn-reset { background: #e0e0e0; color: #333; }
.btn-reset:hover { background: #ccc; }

.setup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  gap: 12px;
  padding: 24px;
}

.setup-overlay .spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e0e0e0;
  border-top-color: #4a90d9;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.setup-overlay p {
  font-size: 15px;
  color: #555;
  max-width: 480px;
  text-align: center;
  white-space: pre-wrap;
  line-height: 1.5;
}

.hidden { display: none !important; }

footer.license {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px 16px;
  font-size: 11px;
  color: #888;
  line-height: 1.4;
}

footer.license a { color: #4a90d9; }

@media (max-width: 600px) {
  .app { flex-direction: column; padding: 8px; }
  .sidebar { width: 100%; position: static; max-height: none; }
  .log-pane { max-height: 50vh; min-height: 280px; }
  .input-row { flex-wrap: wrap; }
  .input-row button { flex: 1; }
}
