:root {
  --bg1: #d9f3f1;
  --bg2: #bfe8ef;
  --text: #0f172a;

  --card: #ffffff;
  --muted: rgba(15, 23, 42, 0.55);

  --shadow: 0 18px 60px rgba(0, 0, 0, 0.18);
  --shadowSoft: 0 8px 24px rgba(0, 0, 0, 0.14);

  --radiusLg: 18px;
  --radiusMd: 14px;

  --green: #6ea600;
  --blue: #0b78b5;
  --darkBtn: #0b1220;

  --rowBg: #eef1f5;
  --rowBg2: #f5f7fb;

  --border: rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

/* ✅ CRITICAL FIX:
   Author CSS was overriding the native [hidden] behavior.
   This forces hidden elements (modals, download links, export row, etc.) to actually disappear. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji",
    "Segoe UI Emoji";
  color: var(--text);
  background: radial-gradient(1200px 700px at 30% 15%, var(--bg1), transparent 60%),
    radial-gradient(1200px 700px at 70% 30%, var(--bg2), transparent 60%),
    linear-gradient(180deg, #d8f2ef 0%, #bfe7ee 100%);
}

.page {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.hero {
  padding: 32px 16px 14px;
  text-align: center;
}

.title {
  margin: 0;
  font-size: clamp(40px, 4vw, 56px);
  letter-spacing: 0.5px;
  font-weight: 900;
}

.main {
  width: min(1160px, calc(100% - 24px));
  margin: 0 auto;
  display: grid;
  gap: 18px;
  padding-bottom: 12px;
}

/* Preview section */
.previewSection {
  display: grid;
  place-items: center;
  gap: 14px;
}

.terminalWindow {
  width: min(820px, 100%);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #0b1020;
}

.terminalTopbar {
  height: 34px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  background: #2b3a44;
}

.dots {
  display: flex;
  gap: 8px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  opacity: 0.9;
}

.dot.red {
  background: #ff5f57;
}
.dot.yellow {
  background: #febc2e;
}
.dot.green {
  background: #28c840;
}

.terminalScreen {
  padding: 18px;
  min-height: 250px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-weight: 600;
  line-height: 1.5;
  color: #e5e7eb;
  background: radial-gradient(900px 520px at 35% 25%, rgba(20, 60, 140, 0.35), transparent 60%),
    radial-gradient(900px 520px at 60% 55%, rgba(0, 0, 0, 0.55), transparent 70%),
    linear-gradient(180deg, #071327 0%, #070b16 100%);
}

.terminalScreen[data-theme="charcoal"] {
  background: radial-gradient(900px 520px at 35% 25%, rgba(60, 60, 60, 0.35), transparent 60%),
    radial-gradient(900px 520px at 60% 55%, rgba(0, 0, 0, 0.55), transparent 70%),
    linear-gradient(180deg, #0c0f16 0%, #07080c 100%);
}

/* Terminal line segments */
.termLine {
  white-space: pre-wrap;
  word-break: break-word;
}

.segPath {
  color: #39d353;
  font-weight: 800;
}

.segDollar {
  color: #b8c2d1;
  font-weight: 700;
}

.segCmd {
  color: #e5e7eb;
}

.cursor {
  display: inline-block;
  width: 9px;
  height: 18px;
  margin-left: 2px;
  background: #39d353;
  border-radius: 3px;
  vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

/* Buttons */
.controls {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
}

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  border-radius: 9px;
  padding: 10px 16px;
  font-weight: 800;
  color: #fff;
  box-shadow: var(--shadowSoft);
  transition: transform 0.08s ease, filter 0.08s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn:hover {
  filter: brightness(1.02);
}

.btnGreen {
  background: var(--green);
}

.btnBlue {
  background: var(--blue);
}

.btnDark {
  background: var(--darkBtn);
}

.exportRow {
  width: min(820px, 100%);
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.exportLeft {
  display: flex;
  align-items: center;
  gap: 10px;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(15, 23, 42, 0.2);
  border-top-color: rgba(15, 23, 42, 0.7);
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.downloadLink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(11, 18, 32, 0.92);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

.downloadLink:hover {
  filter: brightness(1.06);
}

/* Editor section */
.editorSection {
  width: 100%;
  display: grid;
  place-items: center;
}

.tableCard {
  width: 100%;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(7px);
  border: 1px solid var(--border);
  box-shadow: var(--shadowSoft);
  overflow: hidden;
}

.tableHeader {
  display: grid;
  grid-template-columns: 220px 1fr 140px 140px 90px;
  gap: 12px;
  padding: 12px 12px;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--border);
  font-weight: 900;
  font-size: 13px;
}

.th {
  color: rgba(15, 23, 42, 0.85);
}

.rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}

.row {
  display: grid;
  grid-template-columns: 220px 1fr 140px 140px 90px;
  gap: 12px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(15, 23, 42, 0.08);
  cursor: pointer;
}

.row:hover {
  background: rgba(255, 255, 255, 0.75);
}

.row.selected {
  outline: 3px solid rgba(11, 120, 181, 0.35);
  background: rgba(255, 255, 255, 0.82);
}

.input {
  width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: var(--rowBg2);
  border-radius: 10px;
  padding: 9px 10px;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.92);
  outline: none;
}

.input::placeholder {
  color: rgba(15, 23, 42, 0.45);
  font-weight: 700;
}

.input:focus {
  border-color: rgba(11, 120, 181, 0.45);
  box-shadow: 0 0 0 4px rgba(11, 120, 181, 0.14);
}

.smallNum {
  text-align: center;
  background: var(--rowBg);
  font-weight: 900;
}

.ops {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}

.opBtn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.18);
  background: rgba(255, 255, 255, 0.8);
  font-weight: 900;
  cursor: pointer;
}

.opBtn:hover {
  filter: brightness(1.02);
}

.opBtn:active {
  transform: translateY(1px);
}

/* Toggle switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.25);
  border-radius: 999px;
  transition: 0.2s ease;
}

.slider:before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 999px;
  transition: 0.2s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.22);
}

.switch input:checked + .slider {
  background: rgba(11, 120, 181, 0.9);
}

.switch input:checked + .slider:before {
  transform: translateX(20px);
}

/* Bottom multiline bar */
.multilineBar {
  border-top: 1px solid var(--border);
  padding: 12px;
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 12px;
  align-items: start;
  background: rgba(255, 255, 255, 0.82);
}

.multilineLeft {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 6px;
}

.multilineLabel {
  font-weight: 900;
  color: rgba(15, 23, 42, 0.75);
}

.multilineEditor {
  width: 100%;
  min-height: 54px;
  resize: vertical;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(240, 244, 249, 0.95);
  padding: 12px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-weight: 700;
  outline: none;
}

.multilineEditor.big {
  min-height: 120px;
}

.multilineEditor:focus {
  border-color: rgba(11, 120, 181, 0.45);
  box-shadow: 0 0 0 4px rgba(11, 120, 181, 0.14);
}

/* Modal */
.modalOverlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.55);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 999;
}

