:root {
  --bg: #ffffff;
  --text: #1a1a2e;
  --surface: #f8f9fa;
  --surface-hover: #f0f1f3;
  --border: #e0e0e0;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --code-bg: #f5f5f5;
  --radius: 0.5rem;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

[data-theme="dark"] {
  --bg: #0f0f1a;
  --text: #e8e8f0;
  --surface: #1a1a2e;
  --surface-hover: #252540;
  --border: #2a2a3e;
  --accent: #818cf8;
  --accent-hover: #6366f1;
  --danger: #f87171;
  --danger-hover: #ef4444;
  --code-bg: #1e1e2e;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Roboto', sans-serif;
  font-size: 18px;
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.toolbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.75rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}
@media (min-width: 768px) { .toolbar { padding: 0.75rem 4rem; } }
@media (min-width: 1200px) { .toolbar { padding: 0.75rem 6rem; } }

.site-title {
  font-size: 1.1rem; font-weight: 700;
  color: var(--text); text-decoration: none;
  margin-right: auto;
}

.toolbar button, .toolbar select {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  transition: border-color 0.2s;
}

.toolbar button:hover { border-color: var(--accent); }

.badge {
  padding: 0.2rem 0.6rem;
  background: var(--accent);
  color: white;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.font-size-display {
  min-width: 2rem; text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
}

.admin-link { font-size: 0.85rem; margin-left: 0.5rem; }
.breadcrumb { font-size: 0.85rem; opacity: 0.7; }

.container {
  max-width: 100%;
  margin: 0 auto;
  padding: 2rem 2rem;
}
@media (min-width: 768px) { .container { padding: 2rem 4rem; } }
@media (min-width: 1200px) { .container { padding: 2rem 6rem; } }

.create-section { margin-bottom: 3rem; }
.create-section h2 { margin-bottom: 1rem; font-size: 1.5rem; }

.create-form {
  display: flex; gap: 0.75rem;
  max-width: 100%;
}

.create-form input {
  flex: 1;
  padding: 0.6rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.2s;
}

.create-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.create-form button, .view-link {
  padding: 0.6rem 1.5rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.create-form button:hover, .view-link:hover {
  background: var(--accent-hover);
}

.projects-section h2 { margin-bottom: 1rem; font-size: 1.5rem; }

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
  gap: 1.5rem;
}

.project-card {
  display: flex; flex-direction: column; gap: 0.25rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: box-shadow 0.2s, border-color 0.2s;
}

.project-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
}

.project-card h3 { font-size: 1.1rem; color: var(--accent); }
.file-count, .date { font-size: 0.8rem; opacity: 0.7; }

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 0.75rem;
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--surface);
}

.drop-text { font-size: 1.2rem; font-weight: 500; margin-bottom: 0.25rem; }
.drop-subtext { font-size: 0.85rem; opacity: 0.6; }
.allowed-types { font-size: 0.8rem; opacity: 0.5; margin-bottom: 1.5rem; }

.upload-progress {
  padding: 0.75rem;
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.files-list { margin-bottom: 2rem; }

.file-item {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.file-name { flex: 1; font-weight: 500; }
.file-size { opacity: 0.6; font-size: 0.85rem; }

.landing-section {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.landing-section h3 { font-size: 0.95rem; }
.landing-section select {
  padding: 0.4rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg); color: var(--text);
}
.landing-section button {
  padding: 0.4rem 1rem; background: var(--accent); color: white;
  border: none; border-radius: var(--radius); cursor: pointer;
}

.view-link {
  display: inline-block;
  text-align: center;
  text-decoration: none;
}

.file-browser { margin-top: 1rem; }

.file-browser-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s;
}

.file-browser-item:hover { background: var(--surface); }

.file-icon { font-size: 1.4rem; opacity: 0.6; width: 2rem; text-align: center; }
.file-browser-name { flex: 1; font-weight: 500; }
.file-browser-size { opacity: 0.5; font-size: 0.85rem; }
.file-browser-date { opacity: 0.4; font-size: 0.8rem; }

.settings-section {
  padding: 1.5rem;
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 2rem;
}

.settings-form {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}

.settings-form label { font-size: 0.9rem; }
.settings-form input[type="number"] {
  width: 5rem; padding: 0.4rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text);
}

.settings-form button {
  padding: 0.4rem 1rem;
  background: var(--accent); color: white;
  border: none; border-radius: var(--radius);
  cursor: pointer;
}

.usage { font-size: 0.85rem; opacity: 0.7; }

.admin-projects-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: 1.25rem;
}

.admin-project-card {
  display: flex; flex-direction: column; gap: 0.25rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.2s;
}

.admin-project-card:hover { border-color: var(--accent); }
.admin-project-card h3 { color: var(--accent); }
.admin-project-card span { font-size: 0.8rem; opacity: 0.6; }

.project-detail {
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 2rem;
}

.detail-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.detail-header button { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text); }

.detail-actions {
  display: flex; gap: 0.5rem; align-items: center;
  margin-bottom: 1rem; flex-wrap: wrap;
}

.detail-actions input {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text);
}

.detail-actions button {
  padding: 0.4rem 1rem;
  border: none; border-radius: var(--radius);
  cursor: pointer; font-size: 0.85rem;
}

.detail-actions button:not(.danger) { background: var(--accent); color: white; }

.danger { background: var(--danger) !important; color: white !important; }
.danger:hover { background: var(--danger-hover) !important; }
.danger-sm { padding: 0.25rem 0.5rem; font-size: 0.75rem; border: none; border-radius: 0.25rem; cursor: pointer; }

.detail-landing {
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.detail-landing select {
  padding: 0.3rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg); color: var(--text);
}

.detail-landing button {
  padding: 0.3rem 0.75rem; background: var(--accent); color: white;
  border: none; border-radius: var(--radius); cursor: pointer; font-size: 0.85rem;
}

.detail-file-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.detail-file-item span:first-child { flex: 1; }

.detail-upload {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.detail-upload button {
  margin-top: 0.5rem;
  padding: 0.4rem 1rem;
  background: var(--accent); color: white;
  border: none; border-radius: var(--radius); cursor: pointer;
}

.error { color: var(--danger); font-size: 0.9rem; white-space: pre-line; }
.empty { opacity: 0.5; font-style: italic; }
.loading { opacity: 0.5; }

.search-sort-bar {
  display: flex; gap: 0.75rem; margin-bottom: 1.5rem; flex-wrap: wrap;
}

.search-sort-bar input {
  flex: 1; min-width: 12rem;
  padding: 0.6rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.2s;
}

.search-sort-bar input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-sort-bar select {
  padding: 0.6rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

.project-count {
  font-size: 0.85rem;
  opacity: 0.6;
  margin-bottom: 1rem;
}

@media (max-width: 640px) {
  .container { padding: 1rem; }
  .toolbar { padding: 0.5rem 1rem; }
  .create-form { flex-direction: column; }
  .settings-form { flex-direction: column; align-items: flex-start; }
  .detail-actions { flex-direction: column; }
}
