:root {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #151a23;
  --card: #1e2430;
  --border: #2d3748;
  --muted: #a0aebc;
  --text: #e5e9f2;
  --primary: #165dff;
  --cyan: #0fc6c2;
  --purple: #722ed1;
  --danger: #ff6b81;
  --success: #00b42a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 0%, rgba(15, 198, 194, .16), transparent 28%),
    radial-gradient(circle at 88% 12%, rgba(22, 93, 255, .14), transparent 30%),
    var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

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

.side {
  padding: 24px 18px;
  border-right: 1px solid rgba(45, 55, 72, .8);
  background: rgba(13, 17, 23, .72);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 8px 24px;
}

.brand strong {
  font-size: 20px;
  letter-spacing: 0;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  text-align: left;
  padding: 0 12px;
}

.nav button.active,
.nav button:hover {
  color: var(--text);
  border-color: rgba(15, 198, 194, .28);
  background: rgba(15, 198, 194, .08);
}

.main {
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.account-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.account-card {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid rgba(45, 55, 72, .9);
  border-radius: 8px;
  background: rgba(21, 26, 35, .72);
  white-space: nowrap;
}

.account-card strong {
  font-size: 13px;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
}

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

.grid {
  display: grid;
  gap: 16px;
}

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

.panel,
.stat,
.login-box {
  border: 1px solid rgba(45, 55, 72, .9);
  background: rgba(21, 26, 35, .72);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .18);
}

.panel {
  padding: 18px;
  overflow-x: auto;
}

.stat {
  padding: 18px;
}

.stat strong {
  display: block;
  font-size: 28px;
  margin-top: 8px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0;
}

.btn {
  min-height: 38px;
  border: 1px solid rgba(45, 55, 72, .9);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text);
  background: rgba(30, 36, 48, .9);
  cursor: pointer;
}

.btn.primary {
  border-color: rgba(22, 93, 255, .9);
  background: linear-gradient(135deg, var(--primary), #0b7cff);
}

.btn.danger {
  color: #ffd5dc;
  border-color: rgba(255, 107, 129, .5);
}

.form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(45, 55, 72, .9);
  border-radius: 8px;
  background: rgba(13, 17, 23, .82);
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

textarea {
  min-height: 130px;
  resize: vertical;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(45, 55, 72, .75);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 500;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(15, 198, 194, .1);
  color: #a6fffb;
  border: 1px solid rgba(15, 198, 194, .25);
  font-size: 12px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr);
  gap: 16px;
}

.login {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-stack {
  width: min(900px, 100%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.login-stack.single {
  width: min(460px, 100%);
  grid-template-columns: 1fr;
}

.login-box {
  padding: 24px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  padding: 12px 14px;
  border: 1px solid rgba(15, 198, 194, .28);
  border-radius: 8px;
  background: rgba(21, 26, 35, .96);
  color: var(--text);
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}

.toast.show {
  transform: none;
  opacity: 1;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(4, 8, 15, .72);
  backdrop-filter: blur(10px);
}

.modal-card {
  width: min(760px, 100%);
  max-height: min(760px, calc(100vh - 44px));
  overflow: auto;
  border: 1px solid rgba(45, 55, 72, .95);
  border-radius: 8px;
  background: rgba(21, 26, 35, .98);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .38);
  padding: 22px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.guide-content {
  display: grid;
  gap: 12px;
}

.guide-content section {
  padding: 14px;
  border: 1px solid rgba(45, 55, 72, .78);
  border-radius: 8px;
  background: rgba(13, 17, 23, .62);
}

.guide-content h3 {
  font-size: 15px;
  margin-bottom: 6px;
}

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

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  color: var(--text);
}

.checkline input {
  width: auto;
}

.modal-actions {
  justify-content: flex-end;
  margin-bottom: 0;
}

.visual-editor {
  display: grid;
  gap: 16px;
}

.editor-toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  align-items: end;
}

.file-drop {
  min-height: 64px;
  display: grid;
  gap: 4px;
  align-content: center;
  border: 1px dashed rgba(15, 198, 194, .42);
  border-radius: 8px;
  padding: 12px;
  background: rgba(15, 198, 194, .06);
  cursor: pointer;
}

.file-drop.dragging {
  border-color: rgba(22, 93, 255, .9);
  background: rgba(22, 93, 255, .12);
}

.file-drop input {
  display: none;
}

.field.compact {
  min-width: 0;
}

.command-field {
  min-width: 220px;
}

.editor-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 1fr);
  gap: 16px;
  min-height: 680px;
}

