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

:root {
  --bg:        #111111;
  --surface:   #1a1a1a;
  --surface2:  #222222;
  --surface3:  #2a2a2a;
  --border:    #2e2e2e;
  --border2:   #3a3a3a;
  --text:      #e8e8e8;
  --text-2:    #999;
  --text-3:    #555;
  --accent:    #4a7fc1;
  --accent-h:  #5a8fd1;
  --danger:    #c15a4a;
  --success:   #4ac17a;
  --radius:    8px;
  --sidebar-w: 240px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
#app { display: flex; height: 100vh; overflow: hidden; }

#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

#main {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
}

/* ── Sidebar ── */
.sidebar-logo {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo-icon {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}

.sidebar-logo-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.sidebar-logo-text small {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: var(--text-2);
}

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-section { margin-bottom: 4px; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-3);
  padding: 8px 18px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 18px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  border-radius: 0;
  transition: background 0.12s, color 0.12s;
  text-decoration: none;
  user-select: none;
  border-left: 2px solid transparent;
}

.nav-item:hover { background: var(--surface2); color: var(--text); }

.nav-item.active {
  background: var(--surface2);
  color: var(--text);
  border-left-color: var(--accent);
}

.nav-item-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }

.nav-item-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 16px;
  padding: 0 2px;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.12s, background 0.12s;
}

.nav-item-btn:hover { color: var(--text); background: var(--surface3); }

.nav-sub { padding-left: 10px; }

.nav-sub .nav-item { font-size: 12px; padding: 5px 18px 5px 10px; }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface3);
  border: 1px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  flex-shrink: 0;
}

.sidebar-email {
  flex: 1;
  font-size: 11px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-logout {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 12px;
  padding: 3px 6px;
  border-radius: 4px;
  font-family: inherit;
  transition: color 0.12s, background 0.12s;
  white-space: nowrap;
}

.sidebar-logout:hover { color: var(--danger); background: rgba(193,90,74,0.08); }

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

.page-title { font-size: 22px; font-weight: 600; }
.page-subtitle { font-size: 13px; color: var(--text-2); margin-top: 3px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-family: inherit; font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover { background: var(--surface3); border-color: #444; }
.btn:active { transform: scale(0.98); }

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

.btn-danger {
  background: rgba(193,90,74,0.12);
  border-color: rgba(193,90,74,0.3);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(193,90,74,0.2); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); border-color: var(--border); }

.btn-sm { font-size: 12px; padding: 5px 11px; }
.btn-icon { padding: 7px; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.wheel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.wheel-card:hover {
  border-color: var(--border2);
  background: var(--surface2);
  transform: translateY(-1px);
}

.wheel-card-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.wheel-card-meta {
  font-size: 11px;
  color: var(--text-2);
  display: flex;
  gap: 12px;
}

.wheel-card-preview {
  display: flex;
  gap: 3px;
  align-items: flex-end;
  height: 32px;
}

.preview-bar {
  flex: 1;
  border-radius: 2px;
  min-height: 2px;
  transition: height 0.3s;
}

.wheel-card-actions {
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.15s;
  position: absolute;
  top: 14px;
  right: 14px;
}

.wheel-card:hover .wheel-card-actions { opacity: 1; }

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }

.form-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-input {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-3); }

.form-error {
  font-size: 12px;
  color: var(--danger);
  min-height: 16px;
}

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 28px;
  width: 380px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 32px 80px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-title { font-size: 17px; font-weight: 600; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }

/* ── Auth page ── */
#auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-box {
  width: 380px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.auth-logo {
  text-align: center;
}

.auth-logo-icon {
  width: 48px; height: 48px;
  background: var(--accent);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 10px;
}

.auth-logo h1 { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.auth-logo p { font-size: 13px; color: var(--text-2); }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
}

.auth-tabs {
  display: flex;
  gap: 0;
  background: var(--surface2);
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  text-align: center;
  padding: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}

.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.auth-divider {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  margin: 4px 0;
}

/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 20px;
  color: var(--text-2);
  text-align: center;
}

.empty-state-icon { font-size: 40px; opacity: 0.4; }
.empty-state h3 { font-size: 16px; font-weight: 500; color: var(--text); }
.empty-state p { font-size: 13px; max-width: 300px; }

/* ── Folder ── */
.folder-section { margin-bottom: 24px; }

.folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  cursor: pointer;
  user-select: none;
}

.folder-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.folder-count {
  font-size: 11px;
  color: var(--text-3);
  background: var(--surface2);
  border-radius: 10px;
  padding: 1px 7px;
}

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-blue { background: rgba(74,127,193,0.15); color: var(--accent); }
.badge-green { background: rgba(74,193,122,0.15); color: var(--success); }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 13px;
  color: var(--text);
  transition: transform 0.25s ease;
  z-index: 1000;
  pointer-events: none;
  white-space: nowrap;
}

#toast.show { transform: translateX(-50%) translateY(0); }
#toast.error { border-color: rgba(193,90,74,0.4); color: var(--danger); }

/* ── About page ── */
.about-content {
  max-width: 680px;
}

.about-content h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 28px 0 10px;
  color: var(--text);
}

.about-content h2:first-child { margin-top: 0; }

.about-content p {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.7;
  margin-bottom: 12px;
}

.about-content ul {
  padding-left: 20px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.8;
  margin-bottom: 12px;
}

.about-step {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  align-items: flex-start;
}

.about-step-num {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(74,127,193,0.15);
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.about-step-body h3 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.about-step-body p { font-size: 13px; color: var(--text-2); line-height: 1.6; margin: 0; }

/* ── Spinner ── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utilities ── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.text-muted { color: var(--text-2); }
.text-sm { font-size: 12px; }

/* ── Mobile hamburger button ── */
#mobile-menu-btn {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 400;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 8px;
  width: 38px; height: 38px;
  align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 16px;
}

#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 350;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  #mobile-menu-btn { display: flex; }

  #sidebar {
    position: fixed;
    left: -100%;
    top: 0; bottom: 0;
    z-index: 400;
    width: 260px;
    min-width: 260px;
    transition: left 0.25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
  }

  #sidebar.open {
    left: 0;
  }

  #sidebar-overlay.open { display: block; }

  #main {
    padding: 56px 16px 32px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .modal { width: calc(100vw - 32px); }

  #wheel-container {
    width: min(90vw, 420px) !important;
    height: min(90vw, 420px) !important;
  }

  .auth-box { width: 100%; }

  #actions {
    flex-direction: column;
    align-items: stretch;
  }

  #actions .btn {
    justify-content: center;
  }
}
