* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #fafafa;
  color: #09090b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}

/* ── Header ── */
.home-header {
  background: #ffffff;
  border-bottom: 1px solid #e4e4e7;
  padding: 0 32px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.home-header-inner {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex: 1;
}

.home-user-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #18181b;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.home-user-btn:hover {
  background: #3f3f46;
  color: #ffffff;
}
.home-user-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.home-user-btn .user-initial {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1;
  user-select: none;
}

/* User menu dropdown */
.user-menu-wrap {
  position: relative;
  flex-shrink: 0;
}

.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #ffffff;
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
  min-width: 148px;
  padding: 4px;
  z-index: 100;
}
.user-dropdown.open { display: block; }

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: #09090b;
  text-decoration: none;
  border-radius: 6px;
  transition: background 0.1s;
}
.user-dropdown-item svg {
  flex-shrink: 0;
  color: #71717a;
}
.user-dropdown-item:hover { background: #f4f4f5; }

.header-login-btn {
  font-size: 12px;
  color: #71717a;
  text-decoration: none;
  border: 1px solid #d4d4d8;
  padding: 4px 12px;
  border-radius: 6px;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}
.header-login-btn:hover { border-color: #09090b; color: #09090b; }

/* ── Guest view (not logged in) ── */
.guest-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px;
  gap: 20px;
}
.guest-view-title {
  font-size: 22px;
  font-weight: 700;
  color: #09090b;
  letter-spacing: -0.03em;
}
.guest-view-desc {
  font-size: 14px;
  color: #71717a;
  line-height: 1.7;
  max-width: 320px;
}
.guest-view-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: 10px;
  background: #09090b;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
  margin-top: 4px;
}
.guest-view-btn:hover { background: #27272a; }

.guest-preview-canvas {
  width: 100%;
  height: 480px;
  border-radius: 12px;
  display: block;
  background: #0d0d1a;
}

.home-logo-name {
  font-size: 16px;
  font-weight: 700;
  color: #09090b;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.home-logo-tag {
  font-size: 12px;
  color: #a1a1aa;
}

/* ── Main ── */
.home-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 32px 80px;
}

.home-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #71717a;
  margin-bottom: 16px;
}

.gallery-controls-title {
  font-size: 20px;
  font-weight: 700;
  color: #09090b;
  letter-spacing: -0.02em;
}

.gallery-desc {
  font-size: 13px;
  color: #71717a;
  padding-bottom: 16px;
  padding-top: 4px;
}

/* ── Project grid ── */
.project-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* Show-all button */
.show-all-btn {
  display: block;
  margin: 16px auto 0;
  padding: 0;
  font-size: 13px;
  font-weight: 500;
  color: #a1a1aa;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s;
}
.show-all-btn:hover {
  color: #09090b;
}

/* New project card */
.project-card-new {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1.5px dashed #d4d4d8;
  border-radius: 10px;
  padding: 32px 16px;
  cursor: pointer;
  text-decoration: none;
  color: #71717a;
  background: #ffffff;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  min-height: 120px;
}
.project-card-new:hover {
  border-color: #18181b;
  color: #09090b;
  background: #fafafa;
}
.project-card-new-icon {
  width: 32px;
  height: 32px;
  border: 1.5px solid currentColor;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
}
.project-card-new-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}
.project-card-new-label {
  font-size: 13px;
  font-weight: 500;
}