.editor-workbench.code-maximized {
  grid-template-columns: minmax(0, 1fr);
}

.editor-workbench.code-maximized .preview-panel {
  display: none;
}

.editor-workbench.code-maximized .code-view {
  height: calc(100vh - 240px);
  min-height: 680px;
}

.preview-panel,
.code-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.preview-stage {
  --preview-scale: 1;
  min-height: 620px;
  display: grid;
  place-items: start center;
  overflow: auto;
  border: 1px solid rgba(45, 55, 72, .75);
  border-radius: 8px;
  background: #080b10;
  padding: 16px;
}

.viewport-note {
  display: inline-flex;
  width: fit-content;
  min-height: 28px;
  align-items: center;
  margin: -2px 0 10px;
  padding: 0 10px;
  border: 1px solid rgba(15, 198, 194, .25);
  border-radius: 999px;
  background: rgba(15, 198, 194, .08);
  color: #a6fffb;
  font-size: 12px;
}

.preview-stage iframe {
  width: 1440px;
  height: 620px;
  border: 0;
  border-radius: 8px;
  background: #fff;
  transform: scale(var(--preview-scale));
  transform-origin: top center;
  box-shadow: 0 16px 50px rgba(0, 0, 0, .32);
}

.preview-stage.device-desktop iframe {
  width: 1440px;
  height: 760px;
}

.preview-stage.device-tablet iframe {
  width: 768px;
  height: 1024px;
  border-radius: 18px;
}

.preview-stage.device-mobile iframe {
  width: 390px;
  height: 844px;
  border: 10px solid #151a23;
  border-radius: 28px;
}

.bookmark-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.bookmark-strip:empty {
  display: none;
}

.code-actions {
  align-items: center;
  margin: 0 0 6px;
}

.code-view {
  height: min(70vh, 620px);
  min-height: 460px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(45, 55, 72, .75);
  border-radius: 8px;
  background: rgba(7, 10, 15, .92);
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.code-file {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.code-file-title {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(45, 55, 72, .75);
  background: rgba(21, 26, 35, .98);
  color: var(--muted);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#entryHtmlEditor {
  flex: 1 1 auto;
  display: block;
  width: 100%;
  height: auto;
  min-height: 0;
  box-sizing: border-box;
  border: 0;
  border-radius: 0;
  resize: none;
  padding: 12px 14px;
  background: transparent;
  color: #dbeafe;
  white-space: pre;
  overflow: auto;
  line-height: 1.55;
  tab-size: 2;
}

.code-view.editing {
  border-color: rgba(15, 198, 194, .5);
  box-shadow: inset 0 0 0 1px rgba(15, 198, 194, .18);
}

.tok-tag {
  color: #7dd3fc;
}

.tok-attr {
  color: #facc15;
}

.tok-str {
  color: #86efac;
}

.empty-editor {
  padding: 18px;
  color: var(--muted);
}

.hide {
  display: none !important;
}

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

  .side {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 14px;
  }

  .brand {
    padding-bottom: 12px;
  }

  .nav {
    display: flex;
    overflow-x: auto;
  }

  .nav button {
    white-space: nowrap;
  }

  .main {
    padding: 18px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .account-bar {
    justify-content: flex-start;
  }

  .stats,
  .split,
  .login-stack,
  .editor-toolbar,
  .editor-workbench {
    grid-template-columns: 1fr;
  }

  .preview-stage iframe,
  .preview-stage.device-tablet iframe,
  .preview-stage.device-mobile iframe {
    width: 100%;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 13px;
  }

  h1 {
    font-size: 22px;
  }

  .main {
    padding: 14px;
  }

  .side {
    padding: 12px;
  }

  .brand span {
    display: none;
  }

  .btn,
  input,
  textarea,
  select {
    min-height: 42px;
  }

  .toolbar,
  .account-bar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .account-card {
    width: 100%;
    justify-content: space-between;
  }

  .modal {
    padding: 12px;
  }

  .modal-card {
    max-height: calc(100vh - 24px);
    padding: 16px;
  }

  .modal-head {
    display: grid;
  }

  .stats {
    gap: 10px;
  }

  .stat,
  .panel,
  .login-box {
    padding: 14px;
  }
}
