@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,300;0,400;0,500;0,700;1,300;1,400&display=swap');

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0a;
  --surface: #111;
  --surface2: #181818;
  --surface3: #1f1f1f;
  --text: #ccc;
  --text2: #666;
  --accent: #8888ff;
  --accent2: #6666cc;
  --border: #1a1a1a;
  --radius-sm: 2px;
  --header-h: 52px;
}

html, body {
  height: 100%;
  font-family: 'JetBrains Mono', 'SF Mono', Monaco, monospace;
  font-size: 13px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #121212; }
::-webkit-scrollbar-thumb { background: #A9D1F6; }
::-webkit-scrollbar-thumb:hover { background: #b8ddfa; }
* { scrollbar-width: thin; scrollbar-color: #A9D1F6 #121212; }

a { color: var(--accent); text-decoration: none; }
a:active { opacity: 0.7; }
button { cursor: pointer; font: inherit; border: none; background: none; color: inherit; }
input, textarea { font: inherit; color: inherit; }

/* ===== Layout ===== */
#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 960px;
  margin: 0 auto;
  position: relative;
}

/* ===== Top bar ===== */
#topbar {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 6px;
  flex-shrink: 0;
  z-index: 10;
}

#topbar h1 {
  flex: 1;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  user-select: none;
  color: #eee;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  border-radius: var(--radius-sm);
  transition: background 0.12s;
  color: var(--text2);
}
.icon-btn:active { background: var(--surface3); color: var(--text); }

/* ===== Search bar ===== */
.search-bar {
  padding: 8px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-bar input {
  width: 100%;
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 12px;
  outline: none;
  transition: border 0.12s;
}
.search-bar input:focus { border-color: var(--accent); }
.search-bar input::placeholder { color: var(--text2); }

.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.tag-chip {
  display: inline-block;
  padding: 3px 6px;
  background: transparent;
  border: none;
  font-size: 11px;
  color: #A9D1F6;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
  opacity: 0.7;
}
.tag-chip.active {
  opacity: 1;
  font-weight: 700;
}
.tag-chip:active { opacity: 0.7; }

/* ===== Content area ===== */
#content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px;
}

/* ===== Artist Grid ===== */
.artist-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
@media (min-width: 600px) {
  .artist-grid { grid-template-columns: 1fr 1fr 1fr; }
}

.artist-card {
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
  transition: opacity 0.12s;
  border: 1px solid var(--border);
}
.artist-card:active { opacity: 0.7; }

.artist-card-thumb {
  width: 100%;
  aspect-ratio: 3/4;
  background: var(--surface2);
  object-fit: cover;
  display: block;
}

.artist-card-thumb-placeholder {
  width: 100%;
  aspect-ratio: 3/4;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  color: var(--text2);
  font-size: 28px;
}

.artist-card-info {
  padding: 8px 10px;
}

.artist-card-name {
  font-weight: 500;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.artist-card-tags {
  font-size: 10px;
  color: var(--text2);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Artist Detail ===== */
.artist-detail-header {
  padding: 12px 0;
}

.artist-detail-name { font-size: 24px; font-weight: 500; }

.artist-detail-website {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--accent);
}

.artist-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.artist-detail-tags .tag-chip { cursor: default; }

/* ===== Works Grid ===== */
.works-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
@media (min-width: 600px) {
  .works-grid { grid-template-columns: 1fr 1fr 1fr; }
}

.work-item {
  cursor: pointer;
  overflow: hidden;
  background: var(--surface2);
  aspect-ratio: 3/4;
  position: relative;
}

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

/* ===== Similar ===== */
.similar-section {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.similar-section h3 {
  font-size: 12px;
  font-weight: 400;
  margin-bottom: 8px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.similar-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.similar-chip {
  display: inline-block;
  padding: 6px 10px;
  background: var(--surface2);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.12s;
  border: 1px solid var(--border);
}
.similar-chip:active { background: var(--surface3); }

/* ===== Form ===== */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--text2);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 13px;
  outline: none;
  transition: border 0.12s;
}
.form-group input:focus,
.form-group textarea:focus { border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 60px; }

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.btn {
  flex: 1;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 400;
  text-align: center;
  letter-spacing: 0.5px;
  transition: opacity 0.12s;
  text-transform: uppercase;
}
.btn:active { opacity: 0.6; }
.btn-primary { background: #A9D1F6; color: #111; }
.btn-danger { background: #993333; color: #fff; }
.btn-secondary { background: var(--surface2); border: 1px solid var(--border); }

/* ===== Upload zone ===== */
.upload-zone {
  border: 1px dashed var(--border);
  padding: 24px 16px;
  text-align: center;
  color: var(--text2);
  transition: all 0.12s;
  position: relative;
  margin-bottom: 10px;
  font-size: 12px;
}
.upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(100, 100, 200, 0.05);
}
.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 4px;
  margin-bottom: 10px;
}
.upload-preview img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

/* ===== Viewer ===== */
.viewer {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 100;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.viewer.open { display: flex; }

.viewer img {
  max-width: 95vw;
  max-height: 85vh;
  object-fit: contain;
}

.viewer-close {
  position: fixed;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  background: rgba(0,0,0,0.5);
  z-index: 101;
}

.viewer-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #fff;
  background: rgba(0,0,0,0.3);
  z-index: 101;
}
.viewer-prev { left: 8px; }
.viewer-next { right: 8px; }

.viewer-counter {
  position: fixed;
  bottom: 16px;
  color: rgba(255,255,255,0.4);
  font-size: 12px;
  z-index: 101;
}

/* ===== Empty ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  color: var(--text2);
  text-align: center;
}
.empty-state .emoji { font-size: 32px; margin-bottom: 8px; }

/* ===== Overlay / Modal ===== */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.overlay.open { display: flex; }

.overlay-content {
  background: var(--surface);
  width: 100%;
  max-width: 400px;
  max-height: 70vh;
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--border);
}
.overlay-content h3 {
  font-size: 13px;
  font-weight: 400;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text2);
}

.similar-select-item {
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  transition: background 0.12s;
}
.similar-select-item:active { background: var(--surface2); }
.similar-select-item:last-child { border-bottom: none; }

/* ===== Delete button on works ===== */
.work-delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  font-size: 12px;
  color: #fff;
  z-index: 2;
}
.artist-detail-edit-mode .work-delete-btn { display: flex; }
