*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --border: #e2e5ed;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --danger: #ef4444;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* Login */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--surface);
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,.1);
  width: 100%;
  max-width: 400px;
}

.login-card h1 {
  font-size: 1.75rem;
  text-align: center;
}

.subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1.5rem;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: .75rem;
}

.header-left h1 {
  font-size: 1.125rem;
}

.header-sub {
  color: var(--text-secondary);
  font-size: .875rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: .875rem;
}

/* Layout */
.layout {
  display: flex;
  height: calc(100vh - 56px);
}

.sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem .75rem;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.main {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

/* Sidebar tags */
.tag-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .75rem;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-size: .875rem;
  cursor: pointer;
  transition: background .15s;
}

.tag-item:hover { background: var(--bg); }
.tag-item.active { background: #eef2ff; color: var(--primary); font-weight: 500; }

.tag-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tag-dot.all { background: var(--primary); }

.tag-dot.folder {
  background: transparent;
  width: 12px;
  height: 10px;
  border-radius: 2px;
  border: 2px solid #9CA3AF;
  border-top-width: 3px;
}

.sidebar-label {
  font-size: .6875rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .25rem .75rem;
  margin-bottom: .25rem;
}

.tag-sep {
  color: var(--border);
  align-self: center;
  font-size: .875rem;
}

.draft-tag {
  border-style: dashed;
}

.tag-count {
  margin-left: auto;
  font-size: .75rem;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 0 .4rem;
  border-radius: 10px;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: .5rem 0;
}

.sidebar-add {
  margin-top: auto;
  font-size: .8125rem;
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: .8125rem;
  font-weight: 500;
  margin-bottom: .25rem;
  color: var(--text-secondary);
}

.form-group.inline {
  margin-bottom: 0;
}

.form-group.flex-grow { flex: 1; }

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  outline: none;
  transition: border-color .15s;
}

input:focus { border-color: var(--primary); }

/* Buttons */
.btn {
  padding: .5rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: .875rem;
  cursor: pointer;
  transition: background .15s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover { background: var(--bg); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  font-size: .75rem;
  padding: .25rem .5rem;
}

.btn-block { width: 100%; }

.error-msg {
  color: var(--danger);
  font-size: .8125rem;
  margin-bottom: .75rem;
}

/* Upload */
.upload-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.upload-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--text-secondary);
  transition: border-color .15s, background .15s;
  margin-bottom: 1rem;
}

.drop-zone.dragover {
  border-color: var(--primary);
  background: #eef2ff;
}

.drop-zone a { color: var(--primary); }

.hint { font-size: .75rem; margin-top: .25rem; }

.tag-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.tag-checkbox {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .25rem .6rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: .8125rem;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}

.tag-checkbox:has(input:checked) {
  border-color: var(--primary);
  background: #eef2ff;
}

.tag-checkbox input { display: none; }

.tag-checkbox .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.pending-files {
  margin-bottom: 1rem;
}

.pending-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem 0;
  font-size: .8125rem;
  border-bottom: 1px solid var(--border);
}

.pending-item .name { flex: 1; }
.pending-item .size { color: var(--text-secondary); }
.pending-item .status { font-size: .75rem; }
.pending-item .status.done { color: #16a34a; }
.pending-item .status.error { color: var(--danger); }

/* Files */
.files-header {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  margin-bottom: 1rem;
}

.files-header h2 { font-size: 1.125rem; }

.file-count { color: var(--text-secondary); font-size: .875rem; }

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.file-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow .15s;
}

.file-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); }

.file-thumb {
  height: 160px;
  background: #f0f0f5;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-thumb .video-icon {
  font-size: 2.5rem;
  color: var(--text-secondary);
}

.file-info {
  padding: .75rem;
}

.file-name {
  font-size: .8125rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: .25rem;
}

.file-meta {
  font-size: .75rem;
  color: var(--text-secondary);
  margin-bottom: .5rem;
}

.file-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  margin-bottom: .5rem;
}

.file-tag {
  font-size: .6875rem;
  padding: .1rem .4rem;
  border-radius: 10px;
  color: #fff;
}

.file-actions {
  display: flex;
  gap: .5rem;
}

.file-actions .btn { font-size: .75rem; padding: .25rem .6rem; }

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
}

/* Modal */
.modal {
  border: none;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
  max-width: 420px;
  width: 90%;
}

.modal::backdrop { background: rgba(0,0,0,.3); }

.modal h3 { margin-bottom: 1rem; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  margin-top: 1.25rem;
}

@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .upload-row { flex-direction: column; }
}
