:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --border: #dbe3ee;
  --text: #172033;
  --muted: #60708a;
  --accent: #2f6fed;
  --accent-2: #edf3ff;
  --shadow: 0 12px 40px rgba(31, 54, 88, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 16px;
}

h1, h2, h3, p { margin-top: 0; }

.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 14px;
}

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

input, textarea, select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
}

textarea { resize: vertical; }

.buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

button {
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 600;
}

button.secondary {
  background: var(--accent-2);
  color: var(--accent);
}

button:hover { opacity: 0.95; }

.chat-log {
  min-height: 340px;
  max-height: 48vh;
  overflow: auto;
  display: grid;
  gap: 10px;
  padding: 8px;
  background: linear-gradient(180deg, #f9fbff, #fff);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.message {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
}

.message.user { background: #f5f9ff; }
.message.assistant { background: #ffffff; }

.meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.body {
  white-space: pre-wrap;
  line-height: 1.6;
}

.hint {
  color: var(--muted);
  margin-bottom: 12px;
}

.result-box {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fbfcfe;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
}

@media (min-width: 980px) {
  .app {
    grid-template-columns: 360px 1fr 360px;
    align-items: start;
  }
  .settings, .revise { position: sticky; top: 20px; }
  .chat { min-height: calc(100vh - 40px); }
}

@media (max-width: 700px) {
  .grid { grid-template-columns: 1fr; }
  .app { padding: 12px; }
}
