:root {
  --bg: #111;
  --bg-panel: #1a1a1a;
  --border: #333;
  --text: #e0e0e0;
  --text-muted: #888;
  --accent: #6c5ce7;
  --accent-hover: #7d6ee8;
  --grid-default: #1a1a1a;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.referral-banner {
  padding: 0.5rem 1rem;
  background: var(--border);
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.referral-banner.hidden {
  display: none;
}

.referral-banner__text {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text);
}

.header {
  text-align: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
}

.tagline {
  margin: 0.25rem 0 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.main {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem;
  gap: 1.5rem;
}

/* In edit mode, raise main above the overlay so the grid is not greyed out and receives pointer events */
.main.main--edit {
  position: relative;
  z-index: 51;
}

.canvas-wrap {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.4);
}

.canvas-wrap--edit {
  z-index: 51;
  touch-action: none;
}

#grid {
  display: block;
  width: 100%;
  max-width: 700px;
  aspect-ratio: 1;
  height: auto;
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-crisp-edges;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
}

.tooltip {
  position: absolute;
  left: 0;
  top: 0;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.85);
  border-radius: 6px;
  font-size: 12px;
  pointer-events: none;
  transform: translate(-50%, -100%);
  margin-top: -8px;
  white-space: nowrap;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.15s;
}

.tooltip.visible {
  opacity: 1;
}

.timeline {
  width: 100%;
  max-width: 600px;
}

.timeline-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.timeline-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.btn:hover {
  background: #252525;
}

.btn-icon {
  width: 40px;
  padding: 8px;
  font-size: 16px;
}

.btn-icon--active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-icon--active:hover {
  background: var(--accent-hover);
}

.btn:disabled,
.btn-icon:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  width: 100%;
  padding: 12px;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--accent);
  border-color: var(--accent);
}

.btn-primary:disabled:hover {
  background: var(--accent);
}

#daySlider {
  flex: 1;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 4px;
}

#daySlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}

#daySlider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.day-label {
  min-width: 4rem;
  font-size: 14px;
  color: var(--text-muted);
}

.timeline-description-wrap {
  margin-top: 1rem;
  max-width: 700px;
}

.timeline-description-toggle {
  display: none;
  width: 100%;
  padding: 0.5rem 0;
  font-size: 0.9rem;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}

.timeline-description-toggle:hover {
  text-decoration: underline;
}

.timeline-description {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 700px;
}

.timeline-description p {
  margin: 0 0 0.6rem;
}

.timeline-description p:last-child {
  margin-bottom: 0;
}

.timeline-description ul {
  margin: 0.4rem 0 0.6rem 1.25rem;
  padding: 0;
}

.timeline-description li {
  margin-bottom: 0.35rem;
}

.timeline-description li:last-child {
  margin-bottom: 0;
}

.timeline-description strong {
  color: var(--text);
  font-weight: 600;
}

.payment-loading {
  margin-top: 1rem;
  max-width: 520px;
  width: 100%;
}

.payment-loading.payment-loading--hidden {
  display: none !important;
}

.payment-loading__track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.payment-loading__fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  display: block;
}

.payment-loading.payment-loading--active .payment-loading__fill {
  animation: payment-loading-fill 8.5s ease-out forwards;
}

@keyframes payment-loading-fill {
  from { width: 0%; }
  to { width: 100%; }
}

.panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  max-width: 100%;
  height: 100vh;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease;
}

.panel--closed {
  transform: translateX(100%);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.panel-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.field input,
.field textarea {
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
}

.field textarea {
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
}

.field input[type="color"] {
  height: 40px;
  padding: 2px;
  cursor: pointer;
}

.field--color .color-field-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field--color .color-field-row .btn {
  padding: 8px 12px;
}

.field--color .color-field-row .btn-icon {
  width: auto;
}

.hours-days-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.hours-days-row .field {
  flex: 1;
  min-width: 0;
}

.hours-days-row .field input {
  width: 100%;
  box-sizing: border-box;
}

.selected-count,
.total-cost {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
}

.total-cost {
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--text);
}

.credit-balance-wrap {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--text-muted);
}

.credit-balance-wrap.hidden {
  display: none;
}

.panel-divider {
  border: 0;
  border-top: 1px solid var(--border, #333);
  margin: 1rem 0;
}

.panel-cost-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
}

