:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --panel: #ffffff;
  --text: #232825;
  --muted: #6a706b;
  --border: #d7dbd4;
  --strong-border: #b7bdb6;
  --accent: #00796b;
  --accent-dark: #005b50;
  --accent-soft: #e7f3f0;
  --warn: #8a5a00;
  --shadow: 0 18px 40px rgba(29, 40, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

.app-shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 22px auto;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  gap: 18px;
  align-items: start;
}

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

.input-panel,
.output-panel {
  padding: 14px;
}

.section-title {
  color: #2d312e;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

form {
  display: grid;
  gap: 14px;
  margin-top: 8px;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: #343934;
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  min-height: 36px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

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

input::placeholder,
textarea::placeholder {
  color: #818782;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 121, 107, 0.13);
}

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

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

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

.divider {
  border-top: 1px solid var(--border);
  margin-top: 2px;
}

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

.query-card {
  min-height: 54px;
  border: 1px solid var(--strong-border);
  border-radius: 7px;
  background: #fff;
  color: #333834;
  cursor: pointer;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  font: inherit;
  padding: 8px;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}

.query-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.query-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 650;
}

.icon {
  font-size: 20px;
  line-height: 1;
}

.actions,
.output-header {
  display: flex;
  gap: 10px;
  align-items: center;
}

.actions {
  justify-content: flex-end;
}

button {
  font: inherit;
}

.primary-button,
.secondary-button {
  border-radius: 6px;
  min-height: 38px;
  padding: 0 16px;
  cursor: pointer;
  border: 1px solid transparent;
  font-weight: 650;
}

.primary-button {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  color: #313632;
  background: #fff;
  border-color: var(--strong-border);
}

.secondary-button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.compact {
  min-height: 34px;
}

.output-panel {
  display: grid;
  gap: 12px;
  position: sticky;
  top: 18px;
}

.output-header {
  justify-content: space-between;
}

.output-header p {
  margin: 5px 0 0;
  color: var(--muted);
}

pre {
  margin: 0;
  min-height: 560px;
  max-height: calc(100vh - 170px);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fbfcfa;
  color: #202521;
  padding: 14px;
  line-height: 1.5;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.notice {
  border-left: 3px solid #d79b14;
  background: #fff8e8;
  color: var(--warn);
  padding: 9px 11px;
  border-radius: 5px;
  line-height: 1.4;
}

.author-credit {
  margin-top: 7px;
  color: #6d5a32;
  font-size: 12px;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .output-panel {
    position: static;
  }

  pre {
    min-height: 360px;
    max-height: none;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 20px, 1180px);
    margin: 10px auto;
  }

  .grid.three,
  .grid.two,
  .query-grid {
    grid-template-columns: 1fr;
  }

  .actions {
    justify-content: stretch;
  }

  .primary-button,
  .secondary-button {
    flex: 1;
  }
}
