:root {
  --ink: #f4f7fb;
  --muted: #9aa8bd;
  --line: rgba(151, 166, 195, 0.22);
  --surface: rgba(17, 24, 39, 0.82);
  --surface-strong: rgba(22, 31, 49, 0.94);
  --soft: rgba(255, 255, 255, 0.07);
  --accent: #45a3ff;
  --accent-dark: #9ccfff;
  --mint: #26e0b8;
  --coral: #ff7a6b;
  --yellow: #f7c948;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.44);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 14% 10%, rgba(69, 163, 255, 0.28), transparent 30%),
    radial-gradient(circle at 88% 18%, rgba(38, 224, 184, 0.18), transparent 28%),
    radial-gradient(circle at 58% 92%, rgba(255, 122, 107, 0.15), transparent 32%),
    linear-gradient(135deg, #070b12 0%, #0c1320 44%, #101721 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent 82%);
}

.shell {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 28px;
  width: min(1180px, calc(100% - 16px));
  margin: 0 auto;
  padding: 18px 0 30px;
}

.side-panel {
  position: sticky;
  top: 24px;
  align-self: start;
  display: grid;
  gap: 14px;
}

.schema-card {
  overflow: visible;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(38, 224, 184, 0.14), rgba(69, 163, 255, 0.055)),
    var(--surface-strong);
  border: 1px solid rgba(38, 224, 184, 0.28);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.examples button {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.025)),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.schema-kicker {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.schema-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.schema-title {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.15;
}

.schema-body {
  margin-top: 18px;
}

.schema-card pre,
#sql {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.schema-card pre {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.55;
}

.workspace {
  display: grid;
  gap: 18px;
}

.topbar {
  display: flex;
  justify-content: stretch;
  align-items: center;
  padding: 0;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 32px;
}

.brand-lockup {
  position: relative;
  display: inline-grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px 12px;
  width: 100%;
  min-width: 0;
  padding: 13px 16px 12px 14px;
  border: 1px solid rgba(38, 224, 184, 0.28);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(38, 224, 184, 0.14), rgba(69, 163, 255, 0.07) 48%, rgba(255, 255, 255, 0.025)),
    rgba(17, 24, 39, 0.58);
  box-shadow:
    0 18px 48px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.brand-lockup::before {
  position: absolute;
  inset: -1px;
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(38, 224, 184, 0.28), rgba(247, 201, 72, 0.2), rgba(69, 163, 255, 0.22));
  opacity: 0.55;
  content: "";
  filter: blur(12px);
}

.brand-mark {
  position: relative;
  isolation: isolate;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  overflow: hidden;
  border: 1px solid rgba(90, 255, 218, 0.72);
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 30%, rgba(255, 255, 255, 0.95), rgba(94, 255, 221, 0.62) 22%, transparent 38%),
    conic-gradient(from 210deg, #26e0b8, #45a3ff, #f7c948, #26e0b8);
  color: #04121a;
  font-size: 14px;
  font-weight: 1000;
  letter-spacing: -0.02em;
  box-shadow:
    0 0 22px rgba(38, 224, 184, 0.24),
    0 12px 32px rgba(69, 163, 255, 0.18),
    inset 0 0 0 5px rgba(5, 15, 25, 0.64);
  animation: brand-orbit 5.5s linear infinite, brand-breathe 2.8s ease-in-out infinite;
}

.brand-mark::before {
  position: absolute;
  inset: 5px;
  z-index: -1;
  border-radius: 50%;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.82), rgba(38, 224, 184, 0.76) 44%, rgba(69, 163, 255, 0.72));
  content: "";
}

.brand-mark::after {
  position: absolute;
  top: -45%;
  left: -80%;
  width: 54%;
  height: 190%;
  transform: rotate(24deg);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.82), transparent);
  content: "";
  animation: brand-shine 3.8s ease-in-out infinite;
}

.brand-mark-text {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.76);
  color: #06131c;
  font-size: 13px;
  font-weight: 1000;
  box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.9);
}

