:root {
  color-scheme: dark;
  --bg: #121212;
  --panel: #1b1b1b;
  --panel-border: #303030;
  --text: #e7e7e7;
  --muted: #a8a8a8;
  --accent: #7cc7ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #161616 0%, #101010 100%);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  padding: 16px;
}

a {
  color: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.topbar h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

button {
  border: 1px solid var(--panel-border);
  background: #262626;
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

.layout {
  display: flex;
  gap: 16px;
  height: calc(100vh - 92px);
  min-height: 600px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: rgba(27, 27, 27, 0.9);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  min-width: 0;
}

.editor-panel {
  flex: 0 0 38%;
}

.output-panel {
  flex: 1 1 62%;
}

label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

textarea {
  flex: 1;
  width: 100%;
  resize: none;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: #0d0d0d;
  color: var(--text);
  padding: 14px;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  outline: none;
}

textarea:focus {
  border-color: var(--accent);
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.hidden {
  visibility: hidden;
}

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid #3b3b3b;
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

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

.canvas-shell {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: #050505;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

@media (max-width: 1100px) {
  .topbar h1 {
    font-size: 21px;
  }

  .layout {
    min-height: 520px;
  }

  .editor-panel {
    flex-basis: 44%;
  }

  .output-panel {
    flex-basis: 56%;
  }
}

@media (max-width: 900px) {
  body {
    padding: 12px;
  }

  .topbar {
    flex-wrap: wrap;
    align-items: flex-start;
    margin-bottom: 12px;
  }

  .topbar h1 {
    font-size: 19px;
  }

  .topbar p {
    font-size: 14px;
    line-height: 1.4;
  }

  #render-btn {
    width: 100%;
    min-height: 44px;
  }

  .layout {
    flex-direction: column;
    height: auto;
    min-height: 0;
  }

  .panel {
    padding: 12px;
    border-radius: 14px;
  }

  .editor-panel,
  .output-panel {
    flex: 1 1 auto;
  }

  .editor-panel {
    min-height: 320px;
  }

  .canvas-shell {
    min-height: 300px;
  }
}

@media (max-width: 560px) {
  body {
    padding: 10px;
  }

  .topbar {
    gap: 10px;
  }

  .topbar h1 {
    font-size: 17px;
    line-height: 1.25;
  }

  .topbar p {
    font-size: 13px;
  }

  button {
    width: 100%;
    border-radius: 12px;
  }

  .layout {
    gap: 12px;
  }

  .panel {
    gap: 8px;
    padding: 10px;
  }

  label {
    letter-spacing: 0.1em;
  }

  textarea {
    min-height: 260px;
    padding: 12px;
    font-size: 12px;
  }

  .canvas-shell {
    min-height: 240px;
  }
}