:root {
  color-scheme: dark;
  --bg: #14161c;
  --bg-panel: #1c1f28;
  --bg-panel-2: #232732;
  --border: #333744;
  --text: #e6e8ee;
  --text-dim: #9aa0ae;
  --accent: #7c9eff;
  --accent-strong: #5a7eff;
  --danger: #ff6b6b;
  --danger-strong: #e05252;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

header.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

header.site-header .brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  margin-right: auto;
}

header.site-header nav {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.92rem;
}

main {
  flex: 1;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

footer.site-footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
}

h1 {
  font-size: 1.4rem;
  margin: 0 0 1rem;
}

h2 {
  font-size: 1.1rem;
  margin: 1.5rem 0 0.75rem;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

textarea {
  width: 100%;
  min-height: 8rem;
  background: var(--bg-panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  resize: vertical;
}

input[type="text"],
select {
  background: var(--bg-panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  font-size: 0.9rem;
}

button {
  background: var(--accent);
  color: #0c0e13;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.danger {
  background: var(--danger);
}

button.danger:hover {
  background: var(--danger-strong);
}

button.secondary {
  background: var(--bg-panel-2);
  color: var(--text);
  border: 1px solid var(--border);
}

button.secondary:hover {
  background: var(--border);
}

.login-panel {
  max-width: 32rem;
}

ul.publish-scope {
  margin: 0.25rem 0 0.5rem;
  padding-left: 1.25rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.6;
}

ul.publish-scope strong {
  color: var(--text);
}

a.btn-google {
  display: inline-block;
  margin-top: 0.5rem;
  background: var(--accent);
  color: #0c0e13;
  border-radius: 6px;
  padding: 0.6rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
}

a.btn-google:hover {
  background: var(--accent-strong);
}

.row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 0.6rem 0;
}

.field-label {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-right: 0.25rem;
}

canvas.preview {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #202020;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.status {
  font-size: 0.85rem;
  min-height: 1.2em;
}

.status.error {
  color: var(--danger);
}

.status.ok {
  color: #7de08f;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}

.gallery-item {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  text-align: center;
}

.gallery-item img {
  width: 100%;
  aspect-ratio: 1 / 1;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #202020;
  border-radius: 6px;
}

.gallery-item .title {
  font-size: 0.85rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-item .meta {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.list-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}

.list-row img {
  width: 56px;
  height: 56px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #202020;
  border-radius: 6px;
  flex-shrink: 0;
}

.list-row .info {
  flex: 1;
  min-width: 0;
}

.list-row .info .title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-row .info .meta {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.empty {
  color: var(--text-dim);
  font-size: 0.9rem;
  padding: 1rem 0;
}

.terms h2 {
  font-size: 1rem;
}

.terms p,
.terms li {
  color: var(--text-dim);
  font-size: 0.92rem;
}

.pagination {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.25rem;
}

code.px1-preview {
  display: block;
  word-break: break-all;
  background: var(--bg-panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem;
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* --- editor page ------------------------------------------------------- */

.editor-layout {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(240px, 320px);
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 720px) {
  .editor-layout {
    grid-template-columns: 1fr;
  }
}

.editor-canvas-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.canvas-stack {
  position: relative;
  display: inline-block;
  line-height: 0; /* canvas is inline by default and leaves a small baseline gap otherwise */
  max-width: 480px;
  width: 100%;
}

canvas.edit-canvas {
  width: 100%;
  max-width: 480px;
  height: auto;
  aspect-ratio: 1 / 1;
  touch-action: none;
  cursor: crosshair;
}

canvas.cursor-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  pointer-events: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.palette-panel {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.palette-swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

button.swatch {
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  border-radius: 6px;
  border: 2px solid var(--border);
  cursor: pointer;
}

button.swatch.selected {
  border: 2px solid var(--accent);
  outline: 2px solid var(--bg-panel);
  outline-offset: -6px;
}

canvas.sv-canvas {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  touch-action: none;
  cursor: crosshair;
}

input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

#hex-input {
  width: 8ch;
  text-transform: uppercase;
}