@keyframes brand-orbit {
  from {
    filter: hue-rotate(0deg);
  }
  to {
    filter: hue-rotate(18deg);
  }
}

@keyframes brand-breathe {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-1px) scale(1.035);
  }
}

@keyframes brand-shine {
  0%,
  48% {
    left: -85%;
  }
  72%,
  100% {
    left: 128%;
  }
}

.brand-title {
  color: var(--mint);
  font-size: 31px;
  font-weight: 1000;
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 0 24px rgba(38, 224, 184, 0.22);
}

.brand-main {
  min-width: 0;
}

.brand-company {
  grid-column: 1 / -1;
  margin: 0;
  padding-top: 7px;
  color: var(--yellow);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-align: left;
}

h2 {
  font-size: 16px;
}

.examples {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 92px;
  align-items: stretch;
  gap: 6px 8px;
}

.examples button {
  display: flex;
  align-items: center;
  align-self: stretch;
  appearance: none;
  height: 92px;
  min-height: 0;
  padding: 14px 16px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  font: inherit;
  font-size: 15px;
  line-height: 1.2;
}

.examples button:hover {
  border-color: var(--accent);
  background:
    linear-gradient(145deg, rgba(69, 163, 255, 0.13), rgba(38, 224, 184, 0.08)),
    var(--surface-strong);
}

.composer,
.answer-card,
.status {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.025)),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.composer {
  display: grid;
  gap: 12px;
  padding: 14px;
}

textarea {
  width: 100%;
  min-height: 145px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--ink);
  padding: 12px;
  font: inherit;
  line-height: 1.5;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(69, 163, 255, 0.16);
}

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.query-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.query-flow span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 6px 9px;
  border: 1px solid rgba(69, 163, 255, 0.22);
  border-radius: 8px;
  background: rgba(69, 163, 255, 0.08);
  color: #c8d7ef;
  font-weight: 800;
  white-space: nowrap;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.query-flow span[data-flow-step="question"],
.query-flow span[data-flow-step="clickhouse"] {
  border-color: rgba(38, 224, 184, 0.42);
  background: rgba(38, 224, 184, 0.12);
  color: var(--mint);
}

.query-flow span.flow-warning,
.query-flow span.flow-export {
  border-color: rgba(247, 201, 72, 0.42);
  background: rgba(247, 201, 72, 0.12);
  color: var(--yellow);
}

.query-flow span.flow-pending {
  border-color: rgba(151, 166, 195, 0.2);
  background: rgba(151, 166, 195, 0.06);
  color: #9fb0c8;
}

.query-flow span.flow-active {
  border-color: rgba(255, 122, 107, 0.72);
  background: rgba(255, 122, 107, 0.18);
  color: var(--coral);
  box-shadow: 0 0 0 3px rgba(255, 122, 107, 0.1);
}

.query-flow span.flow-done {
  border-color: rgba(38, 224, 184, 0.42);
  background: rgba(38, 224, 184, 0.14);
  color: var(--mint);
}

.query-flow span.flow-error {
  border-color: rgba(255, 122, 107, 0.62);
  background: rgba(255, 122, 107, 0.14);
  color: var(--coral);
}

.query-flow b {
  color: rgba(156, 207, 255, 0.72);
  font-size: 13px;
  font-weight: 900;
}

.export-row {
  display: flex;
  justify-content: flex-start;
  margin-top: -4px;
}

