html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--background, #fafafa);
  color: var(--text, #222);
  transition: background 0.3s, color 0.3s;
}

/* Theme toggle container in top right */
#theme-toggle-container {
  position: fixed;
  top: 18px;
  right: 32px;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 0.6em;
  user-select: none;
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0;
  right: 0; bottom: 0;
  background-color: #ccc;
  border-radius: 26px;
  transition: .4s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 20px; width: 20px;
  left: 3px; bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: .4s;
}
input:checked + .slider {
  background-color: #607d8b;
}
input:focus + .slider {
  box-shadow: 0 0 1px #607d8b;
}
input:checked + .slider:before {
  transform: translateX(20px);
}
#theme-label {
  font-size: 1em;
  color: var(--text, #222);
  font-weight: 500;
  letter-spacing: 0.04em;
}

.mdl-layout__content {
  width: 100%;
}

.centered {
  max-width: 1100px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
}

.centered h1 {
  width: 100%;
  text-align: center;
  margin-bottom: 2.2rem;
  font-size: 2.7rem;
  letter-spacing: 0.02em;
}

#upload-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2.2rem;
  gap: 1.2em;
}

#file-count {
  margin-left: 1em;
  font-weight: 500;
}

#preview-table {
  margin-top: 1.6rem;
  margin-bottom: 2rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.file-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 2em;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 3px 14px #0002;
  background: none;
  border: 2px solid var(--table-border, #e0e0e0);
}

/* Table borders: visible in both themes */
.file-table th,
.file-table td {
  border-right: 1px solid var(--table-border, #e0e0e0);
  padding: 1.2em 0.7em;
  vertical-align: top;
  border-bottom: none;
}

/* Perfect horizontal line between rows (fix for border alignment) */
.file-table tr {
  position: relative;
}
.file-table tr:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 0;
  border-bottom: 1.5px solid var(--table-border, #444);
  pointer-events: none;
}

.file-table th {
  background: var(--background, #fafafa);
  color: var(--text, #222);
  font-weight: 600;
  text-align: center;
  border-top: 1px solid var(--table-border, #e0e0e0);
}

.file-table td {
  background: var(--background, #fafafa);
  color: var(--text, #222);
  text-align: center;
}

/* --- PREVIEW CORRECTION + SCROLLBAR --- */
.preview-xml {
  width: 900px;
  min-width: 340px;
  max-width: 100vw;
  height: 400px;
  max-height: 70vh;
  overflow: auto;
  text-align: left;
  background: #f6f3f1;
  color: #272822;
  border-radius: 18px;
  padding: 1.4em;
  font-size: 0.97em;
  margin: 0 auto;
  box-shadow: 0 2px 8px #0001;
  border: 1.5px solid #e0e0e0;
  white-space: pre;
}

/* --- CUSTOM SCROLLBAR (Chrome, Edge, Safari) --- */
.preview-xml::-webkit-scrollbar {
  width: 14px;
  height: 14px;
  background: transparent;
}
.preview-xml::-webkit-scrollbar-thumb {
  background: #dadada;
  border-radius: 9px;
  border: 4px solid transparent;
  background-clip: padding-box;
}
.preview-xml::-webkit-scrollbar-corner {
  background: transparent;
}
html[data-theme="dark"] .preview-xml::-webkit-scrollbar-thumb {
  background: #444;
}

/* --- CUSTOM SCROLLBAR (Firefox) --- */
.preview-xml {
  scrollbar-color: #dadada #f6f3f1;
  scrollbar-width: thin;
}
html[data-theme="dark"] .preview-xml {
  scrollbar-color: #444 #232323;
}

/* Material dark for preview */
html[data-theme="dark"] .preview-xml {
  background: #232323;
  color: #f8f8f2;
  border: 1.5px solid #383838;
}

/* Responsive for mobile (show horizontal scrollbar if needed) */
@media (max-width: 1000px) {
  .preview-xml {
    width: 95vw;
    min-width: 180px;
    height: 300px;
    font-size: 0.93em;
  }
}

.action-btns {
  display: flex;
  flex-direction: column;
  gap: 1.3em;
  align-items: center;
  justify-content: center;
  margin-top: 0.7em;
}

.file-table th, .file-table td {
  border-radius: 0 !important;
}

.hidden {
  display: none !important;
}

#conversion-progress {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.25);
  z-index: 99;
  display: flex;
  align-items: center;
  justify-content: center;
}

#conversion-progress > div {
  background: #fff;
  border-radius: 8px;
  padding: 2em;
  box-shadow: 0 2px 12px #0002;
  max-width: 320px;
  margin: 2em auto;
  text-align: center;
}

#snackbar {
  visibility: hidden;
  min-width: 200px;
  background-color: #323232;
  color: #fff;
  text-align: center;
  border-radius: 4px;
  padding: 1em;
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  z-index: 100;
  font-size: 1em;
  opacity: 0;
  transition: visibility 0s, opacity 0.4s;
}

#snackbar.show {
  visibility: visible;
  opacity: 1;
}

#modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 101;
  display: flex;
  align-items: center;
  justify-content: center;
}

#modal-dialog {
  background: #fff;
  padding: 2em 1em;
  border-radius: 8px;
  box-shadow: 0 2px 20px #0005;
  min-width: 260px;
  max-width: 340px;
  text-align: center;
}

#modal-message {
  margin-bottom: 1.6em;
  font-size: 1.1em;
}

#modal-actions {
  display: flex;
  justify-content: center;
  gap: 1em;
}

/* Validity message card */
.validity-msg {
  border-radius: 12px;
  padding: 1.1em 1em;
  margin-bottom: 1.1em;
  font-size: 1.06em;
  font-weight: 500;
  background: #e6f4ea;
  color: #388e3c;
  box-shadow: 0 2px 6px #388e3c20;
  display: flex;
  align-items: center;
  gap: 0.8em;
  justify-content: center;
}
html[data-theme="dark"] .validity-msg {
  background: #223c2f;
  color: #b7ffc6;
  box-shadow: 0 2px 8px #388e3c30;
}

.file-table td {
  vertical-align: middle;
}

/* Button spacing */
.mdl-button {
  min-width: 120px;
  margin: 0.15em 0;
  font-size: 1.03em;
}

/* Stronger table borders for dark theme */
:root {
  --background: #fafafa;
  --text: #222;
  --table-border: #e0e0e0;
}
html[data-theme="dark"] {
  --background: #222;
  --text: #fafafa;
  --table-border: #444; /* more visible border in dark mode */
}
html[data-theme="dark"] .file-table th,
html[data-theme="dark"] .file-table td {
  background: #222;
  color: #fafafa;
}
html[data-theme="dark"] #modal-dialog {
  background: #222;
  color: #fafafa;
}
html[data-theme="dark"] #conversion-progress > div {
  background: #222;
  color: #fafafa;
}

/* Fix for Prism.js shadow on code tokens in dark theme */
.preview-xml .token {
  text-shadow: none !important;
}