* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #0f172a;
  color: #e5e7eb;
}

a {
  color: inherit;
  text-decoration: none;
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #020617;
  border-right: 1px solid #1e293b;
  padding: 16px;
  overflow-y: auto;
}

.brand {
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 14px;
}

.muted {
  color: #94a3b8;
  font-size: 13px;
}

.box {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
}

.box h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

input,
textarea,
button {
  font-family: inherit;
}

input[type="text"],
input[type="file"] {
  width: 100%;
  background: #020617;
  border: 1px solid #334155;
  color: #e5e7eb;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
}

button,
.btn {
  border: 0;
  background: #2563eb;
  color: white;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-block;
  font-size: 14px;
}

button:hover,
.btn:hover {
  background: #1d4ed8;
}

.btn-danger {
  background: #dc2626;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-dark {
  background: #334155;
}

.btn-dark:hover {
  background: #475569;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.file-item {
  padding: 9px 10px;
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 8px;
  font-size: 14px;
  word-break: break-all;
}

.file-item.active {
  background: #1d4ed8;
  border-color: #60a5fa;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: #111827;
  border-bottom: 1px solid #1f2937;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-title {
  font-weight: bold;
  word-break: break-all;
}

.editor-wrap {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 0;
  flex: 1;
  min-height: calc(100vh - 61px);
}

.editor-panel {
  padding: 16px;
  min-width: 0;
}

textarea.editor {
  width: 100%;
  min-height: 68vh;
  resize: vertical;
  background: #020617;
  color: #d1d5db;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 16px;
  font-family: Consolas, Monaco, monospace;
  font-size: 14px;
  line-height: 1.55;
  tab-size: 2;
  outline: none;
}

textarea.editor:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, .25);
}

.preview-panel {
  border-left: 1px solid #1f2937;
  background: #020617;
  padding: 16px;
}

iframe {
  width: 100%;
  height: 70vh;
  background: white;
  border: 1px solid #334155;
  border-radius: 12px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0;
}

.message {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.success {
  background: #064e3b;
  border: 1px solid #10b981;
  color: #d1fae5;
}

.error {
  background: #450a0a;
  border: 1px solid #ef4444;
  color: #fee2e2;
}

.warning {
  background: #451a03;
  border: 1px solid #f97316;
  color: #ffedd5;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14px;
}

.small-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.small-form input {
  flex: 1;
  margin: 0;
  min-width: 200px;
}

.mt {
  margin-top: 14px;
}

pre {
  white-space: pre-wrap;
  color: #cbd5e1;
  background: #020617;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 10px;
  overflow-x: auto;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid #1e293b;
    max-height: 45vh;
  }

  .editor-wrap {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    border-left: none;
    border-top: 1px solid #1f2937;
  }
}