:root {
  --primary:           #1976D2;
  --primary-dark:      #1565C0;
  --primary-container: #E3F2FD;
  --secondary:         #00897B;
  --bg:                #F5F5F5;
  --surface:           #FFFFFF;
  --surface-var:       #F8F9FA;
  --on-surface:        #212121;
  --on-surface-var:    #616161;
  --outline:           #BDBDBD;
  --outline-var:       #E0E0E0;
  --divider:           #EEEEEE;
  --error:             #C62828;
  --error-bg:          #FFEBEE;
  --s1: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --s2: 0 2px 8px rgba(0,0,0,.10), 0 1px 3px rgba(0,0,0,.06);
  --s4: 0 4px 16px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
  --r-sm: 8px;
  --r-md: 12px;
  --sans: 'Roboto', sans-serif;
  --mono: 'Roboto Mono', monospace;
}

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

body {
  font-family: var(--sans);
  font-size: 1rem;
  background: var(--bg);
  color: var(--on-surface);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── App Bar ── */
.app-bar {
  background: var(--surface);
  box-shadow: var(--s1);
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-bar-inner {
  max-width: 800px;
  margin: 0 auto;
  padding: .875rem 1.5rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.app-bar-icon {
  width: 40px; height: 40px;
  background: var(--primary-container);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.app-bar-text { flex: 1; }
.app-bar-title {
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: .01em;
  line-height: 1.3;
}
.app-bar-title em { font-style: normal; color: var(--primary); }
.app-bar-sub {
  font-size: .875rem;
  color: var(--on-surface-var);
  margin-top: 1px;
}

/* ── Language Switch ── */
.lang-switch {
  display: flex;
  border: 1.5px solid var(--primary);
  border-radius: var(--r-sm);
  overflow: hidden;
  flex-shrink: 0;
}
.lang-btn {
  height: 34px;
  padding: 0 .875rem;
  font-family: var(--sans);
  font-size: .875rem;
  font-weight: 500;
  background: transparent;
  color: var(--primary);
  border: none;
  cursor: pointer;
  transition: background .15s;
  letter-spacing: .02em;
}
.lang-btn + .lang-btn { border-left: 1.5px solid var(--primary); }
.lang-btn:hover { background: var(--primary-container); }
.lang-btn.active {
  background: var(--primary);
  color: #fff;
}

/* ── Layout ── */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── Card ── */
.card {
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--s1);
  border: 1px solid var(--outline-var);
  padding: 1.25rem 1.5rem 1.5rem;
}

/* ── Section title ── */
.section-title {
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--on-surface-var);
  margin-bottom: 1.125rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--divider);
}

/* ── Options grid ── */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: .875rem;
  margin-bottom: .875rem;
}
@media (max-width: 560px) {
  .options-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Outlined text field ── */
.field { display: flex; flex-direction: column; gap: .3rem; }
.field > label {
  font-size: .875rem;
  font-weight: 500;
  color: var(--on-surface-var);
  letter-spacing: .015em;
}

select, input[type=text] {
  height: 44px;
  background: var(--surface);
  border: 1.5px solid var(--outline);
  border-radius: var(--r-sm);
  color: var(--on-surface);
  font-family: var(--sans);
  font-size: 1rem;
  padding: 0 .875rem;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
  width: 100%;
}
select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23757575' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}
select:hover, input[type=text]:hover { border-color: var(--on-surface-var); }
select:focus, input[type=text]:focus {
  border-color: var(--primary);
  border-width: 2px;
  box-shadow: 0 0 0 3px rgba(25,118,210,.12);
}

/* ── Checkbox ── */
.checkbox-row {
  display: flex; align-items: center; gap: .625rem;
  font-size: 1rem; color: var(--on-surface-var);
  cursor: pointer; user-select: none;
  padding: .375rem 0;
}
.checkbox-row input[type=checkbox] {
  width: 18px; height: 18px;
  accent-color: var(--primary);
  cursor: pointer; flex-shrink: 0;
}

/* ── Textarea ── */
textarea {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--outline);
  border-radius: var(--r-sm);
  color: var(--on-surface);
  font-family: var(--mono);
  font-size: .9375rem;
  line-height: 1.65;
  padding: .875rem 1rem;
  resize: vertical;
  min-height: 160px;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
textarea::placeholder { color: var(--outline); }
textarea:focus {
  border-color: var(--primary);
  border-width: 2px;
  box-shadow: 0 0 0 3px rgba(25,118,210,.1);
}
textarea.drag-over {
  border-color: var(--secondary);
  border-width: 2px;
  box-shadow: 0 0 0 3px rgba(0,137,123,.12);
}

/* ── Buttons ── */
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }

button, .file-label {
  position: relative; overflow: hidden;
  height: 40px; padding: 0 1.125rem;
  font-family: var(--sans); font-size: .9375rem; font-weight: 500;
  letter-spacing: .02em;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: .375rem;
  transition: background .15s, box-shadow .15s, transform .1s;
  white-space: nowrap; border: none; outline: none;
}
button:focus-visible, .file-label:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