.panel-cost-section .hours-days-row {
  width: 100%;
  min-width: 0;
  flex-direction: row; /* override .field so Hours/Days sit side by side and share width */
}

.panel-cost-section .hours-days-row .field {
  flex: 1 1 0%;
  min-width: 0;
  overflow: hidden;
}

.panel-cost-section .hours-days-row .field input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.pay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 0.5rem;
}

.referral-section {
  margin: 0.75rem 0;
}

.referral-section.hidden {
  display: none;
}

.referral-section__hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0.5rem 0 0;
  line-height: 1.4;
}

.referral-link-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.referral-link-input {
  flex: 1;
  font-size: 13px;
  padding: 6px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
}

.account-credits-stat {
  margin: 0 0 0.5rem;
  font-size: 14px;
  color: var(--text-muted);
}

.account-credits-disclaimer {
  margin: 0 0 0.75rem;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.9;
}

.account-modal-separator {
  margin: 1rem 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.min-spend-meter {
  display: none;
}

.min-spend-meter.min-spend-meter--visible {
  display: block;
}

.min-spend-meter__label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.min-spend-meter__track {
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
}

.min-spend-meter__fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 5px;
  transition: width 0.2s ease;
}

.min-spend-meter__fill.min-spend-meter__fill--met {
  background: #00b894;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 50;
}

.overlay.hidden {
  display: none;
}

.overlay.overlay--passthrough {
  pointer-events: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  max-width: 90%;
  width: 360px;
}

.modal-content p {
  margin: 0 0 0.5rem;
  font-size: 14px;
  color: var(--text-muted);
}

.modal-link {
  display: block;
  margin-bottom: 1rem;
  font-size: 14px;
  color: var(--accent);
  word-break: break-all;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-actions .btn-primary {
  width: auto;
}

/* Avatar box in account modal */
#accountAvatarBox.avatar-box,
.avatar-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  border-width: 2px;
  border-style: dashed;
  border-color: var(--border, #333);
  border-radius: 8px;
  cursor: pointer;
  background: var(--bg, #111);
}
.avatar-box:hover {
  border-color: var(--accent);
  background: var(--bg-panel);
}
.avatar-box canvas {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  width: 64px;
  height: 64px;
  display: block;
}
.avatar-box-label {
  font-size: 12px;
  color: var(--text-muted);
}

/* Avatar editor modal */
.modal-content--avatar {
  width: auto;
  max-width: 95%;
}
.modal-content--avatar h3 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text, #e0e0e0);
}
#avatarEditorCanvas,
.modal-content--avatar #avatarEditorCanvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border-width: 1px;
  border-style: solid;
  border-color: var(--border, #333);
  border-radius: 4px;
  cursor: crosshair;
  margin: 0.5rem 0;
}
.avatar-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0.75rem 0;
}
.avatar-palette-color {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
}
.avatar-palette-color:hover {
  border-color: var(--text-muted);
}
.avatar-palette-color.active {
  border-color: var(--accent);
  outline: 1px solid var(--accent);
}
.avatar-palette-eraser {
  background: var(--bg-panel) repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 4px,
    var(--border) 4px,
    var(--border) 8px
  );
}

/* Pixel user avatar in click modal */
.pixel-user-avatar {
  image-rendering: -webkit-optimize-contrast;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  width: 64px;
  height: 64px;
  display: block;
  margin-bottom: 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.pixel-user-avatar.hidden {
  display: none;
}

.timeline-controls--disabled .btn-icon,
.timeline-controls--disabled #daySlider {
  opacity: 0.5;
  pointer-events: none;
}

/* Header account */
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  width: 100%;
}

.header-actions {
  display: flex;
  align-items: center;
  position: static;
  margin-left: auto;
}

.header-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  margin: 0;
  width: auto;
  max-width: calc(100% - 360px);
}

.header.header--logged-in .header-inner {
  justify-content: space-between;
}

.header.header--logged-in .header-actions {
  position: static;
  right: auto;
  top: auto;
  transform: none;
  margin-left: auto;
}

.header.header--logged-in .header-brand {
  align-items: flex-start;
  text-align: left;
  margin: 0;
  width: auto;
  max-width: calc(100% - 360px);
}

.auth-area.hidden,
.account-area.hidden {
  display: none;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
}

.account-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Hamburger menu: hidden on desktop */
.header-nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}

.header-nav-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
}

.header-nav-toggle__line {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}

