:root {
  --bg: #0f1115;
  --card: #1a1d24;
  --accent: #4f8cff;
  --accent-dark: #3a6fd6;
  --text: #eef0f4;
  --muted: #9aa1ac;
  --danger: #e5484d;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

.page-header {
  text-align: center;
  margin-bottom: 16px;
}

.page-header h1 {
  font-size: 1.6rem;
  margin: 0 0 4px;
}

.subtitle {
  color: var(--accent);
  font-size: 0.85rem;
  margin: 0;
}

.upload-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.name-input {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #333844;
  background: #11141a;
  color: var(--text);
  font-size: 1rem;
}

.btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border-radius: 8px;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  text-align: center;
}

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:active { background: var(--accent-dark); }

.btn-secondary {
  background: #2a2f3a;
  color: var(--text);
}

.file-label { width: 100%; }

.error {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 0;
}

.wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.tile {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tile img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: #222;
}

.tile-footer {
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.tile-name {
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.btn-icon {
  background: #2a2f3a;
  border: none;
  color: var(--text);
  border-radius: 6px;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  cursor: pointer;
}

.btn-icon.small {
  width: 30px;
  height: 30px;
  font-size: 0.9rem;
}

.btn-icon.danger {
  color: var(--danger);
}

.crop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.crop-panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.crop-canvas {
  width: 100%;
  max-width: 340px;
  aspect-ratio: 1 / 1;
  align-self: center;
  border-radius: 8px;
  touch-action: none;
  background: #000;
  cursor: grab;
}

.crop-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.crop-controls input[type="range"] {
  flex: 1;
}

.crop-error {
  color: var(--danger);
  margin: 0;
}

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

@media (min-width: 640px) {
  .wall {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}
