:root {
  --bg: #0a0a0b;
  --surface: #111113;
  --surface-2: #18181b;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;
  --accent: #10b981;
  --accent-dim: rgba(16, 185, 129, 0.15);
  --accent-hover: #34d399;
  --selected: #f59e0b;
  --selected-dim: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --sidebar-w: 300px;
  --toolbar-h: 56px;
  --detail-h: 72px;
  --font: 'Geist', system-ui, -apple-system, sans-serif;
  --mono: 'Geist Mono', ui-monospace, monospace;
  --radius: 8px;
  --shadow: 0 0 0 1px var(--border), 0 8px 24px rgba(0, 0, 0, 0.4);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: margin-left 0.2s ease, opacity 0.2s ease;
}

.sidebar.collapsed {
  margin-left: calc(-1 * var(--sidebar-w));
  opacity: 0;
  pointer-events: none;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.logo-mark {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.5px;
}

.logo h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.logo-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.search {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.search:focus {
  border-color: var(--accent);
}

.search::placeholder { color: var(--text-dim); }

.filter-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.filter-select {
  flex: 1;
  padding: 6px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

.filter-btn {
  padding: 6px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.filter-btn.active {
  background: var(--selected-dim);
  border-color: var(--selected);
  color: var(--selected);
}

.design-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.design-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  transition: all 0.12s;
}

.design-item:hover {
  background: var(--surface-2);
  border-color: var(--border);
}

.design-item.active {
  background: var(--accent-dim);
  border-color: rgba(16, 185, 129, 0.3);
}

.design-item.selected-star .star {
  color: var(--selected);
}

.design-item-info {
  flex: 1;
  min-width: 0;
}

.design-item-name {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.2px;
}

.design-item-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.star {
  color: var(--text-dim);
  font-size: 12px;
  flex-shrink: 0;
}

.category-label {
  padding: 12px 12px 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

/* Main */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.toolbar {
  height: var(--toolbar-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toolbar-right { flex-shrink: 0; }

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

.current-design h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.current-category {
  font-size: 11px;
  color: var(--text-dim);
}

.theme-toggle {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
}

.theme-btn {
  padding: 5px 14px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.theme-btn.active {
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border);
}

.theme-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #042f1a;
  border-color: var(--accent);
}

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

.btn-ghost {
  background: var(--surface-2);
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-ghost.is-selected {
  background: var(--selected-dim);
  color: var(--selected);
  border-color: rgba(245, 158, 11, 0.4);
}

.btn-icon { font-size: 14px; }

.preview-area {
  flex: 1;
  position: relative;
  background: #1a1a1c;
  overflow: hidden;
}

.preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

.preview-frame.hidden { display: none; }

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-dim);
}

.empty-icon {
  font-size: 48px;
  opacity: 0.3;
  margin-bottom: 8px;
}

.empty-hint {
  font-size: 12px;
  opacity: 0.7;
}

.detail-bar {
  height: var(--detail-h);
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
}

.detail-bar p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.path-code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 3px 8px;
  border-radius: 4px;
  align-self: flex-start;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  padding: 10px 20px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: all 0.25s ease;
  z-index: 999;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success { border-color: rgba(16, 185, 129, 0.5); }
.toast.error { border-color: rgba(239, 68, 68, 0.5); }

@media (max-width: 768px) {
  :root { --sidebar-w: 100vw; }
  .toolbar { flex-wrap: wrap; height: auto; padding: 10px; }
  .toolbar-center { order: 3; width: 100%; }
  .theme-toggle { width: 100%; }
  .theme-btn { flex: 1; }
  .btn-download { display: none; }
}
