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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  line-height: 1.6;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}

.container-fluid {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Layout */
.layout {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px 40px;
  gap: 24px;
  align-items: flex-start;
}

.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid #f0f0f0;
}

.sidebar-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
}

.site-list {
  overflow-y: auto;
  padding: 8px;
}

.site-item {
  display: block;
  padding: 12px 14px;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  margin-bottom: 4px;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.site-item:hover {
  background: #f5f7ff;
  border-color: #e0e4ff;
}

.site-item.active {
  background: #eef1ff;
  border-color: #667eea;
}

.site-item-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.site-item-domain {
  color: #667eea;
  font-size: 0.8rem;
  margin-bottom: 4px;
}

.site-item-meta {
  color: #999;
  font-size: 0.75rem;
}

.empty-sidebar {
  padding: 20px 14px;
  color: #999;
  font-size: 0.85rem;
  text-align: center;
}

.main-content {
  flex: 1;
  min-width: 0;
}

.card-info {
  background: #fafbff;
}

.info-list {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px 16px;
  font-size: 0.9rem;
}

.info-list dt {
  color: #666;
  font-weight: 500;
}

.info-list dd code {
  background: #f0f2f5;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  word-break: break-all;
}

/* Auth */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.auth-card h1 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.subtitle {
  color: #666;
  margin-bottom: 24px;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-card .form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-card .form-group label {
  font-weight: 500;
  font-size: 0.9rem;
}

.auth-card input {
  width: 100%;
}

.btn-block {
  width: 100%;
  text-align: center;
}

/* Header */
.header {
  background: #fff;
  border-bottom: 1px solid #e8e8e8;
  padding: 16px 0;
  margin-bottom: 24px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header h1 {
  font-size: 1.25rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #666;
}

/* Cards */
.card {
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.card h2 {
  font-size: 1.1rem;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f0f0f0;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-weight: 500;
  font-size: 0.9rem;
}

.form-group small {
  color: #999;
  font-size: 0.8rem;
}

input, select {
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
}

input:focus, select:focus {
  outline: none;
  border-color: #667eea;
}

.form-actions {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.95rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary {
  background: #667eea;
  color: #fff;
}

.btn-primary:hover {
  background: #5a6fd6;
}

.btn-outline {
  background: transparent;
  color: #667eea;
  border: 1px solid #667eea;
  padding: 6px 14px;
  font-size: 0.85rem;
}

.btn-outline:hover {
  background: #f0f2ff;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.8rem;
}

.btn-secondary {
  background: #f0f2f5;
  color: #333;
  border: 1px solid #ddd;
}

.btn-secondary:hover {
  background: #e8eaed;
}

.btn-danger {
  background: #fff2f0;
  color: #cf1322;
  border: 1px solid #ffccc7;
}

.btn-danger:hover {
  background: #ffccc7;
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 0.9rem;
}

.alert-error {
  background: #fff2f0;
  color: #cf1322;
  border: 1px solid #ffccc7;
}

.alert-success {
  background: #f6ffed;
  color: #389e0d;
  border: 1px solid #b7eb8f;
}

/* Template list */
.template-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.template-item {
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 16px;
}

.template-item h3 {
  font-size: 1rem;
  margin-bottom: 4px;
}

.template-item p {
  color: #666;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.template-item code {
  background: #f5f5f5;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
}

.empty {
  color: #999;
}

@media (max-width: 900px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    position: static;
    max-height: 280px;
  }
}

@media (max-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
    text-align: center;
  }
}

.image-manager-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.image-manager-header h2 {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.form-hint {
  margin: 10px 0 0;
  font-size: 0.85rem;
  color: #666;
  line-height: 1.5;
}

.image-manager-hint {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.image-manager-hint code {
  background: #f0f0f5;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}

.theme-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 2px solid #e8e8f0;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.theme-option:hover {
  border-color: #c5c5e0;
}

.theme-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-option:has(input:checked) {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.theme-swatch {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.theme-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.theme-label strong {
  font-size: 0.95rem;
  color: #333;
}

.theme-label small {
  font-size: 0.8rem;
  color: #888;
  line-height: 1.3;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.image-card {
  border: 1px solid #e8e8e8;
  border-radius: 10px;
  overflow: hidden;
  background: #fafafa;
}

.image-card-thumb {
  aspect-ratio: 1;
  background: #1a0a2e;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

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

.image-card-body {
  padding: 12px;
}

.image-card-body h3 {
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.image-card-meta {
  font-size: 0.72rem;
  color: #888;
  word-break: break-all;
  margin-bottom: 4px;
}

.image-card-size {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 10px;
}

.error-text {
  color: #c0392b;
}

body.progress-active {
  overflow: hidden;
}

.progress-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.progress-overlay[hidden] {
  display: none;
}

.progress-card {
  width: min(480px, 100%);
  background: #fff;
  border-radius: 12px;
  padding: 28px 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.progress-title {
  margin: 0 0 8px;
  font-size: 1.15rem;
  color: #1a1a2e;
}

.progress-label {
  margin: 0 0 16px;
  color: #555;
  font-size: 0.95rem;
  min-height: 1.4em;
}

.progress-bar {
  height: 10px;
  background: #eef0f4;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 0.85rem;
  color: #777;
}

.progress-note {
  margin: 12px 0 0;
  font-size: 0.85rem;
  color: #888;
  text-align: center;
}

.image-card-progress {
  height: 4px;
  background: #eef0f4;
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0;
}

.image-card-progress-fill {
  height: 100%;
  width: 30%;
  background: #667eea;
  border-radius: 999px;
  animation: image-progress-indeterminate 1.2s ease-in-out infinite;
}

@keyframes image-progress-indeterminate {
  0% { transform: translateX(-100%); width: 40%; }
  50% { transform: translateX(80%); width: 60%; }
  100% { transform: translateX(250%); width: 40%; }
}
