:root {
  --panel: #ffffff;
  --text: #0f172a;
  --subtext: #334155;
  --border: #bfdbfe;
  --primary: #1d4ed8;
  --primary-strong: #1e40af;
  --primary-soft: #dbeafe;
  --success: #0e9f6e;
  --danger: #c81e1e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
  min-height: 100vh;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #93c5fd;
  background: linear-gradient(90deg, #dbeafe 0%, #bfdbfe 100%);
  position: sticky;
  top: 0;
  z-index: 10;
}

.title-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.app-icon {
  color: var(--primary);
  font-size: 1.35rem;
}

.title-wrap h1 {
  margin: 0;
  font-size: 1.25rem;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

button {
  border: 1px solid #93c5fd;
  background: #eff6ff;
  color: var(--primary-strong);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease, transform 120ms ease;
}

button:hover:enabled {
  border-color: var(--primary-strong);
  background: #dbeafe;
  color: #1e3a8a;
  transform: translateY(-1px);
}

button:disabled {
  background: #e2e8f0;
  color: #64748b;
  border-color: #cbd5e1;
  opacity: 0.8;
  cursor: not-allowed;
  transform: none;
}

#saveDiskBtn {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

#saveDiskBtn:hover:enabled {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
  color: #ffffff;
}

.split-layout {
  --left-pane-width: 1fr;
  --right-pane-width: 1fr;
  display: grid;
  grid-template-columns: minmax(240px, var(--left-pane-width)) 12px minmax(240px, var(--right-pane-width));
  gap: 0.75rem;
  padding: 1rem;
  height: calc(100vh - 78px);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-shadow: 0 8px 24px rgba(30, 64, 175, 0.08);
}

.splitter {
  cursor: col-resize;
  position: relative;
  border-radius: 999px;
  background: transparent;
  outline: none;
}

.splitter::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 3px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: #93c5fd;
}

.splitter:hover::before,
.splitter:focus-visible::before,
body.is-resizing .splitter::before {
  background: var(--primary);
}

body.is-resizing {
  cursor: col-resize;
  user-select: none;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #dbeafe;
  background: var(--primary-soft);
}

.panel-header h2 {
  margin: 0;
  font-size: 1rem;
}

.status-text {
  color: var(--subtext);
  font-size: 0.85rem;
}

/* Prism editor overlay — transparent textarea over a Prism-highlighted pre */
.prism-editor-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.prism-editor-wrap pre,
.prism-editor-wrap textarea {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 1rem;
  font-family: Consolas, Menlo, Monaco, monospace;
  font-size: 0.95rem;
  line-height: 1.6;
  white-space: pre;
  word-break: normal;
  tab-size: 2;
  border: 0;
  border-radius: 0;
  box-sizing: border-box;
}

/* Highlighted pre sits behind the textarea */
.prism-editor-wrap pre {
  z-index: 1;
  pointer-events: none;
  background: #f8fbff;
  overflow: hidden; /* scrolled in sync via JS, not by the user */
  box-shadow: none;
  text-shadow: none;
}

/* Override Prism theme defaults that conflict with our layout */
.prism-editor-wrap pre[class*="language-"] {
  background: #f8fbff;
  margin: 0;
  padding: 1rem;
  border-radius: 0;
  box-shadow: none;
  text-shadow: none;
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Transparent textarea on top captures all input */
.prism-editor-wrap textarea {
  z-index: 2;
  background: transparent;
  color: transparent;
  caret-color: var(--text);
  -webkit-text-fill-color: transparent;
  resize: none;
  outline: none;
  overflow: auto;
}

.output {
  height: 100%;
  overflow: auto;
  padding: 1rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.output svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.output pre {
  width: 100%;
  margin: 0;
}

.error {
  color: var(--danger);
}

.success {
  color: var(--success);
}

@media (max-width: 980px) {
  .split-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .panel {
    min-height: 45vh;
  }

  .splitter {
    display: none;
  }
}