.account-email {
  font-size: 12px;
  color: var(--text-muted);
  margin-right: 4px;
  display: none;
}

/* Attach account in Design Your Pixels panel (Link + Attach checkbox + Login grouped) */
.attach-account-section.account-link-group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.attach-account-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}

.attach-account-label input[type="checkbox"]:disabled {
  cursor: not-allowed;
  accent-color: #666;
}

.attach-account-label input[type="checkbox"]:disabled + span {
  color: var(--text-muted);
}

.attach-account-login {
  display: flex;
  gap: 8px;
  align-items: center;
}

.attach-account-login.hidden {
  display: none;
}

/* Overlay image in edit panel */
.overlay-image-section {
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.overlay-image-section.hidden {
  display: none;
}

.field-label {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

.field-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
  opacity: 0.9;
}

.overlay-image-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.overlay-controls {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.overlay-controls.hidden {
  display: none;
}

.overlay-controls .field input[type="range"] {
  width: 100%;
}

.overlay-controls-actions {
  display: flex;
  gap: 8px;
  margin-top: 0.5rem;
}

/* Modals */
.modal-content h3,
.modal-content h4 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.modal-content h4 {
  margin-top: 1.25rem;
  font-size: 1rem;
}

.modal-hint {
  font-size: 0.85rem !important;
  margin-bottom: 1rem !important;
}

.modal-content--wide {
  width: 480px;
  max-width: 95%;
}

/* Full-page scheduler */
.modal--schedule-fullpage {
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
}

.modal--schedule-fullpage .modal-content--schedule {
  width: 100%;
  max-width: 100%;
  height: 100vh;
  border-radius: 0;
  border: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.schedule-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.schedule-page-header h3 {
  margin: 0;
  font-size: 1.25rem;
}

.schedule-page-layout {
  display: grid;
  grid-template-columns: minmax(280px, 40%) 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.schedule-import-column {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 1.25rem;
}

.schedule-import-section h4,
.schedule-frame-strip-section h4 {
  font-size: 0.95rem;
  margin: 0 0 0.5rem;
  color: var(--text);
}

.schedule-import-section,
.schedule-frame-strip-section {
  margin-bottom: 1.25rem;
}

.schedule-import-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0.75rem;
}

.schedule-import-tab {
  padding: 0.5rem 1rem;
  font-size: 13px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 0;
}

.schedule-import-tab:first-child {
  border-radius: 6px 0 0 6px;
}

.schedule-import-tab:last-child {
  border-radius: 0 6px 6px 0;
  border-left-width: 0;
}

.schedule-import-tab--active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.schedule-import-panel {
  margin-bottom: 0.75rem;
}

.schedule-import-panel--hidden {
  display: none;
}

.schedule-import-panel .field-hint,
.schedule-frame-strip-section .field-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

.schedule-import-panel .btn + .btn,
.schedule-import-panel .schedule-import-count {
  margin-left: 0.5rem;
}

.schedule-import-count {
  font-size: 13px;
  color: var(--text-muted);
}

.schedule-atlas-params {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
  margin: 0.75rem 0;
}

.schedule-atlas-params .field span {
  display: block;
  font-size: 12px;
  margin-bottom: 0.25rem;
}

.schedule-atlas-preview-wrap {
  margin: 0.75rem 0;
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #0d0d0d;
}

.schedule-atlas-preview {
  display: block;
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.schedule-frame-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0.5rem 0;
  min-height: 60px;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.schedule-frame-strip-item {
  flex-shrink: 0;
  width: 48px;
  position: relative;
  border: 2px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg);
}

.schedule-frame-strip-item:hover {
  border-color: var(--accent);
}

.schedule-frame-strip-item canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.schedule-frame-strip-item .schedule-frame-num {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  font-size: 10px;
  text-align: center;
  background: rgba(0, 0, 0, 0.75);
  color: var(--text);
  padding: 2px 0;
}

.schedule-slots-column {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 1.5rem;
}

.schedule-slots-column .modal-hint {
  margin: 0 0 0.75rem;
}

.auth-error {
  color: #ff6b6b;
  font-size: 13px;
  margin-top: 0.5rem;
}

.auth-error.hidden {
  display: none;
}

/* Gallery */
.gallery-grid,
.gallery-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 10px;
  margin: 1rem 0;
}

.gallery-thumb-item {
  position: relative;
  cursor: pointer;
  border: 2px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  aspect-ratio: 1;
}

.gallery-thumb-item:hover {
  border-color: var(--accent);
}

.gallery-thumb-item canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.gallery-grid-item {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  aspect-ratio: 1;
}

.gallery-grid-item canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.gallery-grid-item-actions {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  gap: 4px;
  justify-content: center;
}

.gallery-grid-item-actions .btn {
  padding: 4px 8px;
  font-size: 12px;
}

.gallery-collection-section {
  margin: 1rem 0;
}
.gallery-collection-title {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}
.gallery-drop-zone {
  min-height: 80px;
  transition: background 0.15s, border-color 0.15s;
  padding: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 8px;
}
.gallery-drop-zone.gallery-drop-zone--active {
  background: rgba(108, 92, 231, 0.12);
  border-color: rgba(108, 92, 231, 0.55);
}
.gallery-drop-zone-placeholder {
  grid-column: 1 / -1;
  padding: 1.5rem;
  text-align: center;
  font-size: 13px;
  font-style: italic;
  color: var(--text-muted);
  background: rgba(108, 92, 231, 0.08);
  border: 2px dashed rgba(108, 92, 231, 0.4);
  border-radius: 8px;
  pointer-events: none;
}
.gallery-grid-item[draggable="true"] {
  cursor: grab;
}
.gallery-grid-item:active[draggable="true"] {
  cursor: grabbing;
}
.gallery-grid-item.gallery-item-dragging {
  opacity: 0.6;
}

#pixelUserGalleryCanvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin: 0.5rem 0;
  display: block;
}

.pixel-user-profile {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.pixel-user-profile-name {
  font-weight: 600;
  font-size: 1rem;
  margin: 0 0 0.25rem;
  color: var(--text);
}
.pixel-user-profile-description {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0.25rem 0;
  line-height: 1.4;
}
.pixel-user-profile-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.pixel-user-likes {
  font-size: 13px;
  color: var(--text-muted);
}
.account-likes-stat {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.schedule-slots {
  margin: 0.5rem 0;
  max-height: 50vh;
  overflow-y: auto;
  padding-right: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.schedule-slot-row {
  display: grid;
  grid-template-columns: auto 120px 1fr;
  gap: 0.75rem;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem;
  background: #151515;
}

.schedule-slot-title {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
  align-self: flex-start;
  min-width: 60px;
}

.schedule-slot-preview {
  width: 120px;
  height: 120px;
  border: 1px solid var(--border);
  border-radius: 6px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.schedule-slot-controls {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.schedule-slot-position-row {
  display: flex !important;
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  gap: 0.5rem;
  align-items: stretch;
  width: 100%;
}

.schedule-slot-position-row .schedule-slot-axis-field,
.schedule-slot-position-row .field {
  min-width: 0;
  width: 100%;
  flex: 0 0 auto;
}

.schedule-slot-axis-field {
  min-width: 0;
  width: 100%;
}

.schedule-slot-axis-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
}

.schedule-slot-axis-row input[type="range"] {
  flex: 1 1 0;
  min-width: 0;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
}

.schedule-slot-x-value,
.schedule-slot-y-value {
  font-size: 14px;
  color: var(--text-muted);
  min-width: 40px;
  text-align: right;
}

.schedule-slot-scale-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
}

.schedule-slot-scale-row input[type="range"] {
  flex: 1 1 0;
  min-width: 0;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
}

.schedule-slot-scale-value {
  font-size: 14px;
  color: var(--text-muted);
  min-width: 40px;
  text-align: right;
}

/* --- Mobile-first / responsive base --- */
.canvas-wrap {
  max-width: min(700px, 100%);
  width: 100%;
}

.timeline {
  max-width: min(600px, 100%);
  width: 100%;
}

.timeline-controls {
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 768px) {
  .header {
    padding: 1rem;
    position: relative;
    z-index: 120;
  }

  .header-actions {
    position: relative;
    z-index: 120;
  }

  .header-nav-toggle {
    display: none;
  }

  .header.header--logged-in .header-nav-toggle {
    display: flex;
  }

  .account-area.account-nav {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    flex-direction: column;
    min-width: 180px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    padding: 0.5rem;
    gap: 0;
    z-index: 200;
  }

  .header--nav-open .account-area.account-nav {
    display: flex;
  }

  .account-area.account-nav .btn,
  .account-area.account-nav .btn-ghost {
    justify-content: flex-start;
    width: 100%;
    min-height: 44px;
    border-radius: 6px;
  }

  .account-area.account-nav .account-email {
    display: block;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
  }

  .main {
    padding: 1rem;
    gap: 1rem;
  }

  .timeline-controls {
    gap: 6px;
  }

  .btn-icon {
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
  }

  .day-label {
    min-width: 3rem;
    font-size: 13px;
  }

  .panel {
    position: static;
    width: 100%;
    height: auto;
    max-height: none;
    border-radius: 0;
    border-left: none;
    border-top: 1px solid var(--border);
    box-shadow: none;
    transform: none;
    transition: none;
  }

  .panel.panel--closed {
    display: none;
    transform: none;
  }

  .panel .panel-body {
    overscroll-behavior: contain;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
  }

  .modal-content {
    max-width: calc(100% - 2rem);
    margin: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
  }

  .modal-content--wide {
    width: calc(100% - 2rem);
    max-width: none;
  }

  .modal-content--avatar {
    max-width: calc(100% - 2rem);
  }

  .timeline-description-toggle {
    display: block;
    min-height: 44px;
  }

  .timeline-description-wrap:not(.timeline-description-wrap--open) .timeline-description {
    display: none;
  }

  .timeline-description-wrap.timeline-description-wrap--open .timeline-description {
    display: block;
    margin-top: 0.5rem;
  }

  /* Scheduler: 2 rows on tablet/mobile instead of 2 columns */
  .schedule-page-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    overflow: hidden;
  }

  .schedule-import-column {
    border-right: none;
    border-bottom: 1px solid var(--border);
    min-height: 0;
  }

  .schedule-slots-column {
    min-height: 0;
  }
}

@media (max-width: 480px) {
  .header {
    padding: 0.75rem 1rem;
  }

  .header h1 {
    font-size: 1.35rem;
  }

  .tagline {
    font-size: 0.85rem;
  }

  .header-inner {
    justify-content: center;
    flex-direction: column;
    gap: 0.75rem;
  }

  .header-actions {
    position: relative;
    transform: none;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
  }

  .header-brand {
    align-items: center;
    text-align: center;
    max-width: 100%;
    width: 100%;
  }

  .account-area {
    flex-wrap: wrap;
    justify-content: center;
  }

  .account-area .btn,
  .account-area .btn-ghost {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 13px;
  }

  .main {
    padding: 0.5rem 0.75rem;
  }

  .canvas-wrap {
    border-radius: 4px;
    margin-left: -0.25rem;
    margin-right: -0.25rem;
    max-width: calc(100% + 0.5rem);
  }

  .timeline-controls {
    justify-content: center;
  }

  #daySlider {
    min-width: 80px;
    flex: 1 1 100%;
    order: 10;
    width: 100%;
  }

  .timeline-description {
    font-size: 0.85rem;
    padding: 0 0.25rem;
  }

  .panel-header,
  .panel-body {
    padding: 1rem;
  }

  .field input,
  .field textarea {
    font-size: 16px; /* avoids zoom on focus in iOS */
  }

  .btn-primary {
    min-height: 48px;
    padding: 14px;
  }

  .schedule-slot-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .schedule-slot-preview {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
  }

  .schedule-slot-position-row {
    flex-direction: column !important;
  }

  .modal .modal-content {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
    border: none;
  }

  .modal-content--wide {
    width: 100%;
    margin: 0;
    max-height: 100vh;
    border-radius: 0;
  }

  .modal-content--avatar {
    max-width: 100%;
  }

  #scheduleModal .modal-content--schedule {
    width: 100%;
  }

  .modal-actions {
    flex-wrap: wrap;
  }

  .modal-actions .btn {
    min-height: 44px;
    flex: 1 1 auto;
  }

  .gallery-grid,
  .gallery-thumbs {
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 8px;
  }
}

/* Prevent horizontal overflow on small viewports */
@media (max-width: 700px) {
  body {
    overflow-x: hidden;
  }
}

.btn-sm {
  font-size: 0.875rem;
  padding: 0.25rem 0.5rem;
}

.schedule-list {
  margin: 0.5rem 0 1rem;
  padding: 0;
  list-style: none;
}

.schedule-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.schedule-list li:last-child {
  border-bottom: none;
}

.hidden {
  display: none !important;
}

input[type="file"]::file-selector-button {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  margin-right: 8px;
}

input[type="file"]::file-selector-button:hover {
  background: #252525;
}
