:root {
  color-scheme: dark;
  --bg: #11110f;
  --panel: #20211d;
  --panel-2: #2b2a24;
  --line: #474233;
  --text: #f8f4e9;
  --muted: #bcb3a0;
  --accent: #dfad3f;
  --accent-2: #f2cf74;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #11110f;
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.admin-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  min-height: 100vh;
  padding: 22px;
}

.workspace {
  display: grid;
  place-items: center;
  min-width: 0;
}

.canvas-wrap {
  width: min(100%, calc(100vh - 44px));
  max-width: 980px;
  aspect-ratio: 1;
  background: #050505;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
}

#adminCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.panel {
  align-self: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel-head {
  display: grid;
  gap: 4px;
}

.eyebrow {
  margin: 0;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
}

#templateInput {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #17120b;
  font-weight: 800;
  cursor: pointer;
}

button:hover,
.upload-button:hover {
  background: var(--accent-2);
}

.field-row {
  display: grid;
  gap: 7px;
}

.field-grid,
.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

select,
input[type="number"],
input[type="color"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #11110f;
  color: var(--text);
}

input[type="number"] {
  padding: 0 10px;
}

input[type="text"] {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #11110f;
  color: var(--text);
}

input[type="color"] {
  padding: 4px;
}

input[type="range"] {
  accent-color: var(--accent);
}

.checkbox-row {
  gap: 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.hint {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.button-grid button {
  background: #efeee6;
}

.download-button {
  background: #f1f1ea;
}

.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 6px;
  background: #335f3e;
  color: #f7fff2;
  font-weight: 800;
  text-decoration: none;
}

.share-box {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
}

.preview-section {
  padding: 0 22px 22px;
}

.preview-title {
  width: min(100%, 1260px);
  margin: 0 auto 12px;
}

.user-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  width: min(100%, 1260px);
  min-height: 680px;
  margin: 0 auto;
  padding: 18px;
  background: #11110f;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.user-preview-stage {
  display: grid;
  place-items: center;
  min-width: 0;
}

.user-preview-poster {
  width: min(100%, 660px);
  max-height: 100%;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.user-preview-panel {
  align-self: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.user-preview-crop {
  display: block;
  width: 100%;
  background: #f5f2ed;
  border-radius: 6px;
  cursor: grab;
  touch-action: none;
}

.user-preview-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 900px) {
  .admin-shell {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .canvas-wrap {
    width: 100%;
  }

  .panel {
    align-self: stretch;
  }

  .user-preview {
    grid-template-columns: 1fr;
    overflow: auto;
  }
}

.back-link {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.back-link:hover {
  color: var(--accent-2);
}

.save-button {
  background: var(--accent);
  color: #17120b;
}

.save-button:hover {
  background: var(--accent-2);
}

.save-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.delete-button {
  background: #6b2a2a;
  color: #ffe9e9;
}

.delete-button:hover {
  background: #8a3636;
}

.save-status {
  margin: 0;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.save-status.error {
  color: #ffb4b4;
  border-color: #6b2a2a;
  background: rgba(107, 42, 42, 0.25);
}

.save-status.success {
  color: #b7e6bf;
  border-color: #2c5a34;
  background: rgba(44, 90, 52, 0.25);
}

/* Dashboard */

.dashboard-shell {
  min-height: 100vh;
  padding: 22px;
}

.login-screen {
  min-height: calc(100vh - 44px);
  display: grid;
  place-items: center;
}

.login-card {
  width: min(100%, 360px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  max-width: 1200px;
  margin: 0 auto 22px;
}

.dashboard-header-actions {
  display: flex;
  gap: 10px;
}

.ghost-button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

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

.dashboard-screen .save-status,
.dashboard-screen .hint {
  max-width: 1200px;
  margin: 0 auto 18px;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  max-width: 1200px;
  margin: 0 auto;
}

.project-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.project-card-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
  word-break: break-word;
}

.project-card-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.project-card-link {
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.project-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.project-card-actions button {
  flex: 1;
  min-height: 38px;
  padding: 0 10px;
  font-size: 13px;
  background: #efeee6;
}

.project-card-actions .delete-btn {
  background: #6b2a2a;
  color: #ffe9e9;
}

.project-card-actions .delete-btn:hover {
  background: #8a3636;
}

@media (max-width: 700px) {
  .dashboard-shell {
    padding: 14px;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
