body {
  font-family: "Roboto", sans-serif;
  background-color: #fffde7;
  margin: 0;
  padding: 0;
  padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: auto;
}

header {
  width: 100%;
  box-sizing: border-box;
  background: #123d35;
  border-bottom: 4px solid #ffd54f;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.16);
}

.header-inner {
  width: min(1180px, calc(100% - 32px));
  min-height: 68px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

.backbar {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

#backButton {
  display: none;
  margin: 12px 0;
  color: #123d35;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}

#backButton:hover {
  text-decoration: underline;
}

#logoAnakBisa {
  width: 156px;
  height: auto;
  display: block;
}

.app-title {
  color: #ffffff;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0;
  padding-left: 18px;
  border-left: 1px solid rgba(255, 255, 255, 0.28);
}

#leaderboard-banner {
  margin-top: 16px;
  margin-bottom: 10px;
  text-align: center;
}

#leaderboard-banner img {
  max-width: min(100%, 728px);
  height: auto;
  display: block;
}

/* Toolbar & Kontrol Latihan */
.toolbar-container {
  width: min(1180px, calc(100% - 32px));
  background: #ffffff;
  border: 2px solid #ffd54f;
  border-radius: 10px;
  padding: 12px 18px;
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  box-sizing: border-box;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.preset-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.preset-group label {
  color: #123d35;
  font-size: 15px;
}

#presetSelect {
  background-color: #fff9c4;
  color: #004d40;
  padding: 8px 12px;
  border: 1.5px solid #fbc02d;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
}

/* Tombol */
button {
  background-color: #ffd54f;
  color: #004d40;
  padding: 9px 16px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

button:hover {
  background-color: #ffca28;
  transform: translateY(-1px);
}

button.btn-primary {
  background-color: #00897b;
  color: #ffffff;
}

button.btn-primary:hover {
  background-color: #00796b;
}

button.btn-small {
  padding: 4px 10px;
  font-size: 13px;
  background: #e0f2f1;
}

/* Container Editor & Hasil */
#container {
  display: flex;
  margin-top: 16px;
  width: min(1180px, calc(100% - 32px));
  height: 620px;
  gap: 16px;
}

#codeContainer,
#outputContainer {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 10px;
  border: 2px solid #ffd54f;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.panel-header {
  background: #123d35;
  color: #ffffff;
  padding: 10px 16px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  background: #37474f;
  color: #eceff1;
}

.badge-success {
  background: #2e7d32;
  color: #ffffff;
}

.badge-error {
  background: #c62828;
  color: #ffffff;
}

/* CodeMirror */
.CodeMirror {
  flex: 1;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 16px;
  line-height: 1.5;
  background: #fafafa;
}

.editor-buttons {
  padding: 10px 14px;
  background: #f5f5f5;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Output Panel */
#output {
  flex: 1;
  padding: 14px;
  background-color: #ffffff;
  overflow: auto;
  font-size: 14px;
}

.initial-msg {
  color: #546e7a;
  font-style: italic;
  padding: 20px;
  text-align: center;
}

/* Tabel Hasil Query SQL */
.table-container {
  overflow-x: auto;
  margin-top: 8px;
}

.sql-table {
  width: 100%;
  border-collapse: collapse;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 14px;
  background: #ffffff;
}

.sql-table th {
  background: #004d40;
  color: #ffffff;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid #00332c;
  position: sticky;
  top: 0;
}

.sql-table td {
  padding: 8px 12px;
  border: 1px solid #e0e0e0;
  color: #263238;
}

.sql-table tr:nth-child(even) {
  background: #f9fbfb;
}

.sql-table tr:hover {
  background: #e0f2f1;
}

.result-summary {
  font-size: 13px;
  color: #00796b;
  font-weight: 600;
  margin-bottom: 8px;
}

.sql-message-box {
  padding: 14px 18px;
  border-radius: 6px;
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.6;
}

.sql-success {
  background: #e8f5e9;
  border-left: 5px solid #2e7d32;
  color: #1b5e20;
}

.sql-error {
  background: #ffebee;
  border-left: 5px solid #c62828;
  color: #b71c1c;
  font-family: "Consolas", monospace;
}

/* Skema Drawer Panel */
#schemaPanel {
  background: #f1f8e9;
  border-bottom: 2px solid #c5e1a5;
  padding: 12px 16px;
  max-height: 240px;
  overflow-y: auto;
}

.schema-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: #33691e;
}

.schema-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.schema-table-card {
  background: #ffffff;
  border: 1px solid #dcedc8;
  border-radius: 6px;
  padding: 8px 12px;
  font-family: "Consolas", monospace;
  font-size: 13px;
}

.schema-table-name {
  color: #1b5e20;
  font-weight: 700;
  margin-bottom: 4px;
  border-bottom: 1px solid #e8f5e9;
  padding-bottom: 2px;
}

.schema-col-list {
  margin: 0;
  padding-left: 16px;
  color: #37474f;
}

.schema-col-type {
  color: #78909c;
  font-size: 11px;
}

/* Responsive */
@media (max-width: 860px) {
  .header-inner {
    width: calc(100% - 24px);
    min-height: 58px;
    gap: 12px;
  }

  #logoAnakBisa {
    width: 124px;
  }

  .app-title {
    font-size: 17px;
    padding-left: 12px;
  }

  .toolbar-container {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-actions {
    justify-content: space-between;
  }

  #container {
    flex-direction: column;
    height: auto;
  }

  #codeContainer,
  #outputContainer {
    min-height: 380px;
  }
}

/* Keep controls and long SQL results inside the viewport. */
[hidden] { display: none !important; }
button:disabled { opacity: .55; cursor: wait; transform: none; }
.preset-group { flex-wrap: wrap; min-width: 0; max-width: 100%; }
#presetSelect { min-width: 0; max-width: 100%; }
.toolbar-actions { flex-wrap: wrap; }
#codeContainer, #outputContainer { min-width: 0; }
#leaderboard-banner { max-width: calc(100% - 32px); }
.playground-note { width: min(1180px, calc(100% - 32px)); box-sizing: border-box; color: #37474f; font-size: 15px; line-height: 1.6; margin: 12px 0 0; }
.sql-message-box { overflow-wrap: anywhere; }
.schema-col-type { font-size: 13px; color: #546e7a; }
@media (max-width: 860px) {
  .preset-group { flex-direction: column; align-items: stretch; }
  .toolbar-actions { justify-content: flex-start; }
  #presetSelect { width: 100%; }
  .editor-buttons { flex-wrap: wrap; }
}

.sql-table th, .sql-table td { white-space: nowrap; }
.sql-table, #output { font-size: 15px; }