/* Existing project card */
.project-card {
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  background: #ffffff;
  padding: 0;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.project-card:hover {
  border-color: #a1a1aa;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* Thumbnail area (16:9) */
.project-card-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #f4f4f5;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.project-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.project-card-thumb-empty {
  color: #d4d4d8;
}
.project-card-thumb-empty svg {
  width: 28px;
  height: 28px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Card body (name + date) */
.project-card-body {
  padding: 10px 12px 11px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.project-card-name {
  font-size: 13px;
  font-weight: 600;
  color: #09090b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 22px;
}

.project-card-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}
.project-card-name-row .project-card-name {
  padding-right: 0;
}
.project-card-badges {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
  margin-left: auto;
}
.project-card-badge {
  font-size: 10px;
  font-weight: 600;
  color: #71717a;
  background: #f4f4f5;
  border-radius: 4px;
  padding: 1px 5px;
  line-height: 1.6;
  white-space: nowrap;
}
.badge-pub {
  color: #3b82f6;
  background: #eff6ff;
}
.badge-fork {
  color: #71717a;
  background: #f4f4f5;
}

.project-card-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.project-card-date {
  font-size: 11px;
  color: #a1a1aa;
}

.project-card-del {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 24px;
  height: 24px;
  border: none;
  background: rgba(255,255,255,0.82);
  cursor: pointer;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a1a1aa;
  opacity: 0;
  transition: opacity 0.15s, color 0.1s, background 0.1s;
  flex-shrink: 0;
  backdrop-filter: blur(4px);
}
.project-card:hover .project-card-del {
  opacity: 1;
}
.project-card-del:hover {
  color: #ef4444;
  background: rgba(255,255,255,0.95);
}
.project-card-del svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Loading / empty states */
.home-state {
  grid-column: 1 / -1;
  padding: 40px 0;
  text-align: center;
  font-size: 13px;
  color: #a1a1aa;
}

/* ── Back link (shared across user/upgrade pages) ── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #71717a;
  text-decoration: none;
  margin-bottom: 20px;
  transition: color 0.1s;
}
.back-link:hover { color: #09090b; }
.back-link svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Modal (shared) ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: #ffffff;
  border: 1px solid #e4e4e7;
  border-radius: 14px;
  padding: 24px;
  max-width: 360px;
  width: calc(100% - 32px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

.modal-box-title {
  font-size: 15px;
  font-weight: 700;
  color: #09090b;
  margin-bottom: 6px;
}

.modal-box-desc {
  font-size: 13px;
  color: #71717a;
  line-height: 1.5;
  margin-bottom: 16px;
}

.modal-box-input {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  outline: none;
  margin-bottom: 16px;
  box-sizing: border-box;
  font-family: inherit;
  transition: border-color 0.15s;
}
.modal-box-input:focus { border-color: #a1a1aa; }

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

.modal-btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid #e4e4e7;
  background: #ffffff;
  color: #09090b;
  transition: background 0.15s;
}
.modal-btn:hover { background: #f4f4f5; }

.modal-btn-primary {
  background: #09090b;
  color: #ffffff;
  border-color: #09090b;
}
.modal-btn-primary:hover { background: #27272a; }
.modal-btn-primary:disabled { background: #a1a1aa; border-color: #a1a1aa; cursor: not-allowed; }

.modal-btn-danger {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
}
.modal-btn-danger:hover { background: #dc2626; }

/* ── Published objects list ── */
.published-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid #e4e4e7;
  border-radius: 10px;
  background: #ffffff;
  overflow: hidden;
}
.published-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid #f4f4f5;
  transition: background 0.1s;
}
.published-item:last-child { border-bottom: none; }
.published-item:hover { background: #fafafa; }
.published-item-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: #09090b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.published-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.published-item-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: #a1a1aa;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.1s, color 0.1s;
  text-decoration: none;
}
.published-item-btn:hover { background: #f4f4f5; color: #18181b; }
.published-item-btn.del:hover { background: #fee2e2; color: #ef4444; }
.published-item-btn svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.published-empty {
  padding: 32px 0;
  text-align: center;
  font-size: 13px;
  color: #a1a1aa;
}

/* ── Footer ── */
.home-footer {
  text-align: center;
  padding: 24px 0 32px;
  font-size: 11px;
  color: #d4d4d8;
}

.app-version-link {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s;
}
.app-version-link:hover {
  color: #a1a1aa;
  text-decoration: underline;
}

/* ── Project card meta (author + fork count) ── */
.project-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.project-card-author {
  font-size: 11px;
  color: #a1a1aa;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.project-card-fork-count {
  font-size: 10px;
  color: #a1a1aa;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 3px;
}
.project-card-fork-count svg {
  width: 10px;
  height: 10px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.project-card-like-count {
  font-size: 10px;
  color: #a1a1aa;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 3px;
}
.project-card-like-count svg {
  width: 10px;
  height: 10px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .home-main { padding: 24px 16px 60px; }
  .home-header { padding: 0 16px; }
}
