:root {
  --bg: #fff;
  --panel: #fff;
  --panel-strong: #fff;
  --ink: #000;
  --muted: #666;
  --line: #000;
  --accent: #000;
  --accent-soft: #f5f5f5;
  --shadow: none;
  --dot: rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.35rem;
  background: #fff;
  border-right: 2px solid var(--line);
  text-align: center;
}

.sidebar-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.eyebrow,
.frame-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #000;
}

h1,
h2 {
  margin: 0;
  font-family: 'Inter', sans-serif;
  line-height: 1;
  font-weight: 600;
}

h1 {
  font-size: clamp(2rem, 3vw, 2.8rem);
}

.brand-title {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  letter-spacing: -0.5px;
  text-align: center;
  text-transform: uppercase;
}

h2 {
  font-size: clamp(1.8rem, 2vw, 2.3rem);
}

.sidebar-copy,
.workspace-copy,
.sidebar-panel li,
.empty-state,
figcaption {
  color: var(--muted);
}

.sidebar-panel {
  padding: 0.9rem 1rem;
  border: 2px solid var(--line);
  border-radius: 0;
  background: #fff;
}

.sidebar-panel h2 {
  margin-bottom: 0.75rem;
  font-size: 1.15rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.panel-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.6rem;
  border-radius: 0;
  background: #000;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
}

.project-list,
.user-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.project-item,
.user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.75rem 0.85rem;
  border: 2px solid var(--line);
  border-radius: 0;
  background: #fff;
}

.project-item.active {
  border-color: #000;
  background: #000;
  color: #fff;
}

.project-switch {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: center;
  cursor: pointer;
  color: inherit;
}

.project-switch strong,
.user-item span {
  display: block;
  color: var(--ink);
}

.project-item.active .project-switch strong {
  color: #fff;
}

.project-item.active .project-meta {
  color: rgba(255, 255, 255, 0.7);
}

.project-meta,
.empty-sidebar-state,
.active-project-name {
  font-size: 0.88rem;
  color: var(--muted);
}

.active-project-name {
  margin-bottom: 0.65rem;
}

.sidebar-form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.8rem;
}

.sidebar-input {
  width: 100%;
  padding: 0.8rem 0.95rem;
  border: 2px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  outline: none;
  font-family: 'Inter', sans-serif;
}

.sidebar-input:focus {
  border-color: #000;
  box-shadow: 0 0 0 1px #000;
}

.mini-action {
  padding: 0.25rem 0.45rem;
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}

.mini-action:disabled {
  opacity: 0.35;
  cursor: default;
}

.sidebar-panel ul {
  margin: 0;
  padding-left: 0;
  list-style-position: inside;
}

.sidebar-panel li + li {
  margin-top: 0.45rem;
}

.ghost-button,
.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: 0;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
}

.ghost-button {
  width: 100%;
  padding: 0.85rem 1rem;
}

.ghost-button:hover,
.upload-button:hover {
  background-color: #f5f5f5;
}

.workspace-wrap {
  padding: 1rem;
}

.workspace-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.workspace-tools {
  display: flex;
  align-items: end;
  gap: 1rem;
}

.workspace-copy {
  max-width: 34rem;
  margin: 0;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.zoom-button,
.zoom-reset {
  width: auto;
  padding: 0.65rem 0.85rem;
}

.zoom-button {
  min-width: 2.7rem;
}

.zoom-label {
  min-width: 3.5rem;
  text-align: center;
  font-size: 0.92rem;
  color: var(--muted);
}

.status-message {
  margin: 0.8rem 0 0;
  padding: 0.8rem 1rem;
  border: 2px solid #000;
  border-radius: 0;
  background: #f5f5f5;
  color: #000;
}

.workspace {
  position: relative;
  min-height: calc(100vh - 5rem);
  overflow: auto;
  border: 2px solid var(--line);
  border-radius: 0;
  background:
    radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 22px 22px;
}

.workspace-canvas {
  position: relative;
  transform-origin: top left;
}

.frame {
  position: absolute;
  width: 300px;
  min-height: 260px;
  padding: 1rem;
  border: 2px solid #000;
  border-radius: 0;
  background: #fff;
}

.frame.dragging {
  opacity: 0.9;
  cursor: grabbing;
}

.frame.resizing {
  user-select: none;
}

.frame-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
  cursor: grab;
}

.frame-title {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  font-family: 'Inter', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
  outline: none;
}

.frame-title:focus {
  box-shadow: inset 0 -2px 0 #000;
}

.upload-button {
  position: relative;
  flex-shrink: 0;
  padding: 0.7rem 0.9rem;
  font-size: 0.9rem;
  overflow: hidden;
}

.upload-button input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

.frame-dropzone {
  min-height: 170px;
  height: calc(100% - 4.7rem);
  padding: 0.7rem;
  border: 2px dashed #ddd;
  border-radius: 0;
  background: #fafafa;
  transition: border-color 160ms ease, background 160ms ease;
}

.frame-dropzone.drag-over {
  border-color: #000;
  background: #f5f5f5;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.7rem;
}

.image-card {
  position: relative;
  margin: 0;
  border-radius: 0;
  overflow: hidden;
  background: #fff;
  border: 2px solid #000;
  cursor: grab;
}

.delete-card {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  padding: 0;
  border: 2px solid #000;
  border-radius: 0;
  background: #fff;
  color: #000;
  font-size: 0.82rem;
  line-height: 1;
  cursor: pointer;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, background 160ms ease;
  font-weight: 600;
}

.image-card:hover .delete-card,
.image-card:focus-within .delete-card {
  opacity: 1;
  pointer-events: auto;
}

.delete-card:hover {
  background: #000;
  color: #fff;
}

.image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.resize-handle {
  position: absolute;
  width: 0.8rem;
  height: 0.8rem;
  border: 0;
  background: #000;
  opacity: 0;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 2;
  appearance: none;
}

.frame:hover .resize-handle,
.frame:focus-within .resize-handle,
.frame.resizing .resize-handle {
  opacity: 1;
}

.resize-handle:hover {
  transform: scale(1.08);
}

.resize-nw {
  top: -0.15rem;
  left: -0.15rem;
  cursor: nwse-resize;
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

.resize-ne {
  top: -0.15rem;
  right: -0.15rem;
  cursor: nesw-resize;
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}

.resize-sw {
  bottom: -0.15rem;
  left: -0.15rem;
  cursor: nesw-resize;
  clip-path: polygon(0 0, 0 100%, 100% 100%);
}

.resize-se {
  right: -0.15rem;
  bottom: -0.15rem;
  cursor: nwse-resize;
  clip-path: polygon(100% 0, 0 100%, 100% 100%);
}

.empty-state {
  margin: 0;
  text-align: center;
  padding: 2.4rem 1rem;
  font-size: 0.95rem;
}

.hidden {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .workspace-tools {
    width: 100%;
    flex-direction: column;
    align-items: start;
  }

  .workspace {
    min-height: 70vh;
  }
}

@media (max-width: 720px) {
  .workspace-wrap,
  .sidebar {
    padding: 1rem;
  }

  .frame {
    width: min(88vw, 300px);
  }
}
