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

:root {
  --bg:        #0f0f0f;
  --surface:   #1a1a1a;
  --border:    #2a2a2a;
  --text:      #e8e8e8;
  --text-dim:  #777;
  --accent:    #e0e0e0;
  --danger:    #c0392b;
  --radius:    6px;
  --gap:       12px;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: system-ui, sans-serif; font-size: 14px; }

[v-cloak] { display: none; }

/* ── Setup ──────────────────────────────────────────────────────────────── */

.setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 16px;
  padding: 24px;
}

.setup h1 { font-size: 2rem; letter-spacing: -0.04em; }
.setup p  { color: var(--text-dim); }

.setup-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 380px;
}

.setup-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.setup-form input {
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
}

.setup-form button {
  padding: 10px;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.setup-form button:disabled { opacity: 0.4; cursor: default; }

/* ── Main layout ─────────────────────────────────────────────────────────── */

.main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.header h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.03em; }

.header-right { display: flex; align-items: center; gap: 10px; }

.status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: lowercase;
  letter-spacing: 0.03em;
}
.status.live        { background: #1a3a1a; color: #5aaa5a; }
.status.connecting  { background: #2a2a1a; color: #aaa05a; }
.status.disconnected{ background: #2a1a1a; color: #aa5a5a; }

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  width: 32px; height: 32px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn.small { font-size: 14px; }
.icon-btn:hover { background: var(--border); }

/* ── Dropzone ─────────────────────────────────────────────────────────────── */

.dropzone {
  margin: 16px 20px 0;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.15s, max-height 0.2s, padding 0.2s;
  overflow: hidden;
  max-height: 0;
  padding: 0 20px;
}

.dropzone.is-open {
  max-height: 200px;
  padding: 20px;
}

.dropzone.drag-over {
  border-color: var(--text);
  background: rgba(255,255,255,0.03);
  max-height: 200px;
  padding: 20px;
}

.dropzone-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  min-height: 60px;
  font-size: 13px;
}

.upload-progress { display: flex; flex-direction: column; gap: 6px; }

.upload-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px 10px;
  background: var(--surface);
  border-radius: 4px;
}

.upload-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; font-size: 13px; }

.upload-state { font-size: 11px; flex-shrink: 0; }
.upload-state.uploading { color: #aaa05a; }
.upload-state.done      { color: #5aaa5a; }
.upload-state.error     { color: #aa5a5a; }

.upload-bar-track {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.upload-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.1s linear;
  background: #aaa05a;
}
.upload-bar-fill.done  { background: #5aaa5a; }
.upload-bar-fill.error { background: #aa5a5a; }

/* ── Gallery ─────────────────────────────────────────────────────────────── */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--gap);
  padding: 16px 20px 40px;
}

.gallery-item {
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  background: var(--surface);
}

.gallery--original .gallery-item {
  aspect-ratio: unset;
}

.gallery--original .gallery-item img {
  height: auto;
  object-fit: unset;
}

.gallery-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.15s;
}

.gallery-item:hover img { opacity: 0.85; }

.gallery-item-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 8px;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

.gallery-item:hover .gallery-item-overlay { opacity: 1; }

.overlay-name {
  font-size: 11px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 80px 20px;
}

/* ── Lightbox ─────────────────────────────────────────────────────────────── */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 100;
  overflow-y: auto;
  padding: 20px;
}

.lightbox-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-width: 860px;
  width: 100%;
  overflow: hidden;
  position: relative;
  margin: auto;
}

.close-btn {
  position: absolute;
  top: 12px; right: 12px;
  background: rgba(0,0,0,0.5);
  border: none;
  color: #fff;
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  z-index: 1;
}

.lightbox-img {
  display: block;
  width: 100%;
  max-height: 55vh;
  object-fit: contain;
  background: #000;
}

.detail-meta {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.detail-label {
  width: 90px;
  flex-shrink: 0;
  color: var(--text-dim);
  font-size: 12px;
  padding-top: 2px;
}

.detail-value { color: var(--text); }

.tag-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  flex: 1;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--border);
  padding: 2px 8px 2px 10px;
  border-radius: 20px;
  font-size: 12px;
}

.tag button {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}
.tag button:hover { color: var(--text); }

.tag-input {
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  padding: 2px 4px;
  width: 100px;
  outline: none;
}
.tag-input:focus { border-color: var(--text-dim); }

.url-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.url-text {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.btn-copy {
  flex-shrink: 0;
  padding: 3px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-copy:hover { background: var(--border); }

.detail-description {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
  padding: 8px 10px;
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
  outline: none;
  width: 100%;
}
.detail-description:focus { border-color: var(--text-dim); }

.detail-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 4px;
}

.btn-secondary {
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn-secondary:hover { background: var(--border); }

.btn-danger {
  padding: 7px 14px;
  background: transparent;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 13px;
  cursor: pointer;
}
.btn-danger:hover { background: var(--danger); color: #fff; }

/* ── Full-window drop overlay ────────────────────────────────────────────── */

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.drop-overlay span {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  border: 2px dashed var(--text);
  padding: 40px 64px;
  border-radius: 16px;
  letter-spacing: -0.02em;
}

/* ── Paste undo toasts ───────────────────────────────────────────────────── */

.toast-stack {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  pointer-events: all;
  animation: toast-in 0.15s ease;
  white-space: nowrap;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.toast-name {
  font-size: 13px;
  color: var(--text-dim);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast-undo {
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.toast-dismiss {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
}
.toast-dismiss:hover { color: var(--text); }

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .gallery { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .lightbox-img { max-height: 40vh; }
  .detail-row { flex-direction: column; gap: 4px; }
  .detail-label { width: auto; }
}