.export-link {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid rgba(247, 201, 72, 0.42);
  border-radius: 8px;
  background: rgba(247, 201, 72, 0.12);
  color: var(--yellow);
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

.export-link:hover {
  border-color: var(--yellow);
  background: rgba(247, 201, 72, 0.18);
}

.export-link[aria-busy="true"] {
  cursor: wait;
  opacity: 0.68;
}

label {
  color: var(--muted);
  font-size: 14px;
}

button[type="submit"] {
  min-width: 88px;
  min-height: 34px;
  border: 1px solid rgba(38, 224, 184, 0.42);
  border-radius: 8px;
  background: rgba(38, 224, 184, 0.12);
  color: var(--mint);
  padding: 7px 14px;
  cursor: pointer;
  font-weight: 900;
  box-shadow: none;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

button[type="submit"]:hover {
  border-color: rgba(38, 224, 184, 0.68);
  background: rgba(38, 224, 184, 0.18);
}

button[type="submit"]:disabled {
  opacity: 0.65;
  cursor: wait;
}

.status {
  padding: 14px;
  color: var(--muted);
}

.result {
  display: grid;
  gap: 14px;
}

.answer-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.report-card {
  gap: 0;
  overflow: hidden;
  padding: 0;
  border-color: rgba(38, 224, 184, 0.26);
  background:
    linear-gradient(150deg, rgba(38, 224, 184, 0.09), rgba(69, 163, 255, 0.045) 42%, rgba(255, 255, 255, 0.035)),
    var(--surface);
}

.report-header {
  display: grid;
  gap: 5px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid rgba(151, 166, 195, 0.18);
  background:
    linear-gradient(90deg, rgba(38, 224, 184, 0.12), rgba(69, 163, 255, 0.055), transparent);
}

.report-header p {
  margin: 0;
  color: var(--yellow);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.report-header h2 {
  color: var(--ink);
  font-size: 21px;
  line-height: 1.2;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-header.report-header {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.chart-card-header {
  align-items: flex-start;
}

.chart-type-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.chart-type-button {
  border: 1px solid rgba(69, 163, 255, 0.22);
  border-radius: 8px;
  background: rgba(69, 163, 255, 0.08);
  color: #c8d7ef;
  padding: 6px 9px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.1;
}

.chart-type-button:hover {
  border-color: var(--accent);
  background: rgba(69, 163, 255, 0.14);
}

.chart-type-button.active {
  border-color: rgba(38, 224, 184, 0.42);
  background: rgba(38, 224, 184, 0.14);
  color: var(--mint);
}

.chart-type-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.secondary-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--accent-dark);
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 700;
}

.secondary-button:hover {
  border-color: var(--accent);
  background: rgba(69, 163, 255, 0.1);
}

.compact-button {
  flex: 0 0 auto;
  padding: 7px 9px;
  font-size: 12px;
}

#answer {
  display: grid;
  gap: 13px;
  padding: 20px;
  line-height: 1.65;
  color: var(--ink);
  font-size: 15px;
}

#answer p,
#answer h2,
#answer h3,
#answer h4,
#answer ul,
#answer ol {
  margin: 0;
}

#answer p + p,
#answer p + ul,
#answer p + ol,
#answer ul + h3,
#answer ol + h3,
#answer ul + h4,
#answer ol + h4 {
  margin-top: 12px;
}

#answer h2 {
  max-width: none;
  color: #d9ecff;
  font-size: 24px;
  font-weight: 900;
  line-height: 1.28;
  letter-spacing: 0;
}

#answer h3 {
  margin-top: 8px;
  color: var(--mint);
  font-size: 17px;
  font-weight: 900;
  line-height: 1.35;
  border-left: 5px solid var(--mint);
  padding: 2px 0 2px 12px;
  background: linear-gradient(90deg, rgba(38, 224, 184, 0.07), transparent 62%);
}

#answer .answer-heading-yellow {
  color: var(--yellow);
  border-left-color: var(--yellow);
  background: linear-gradient(90deg, rgba(247, 201, 72, 0.075), transparent 62%);
}

#answer h4 {
  margin-top: 6px;
  color: #cfe7ff;
  font-size: 16px;
  font-weight: 900;
  line-height: 1.35;
}

#answer p {
  max-width: none;
  color: #e8eef7;
}

#answer ul,
#answer ol {
  display: grid;
  gap: 8px;
  max-width: none;
  padding-left: 0;
  list-style: none;
}

#answer ol {
  counter-reset: briefing-list;
}

