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

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-elevated: #f9fafb;
  --border: #e2e5ee;
  --border-focus: #6366f1;
  --text-primary: #1a1d2e;
  --text-secondary: #6b7080;
  --text-muted: #adb2c4;
  --accent: #6366f1;
  --accent-hover: #4f52d4;
  --accent-subtle: rgba(99, 102, 241, 0.08);
  --radius: 12px;
  --radius-sm: 7px;
}

html, body {
  width: 100%;
  min-height: 100%;
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'Pretendard', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

/* ── Layout ─────────────────────────────────────── */

#main {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

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

header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}

header h1 {
  flex: 1;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: color 0.15s, border-color 0.15s;
}

.btn-back:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  padding: 7px 16px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  white-space: nowrap;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

/* ── Dataset Grid (index) ────────────────────────── */

#dataset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.dataset-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.18s, transform 0.18s;
}

.dataset-card:hover {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.09);
  transform: translateY(-2px);
}

.card-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--surface-elevated);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.no-thumb {
  font-size: 36px;
  font-weight: 700;
  color: var(--text-muted);
}

.card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.card-category {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
}

.card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Dataset Detail ──────────────────────────────── */

.detail-hero {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 32px;
  margin-bottom: 24px;
  align-items: start;
}

.detail-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.detail-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.no-thumb.large {
  font-size: 64px;
}

.detail-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 4px;
}

.detail-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.detail-ref {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.detail-ref:hover {
  text-decoration: underline;
}

.tag-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--surface-elevated);
}

.detail-sections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.detail-text {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.8;
  white-space: pre-wrap;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 9px 18px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent-subtle);
  transition: background 0.15s;
}

.btn-download:hover {
  background: var(--accent);
  color: #fff;
}

/* ── Utility ─────────────────────────────────────── */

.loading, .empty {
  color: var(--text-muted);
  font-size: 14px;
  padding: 40px 0;
  text-align: center;
}

/* ── Form Sections ───────────────────────────────── */

#cont {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ── Field ───────────────────────────────────────── */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.field > label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
}

/* ── Two-column Row ──────────────────────────────── */

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Inputs & Textareas ──────────────────────────── */

input[type="text"],
textarea,
select {
  width: 100%;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  padding: 9px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

input[type="text"]:focus,
textarea:focus,
select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-subtle);
  background: var(--surface);
}

input[type="text"][readonly] {
  color: var(--text-muted);
  cursor: default;
}

textarea {
  resize: vertical;
  min-height: 160px;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7080' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

/* ── Category add ────────────────────────────────── */

.input-with-btn {
  display: flex;
  gap: 8px;
}

.input-with-btn input {
  flex: 1;
}

/* ── Checkboxes ──────────────────────────────────── */

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 2px;
}

#dataset-usecase input[type="checkbox"] {
  display: none;
}

#dataset-usecase input[type="checkbox"] + label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  background: var(--surface-elevated);
}

#dataset-usecase input[type="checkbox"]:checked + label {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* ── File Upload ─────────────────────────────────── */

input[type="file"] {
  font-family: inherit;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--surface-elevated);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  width: 100%;
  transition: border-color 0.15s;
}

input[type="file"]:hover {
  border-color: var(--accent);
}

input[type="file"]::file-selector-button {
  background: var(--accent-subtle);
  color: var(--accent);
  border: 1px solid var(--border-focus);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-right: 10px;
  transition: background 0.15s;
}

input[type="file"]::file-selector-button:hover {
  background: var(--accent);
  color: #fff;
}

/* ── Buttons ─────────────────────────────────────── */

button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

button:active {
  transform: scale(0.97);
}

button#add {
  background: var(--surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 9px 16px;
  white-space: nowrap;
}

button#add:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btns {
  display: flex;
  justify-content: flex-end;
}

#add-btn {
  background: var(--accent);
  color: #fff;
  padding: 11px 32px;
  font-size: 14px;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.3);
}

#add-btn:hover {
  background: var(--accent-hover);
}

/* ── Secondary Button ───────────────────────────── */

.btn-secondary {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.btn-secondary:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Modal ───────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}

.modal-close:hover {
  color: var(--text-primary);
  background: var(--surface-elevated);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

/* ── Category List (modal) ───────────────────────── */

#category-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#category-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: background 0.12s;
}

#category-list li:hover {
  background: var(--surface-elevated);
}

.drag-handle {
  font-size: 16px;
  color: var(--text-muted);
  cursor: grab;
  padding: 0 4px;
  flex-shrink: 0;
  user-select: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.category-name-input {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 14px;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.category-name-input:focus {
  border-color: var(--border-focus);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}



.category-delete-btn {
  background: none;
  border: none;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

#category-list li:hover .category-delete-btn {
  opacity: 1;
}

.category-delete-btn:hover {
  color: var(--danger);
}

#category-list li.dragging {
  opacity: 0.4;
  background: var(--accent-subtle);
}

/* ── Scrollbar ───────────────────────────────────── */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