button.filled {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--s1);
}
button.filled:hover  { background: var(--primary-dark); box-shadow: var(--s2); }
button.filled:active { transform: scale(.98); box-shadow: none; }

button.outlined, .file-label {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
button.outlined:hover, .file-label:hover { background: var(--primary-container); }
button.outlined:active, .file-label:active { transform: scale(.98); }

button.tonal {
  background: transparent;
  color: var(--secondary);
  border: 1.5px solid var(--secondary);
}
button.tonal:hover  { background: #E0F2F1; }
button.tonal:active { transform: scale(.98); }

button.text-btn {
  background: transparent;
  color: var(--on-surface-var);
  border: 1.5px solid transparent;
}
button.text-btn:hover  { background: rgba(0,0,0,.05); color: var(--on-surface); }
button.text-btn:active { background: rgba(0,0,0,.09); }

.file-label input[type=file] { display: none; }

/* ── Stats ── */
.stats-grid { display: flex; gap: .625rem; flex-wrap: wrap; margin-bottom: .875rem; }
.stat {
  background: var(--surface-var);
  border: 1px solid var(--outline-var);
  border-radius: var(--r-sm);
  padding: .625rem 1.125rem;
  text-align: center;
  min-width: 84px;
}
.stat .v {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--primary);
  line-height: 1.2;
}
.stat .k {
  font-size: .75rem;
  color: var(--on-surface-var);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-top: 2px;
}

/* ── Chips (column type tags) ── */
.col-tags { display: flex; flex-wrap: wrap; gap: .375rem; }
.chip {
  display: inline-flex; align-items: center; gap: .25rem;
  font-family: var(--mono); font-size: .8125rem; font-weight: 500;
  padding: 4px 12px;
  border-radius: 100px; border: 1px solid;
}
.chip.int     { color: #BF360C; border-color: rgba(191,54,12,.3);  background: rgba(255,87,34,.07); }
.chip.double  { color: #6A1B9A; border-color: rgba(106,27,154,.3); background: rgba(156,39,176,.07); }
.chip.varchar { color: #00695C; border-color: rgba(0,105,92,.3);   background: rgba(0,150,136,.07); }

/* ── Output header ── */
.output-header {
  display: flex; align-items: center;
  justify-content: space-between;
  flex-wrap: wrap; gap: .5rem;
  margin-bottom: .75rem;
}

/* ── SQL code block ── */
.code-block {
  background: #1E1E1E;
  border-radius: var(--r-sm);
  overflow: auto;
  resize: vertical;
  min-height: 220px;
  max-height: 480px;
}
.sql-output {
  display: block;
  color: #D4D4D4;
  font-family: var(--mono);
  font-size: .875rem;
  line-height: 1.65;
  padding: 1rem 1.25rem;
  white-space: pre;
  outline: none;
}
/* VS Code Dark+ palette */
.kw  { color: #569CD6; }
.kw2 { color: #C586C0; }
.num { color: #B5CEA8; }
.str { color: #CE9178; }
.cmt { color: #6A9955; font-style: italic; }

/* ── Error banner ── */
.err-banner {
  background: var(--error-bg);
  border: 1px solid rgba(198,40,40,.25);
  border-radius: var(--r-sm);
  padding: .875rem 1rem;
  font-size: 1rem;
  color: var(--error);
  display: flex; align-items: flex-start; gap: .5rem;
}
.err-banner .icon { font-size: 1rem; line-height: 1.5; flex-shrink: 0; }

/* ── Notice ── */
.notice {
  font-family: var(--mono);
  font-size: .8125rem;
  color: var(--on-surface-var);
  margin-top: .625rem;
}

/* ── Features Footer ── */
.features {
  background: var(--surface);
  border-top: 1px solid var(--divider);
  margin-top: 1rem;
  padding: 2rem 1.5rem 2.5rem;
}
.features-inner {
  max-width: 800px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}
.feat-title {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--on-surface);
  margin-bottom: .375rem;
}
.feat-desc {
  font-size: .875rem;
  color: var(--on-surface-var);
  line-height: 1.6;
}
@media (max-width: 540px) {
  .features-inner { grid-template-columns: 1fr; gap: 1.25rem; }
}

/* ── Snackbar ── */
.snackbar {
  position: fixed;
  bottom: 1.5rem; left: 50%;
  transform: translateX(-50%) translateY(72px);
  background: #323232; color: #fff;
  padding: .75rem 1.25rem;
  border-radius: var(--r-sm);
  font-size: .9375rem; font-weight: 500;
  box-shadow: var(--s4);
  transition: transform .22s cubic-bezier(.4,0,.2,1), opacity .22s;
  opacity: 0; z-index: 100; pointer-events: none;
}
.snackbar.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.hidden { display: none !important; }