#answer li {
  position: relative;
  padding-left: 18px;
  color: #edf3fb;
}

#answer li::before {
  position: absolute;
  left: 0;
  top: 0.72em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mint);
  content: "";
}

#answer ol li {
  counter-increment: briefing-list;
  padding-left: 30px;
}

#answer ol li::before {
  top: 0.15em;
  width: 20px;
  height: 20px;
  background: rgba(69, 163, 255, 0.16);
  color: #d9ecff;
  content: counter(briefing-list);
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(69, 163, 255, 0.28);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
}

.answer-action-detail {
  display: grid;
  gap: 9px;
}

.answer-action-detail summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: #edf3fb;
  font-weight: 800;
  outline: none;
}

.answer-action-detail summary::marker {
  color: var(--yellow);
}

.answer-action-detail summary:hover {
  color: #ffffff;
  text-decoration: underline;
  text-decoration-color: rgba(247, 201, 72, 0.55);
  text-underline-offset: 4px;
}

.answer-action-detail[open] summary {
  color: var(--yellow);
}

.answer-action-body {
  display: grid;
  gap: 9px;
  margin-top: 10px;
  padding: 13px 14px;
  border: 1px solid rgba(247, 201, 72, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(247, 201, 72, 0.075), rgba(69, 163, 255, 0.04)),
    rgba(7, 11, 18, 0.24);
}

.answer-action-body strong {
  color: var(--yellow);
  font-size: 13px;
}

.answer-action-body ul {
  gap: 7px;
  max-width: none;
}

#answer .answer-action-body li {
  counter-increment: none;
  color: #dbe6f5;
  font-size: 14px;
  line-height: 1.58;
  padding-left: 16px;
}

#answer .answer-action-body li::before {
  top: 0.68em;
  width: 5px;
  height: 5px;
  background: var(--yellow);
  border: 0;
  content: "";
}

#answer strong {
  color: #ffffff;
  font-weight: 900;
}

.markdown-table-wrap {
  overflow: auto;
  border: 1px solid rgba(151, 166, 195, 0.18);
  border-radius: 8px;
}

.report-card > .table-wrap,
.report-card > #sql {
  margin: 16px 20px 20px;
}

.report-card > .table-wrap {
  border: 1px solid rgba(151, 166, 195, 0.18);
  border-radius: 8px;
  background: rgba(7, 11, 18, 0.28);
}

.report-card > #sql {
  padding: 15px;
  border: 1px solid rgba(151, 166, 195, 0.18);
  border-radius: 8px;
  background: rgba(7, 11, 18, 0.36);
  color: #d9ecff;
}

.answer-inline-image {
  width: 50px;
  max-width: 50px;
  height: auto;
  vertical-align: middle;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.result-table-image {
  display: block;
  width: 50px;
  max-width: 50px;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
}

#chart {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.table-wrap {
  overflow: auto;
}

.empty-result {
  margin: 0;
  color: var(--muted);
}

.result-section {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
  min-width: 720px;
}

.result-section:last-child {
  margin-bottom: 0;
}

.result-section h3 {
  margin: 0;
  color: var(--mint);
  font-size: 15px;
  line-height: 1.3;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px;
  text-align: left;
  vertical-align: top;
}

th {
  background: rgba(255, 255, 255, 0.055);
  color: var(--mint);
  font-weight: 800;
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: 1fr;
    width: min(100% - 12px, 1180px);
    padding: 18px 0;
  }

  .side-panel {
    position: static;
  }

  .topbar,
  .controls {
    align-items: start;
    flex-direction: column;
  }

  .topbar {
    align-items: center;
  }

  .brand-lockup {
    width: min(100%, 340px);
    min-width: 0;
  }

  .query-flow {
    width: 100%;
  }

  .chart-card-header {
    flex-direction: column;
  }

  .chart-type-controls {
    justify-content: flex-start;
  }

  .examples {
    grid-template-columns: 1fr;
  }

  button[type="submit"] {
    width: 100%;
  }
}