.modalCard {
  width: min(720px, 100%);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.12);
}

.modalWide {
  width: min(980px, 100%);
}

.modalHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.85);
}

.modalTitle {
  font-weight: 900;
  font-size: 18px;
}

.iconBtn {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  font-weight: 900;
  font-size: 18px;
  line-height: 1;
}

.iconBtn:hover {
  filter: brightness(1.02);
}

.modalBody {
  padding: 16px;
}

/* Settings form */
.settingsGrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.field label {
  display: block;
  font-weight: 900;
  font-size: 13px;
  color: rgba(15, 23, 42, 0.8);
  margin-bottom: 8px;
}

.fieldInput {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(243, 247, 252, 0.95);
  padding: 10px 10px;
  font-weight: 800;
  outline: none;
}

.fieldInput:focus {
  border-color: rgba(11, 120, 181, 0.45);
  box-shadow: 0 0 0 4px rgba(11, 120, 181, 0.14);
}

.divider {
  height: 1px;
  background: rgba(15, 23, 42, 0.12);
  margin: 16px 0;
}

/* Presets */
.presetsHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.presetsTitle {
  font-weight: 900;
}

.presetsButtons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.fileBtn {
  position: relative;
  overflow: hidden;
}

.presetTextarea {
  width: 100%;
  min-height: 170px;
  resize: vertical;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(240, 244, 249, 0.95);
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-weight: 700;
  outline: none;
}

.presetTextarea:focus {
  border-color: rgba(11, 120, 181, 0.45);
  box-shadow: 0 0 0 4px rgba(11, 120, 181, 0.14);
}

.presetsFooter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.spacer {
  flex: 1;
}

/* Export modal */
.exportButtons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.exportHint {
  margin: 0 0 12px;
  color: rgba(15, 23, 42, 0.62);
  font-weight: 700;
}

.exportStatusRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
}

.exportMiniStatus {
  font-weight: 900;
}

/* Footer */
.siteFooter {
  margin-top: auto;
  padding: 18px 12px 22px;
  display: flex;
  justify-content: center;
}

.siteFooterInner {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: rgba(15, 23, 42, 0.75);
}

.siteFooterInner a {
  color: rgba(15, 23, 42, 0.92);
  text-decoration: none;
  font-weight: 900;
}

.siteFooterInner a:hover {
  text-decoration: underline;
}

.siteFooterSep {
  opacity: 0.5;
}

/* Responsive */
@media (max-width: 980px) {
  .tableHeader,
  .row {
    grid-template-columns: 180px 1fr 120px 120px 80px;
  }

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

@media (max-width: 720px) {
  .tableHeader {
    display: none;
  }

  .row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .ops {
    justify-content: flex-start;
  }

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

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