* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #0f1117; color: #e0e0e0; min-height: 100vh; }
a { color: #7c8aff; }

/* Login */
.login-wrap { display: flex; align-items: center; justify-content: center; height: 100vh; padding: 1rem; }
.login-card { background: #1a1d2e; padding: 2.5rem; border-radius: 12px; width: 360px; max-width: 100%; }
.login-card h2 { margin-bottom: 1.5rem; text-align: center; color: #fff; }
.login-card input { width: 100%; padding: 0.75rem; border: 1px solid #333; border-radius: 8px; background: #0f1117; color: #fff; font-size: 1rem; margin-bottom: 1rem; }
.login-card button { width: 100%; padding: 0.75rem; border: none; border-radius: 8px; background: #5b6abf; color: #fff; font-size: 1rem; cursor: pointer; }
.login-card button:hover { background: #6b7acf; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #1a1d2e; padding: 1.5rem 0; flex-shrink: 0; }
.sidebar h1 { font-size: 1.1rem; padding: 0 1.5rem; margin-bottom: 2rem; color: #fff; }
.sidebar a { display: block; padding: 0.75rem 1.5rem; color: #aaa; text-decoration: none; font-size: 0.95rem; border-left: 3px solid transparent; }
.sidebar a:hover, .sidebar a.active { color: #fff; background: #252840; border-left-color: #5b6abf; }
.sidebar .logout { position: absolute; bottom: 1.5rem; left: 0; width: 220px; padding: 0.75rem 1.5rem; color: #888; cursor: pointer; border: none; background: none; text-align: left; font-size: 0.9rem; }
.sidebar .logout:hover { color: #fff; }

/* Hamburger button - hidden on desktop */
.hamburger-btn { display: none; position: fixed; top: 0.75rem; left: 0.75rem; z-index: 1001; background: #1a1d2e; border: 1px solid #333; color: #fff; font-size: 1.5rem; padding: 0.4rem 0.7rem; border-radius: 8px; cursor: pointer; line-height: 1; }
.hamburger-btn:hover { background: #252840; }
.sidebar-overlay { display: none; }

.main { flex: 1; padding: 2rem 3rem; overflow-y: auto; }
.main h2 { margin-bottom: 1.5rem; color: #fff; }

/* Auto-build bar */
.auto-build-bar { display: flex; justify-content: flex-end; margin-bottom: 0.5rem; }
.auto-build-label { display: flex; align-items: center; gap: 0.5rem; color: #aaa; font-size: 0.85rem; cursor: pointer; background: #1a1d2e; padding: 0.4rem 1rem; border-radius: 8px; }
.auto-build-label input { width: auto; margin: 0; }

/* Forms */
label { display: block; margin-bottom: 0.4rem; color: #aaa; font-size: 0.9rem; }
input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
  width: 100%; padding: 0.6rem 0.8rem; border: 1px solid #333; border-radius: 8px;
  background: #1a1d2e; color: #e0e0e0; font-size: 0.95rem; margin-bottom: 1rem;
}
textarea { min-height: 300px; font-family: 'JetBrains Mono', monospace; resize: vertical; }
.form-row { display: flex; gap: 1rem; }
.form-row > div { flex: 1; }

.section-subtitle { margin: 1.5rem 0 0.8rem; color: #fff; }

/* Buttons */
.btn { padding: 0.6rem 1.4rem; border: none; border-radius: 8px; cursor: pointer; font-size: 0.9rem; }
.btn-primary { background: #5b6abf; color: #fff; }
.btn-primary:hover { background: #6b7acf; }
.btn-danger { background: #bf4b4b; color: #fff; }
.btn-danger:hover { background: #cf5b5b; }
.btn-warning { background: #e6a23c; color: #fff; }
.btn-warning:hover { background: #d4940a; }
.btn-secondary { background: #333; color: #ddd; }
.btn-secondary:hover { background: #444; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Table */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid #222; }
th { color: #888; font-weight: 500; font-size: 0.85rem; text-transform: uppercase; }
td { font-size: 0.95rem; }
tr:hover { background: #1a1d2e; }

/* Tags */
.tag { display: inline-block; background: #252840; color: #7c8aff; padding: 2px 8px; border-radius: 4px; font-size: 0.8rem; margin: 0 2px; }
.draft-badge { background: #bf8b2e; color: #fff; padding: 2px 8px; border-radius: 4px; font-size: 0.8rem; }

/* Images grid */
.images-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.image-card { background: #1a1d2e; border-radius: 8px; overflow: hidden; position: relative; }
.image-card img { width: 100%; height: 120px; object-fit: cover; }
.image-card .info { padding: 0.5rem; font-size: 0.8rem; color: #aaa; word-break: break-all; }
.image-card .del-btn { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,0.7); color: #ff6b6b; border: none; border-radius: 4px; padding: 2px 6px; cursor: pointer; font-size: 0.8rem; }
.image-card .select-cb { position: absolute; top: 4px; left: 4px; width: 18px; height: 18px; cursor: pointer; accent-color: #5b6abf; }
.image-card.selected { outline: 2px solid #5b6abf; outline-offset: -2px; }

/* Upload area */
.upload-area { border: 2px dashed #333; border-radius: 12px; padding: 2rem; text-align: center; color: #666; margin-bottom: 1.5rem; cursor: pointer; }
.upload-area:hover { border-color: #5b6abf; color: #aaa; }

/* Deploy */
.deploy-log { background: #0a0c14; border: 1px solid #222; border-radius: 8px; padding: 1rem; font-family: monospace; font-size: 0.85rem; white-space: pre-wrap; max-height: 500px; overflow-y: auto; margin-top: 1rem; color: #8f8; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-dot.idle { background: #4a4; }
.status-dot.building { background: #db2; animation: pulse 1s infinite; }
.status-dot.error { background: #d44; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Social links editor */
.link-row { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
.link-row input { margin-bottom: 0; flex: 1; }
.link-row button { flex-shrink: 0; }

/* Hue preview */
.hue-preview { width: 40px; height: 40px; border-radius: 8px; display: inline-block; vertical-align: middle; margin-left: 0.5rem; }

.hidden { display: none !important; }
.msg { padding: 0.75rem; border-radius: 8px; margin-bottom: 1rem; }
.msg-ok { background: #1a3a1a; color: #4a4; }
.msg-err { background: #3a1a1a; color: #f66; }

/* Nav items */
.nav-items-list { min-height: 40px; }
.nav-item { display: flex; align-items: center; gap: 0.5rem; background: #1a1d2e; border: 1px solid #333; border-radius: 8px; padding: 0.75rem 1rem; margin-bottom: 0.5rem; cursor: grab; }
.nav-item:active { cursor: grabbing; }
.nav-item .nav-handle { color: #555; font-size: 1.2rem; cursor: grab; user-select: none; }
.nav-item .nav-label { flex: 1; color: #e0e0e0; }
.nav-item .nav-type { color: #7c8aff; font-size: 0.8rem; background: #252840; padding: 2px 8px; border-radius: 4px; }
.nav-item input { margin-bottom: 0; }
.nav-item-fields { display: flex; gap: 0.5rem; flex: 1; align-items: center; }
.nav-item-fields input { margin-bottom: 0; flex: 1; }
.nav-item-fields label { margin-bottom: 0; white-space: nowrap; }
.nav-drag-over { border-color: #5b6abf; background: #252840; }

/* Editor split pane */
.editor-split { display: flex; gap: 1rem; margin-bottom: 1rem; }
.editor-textarea { flex: 1; min-height: 400px; margin-bottom: 0; }
.editor-preview {
  flex: 1;
  min-height: 400px;
  max-height: 600px;
  overflow-y: auto;
  background: #1a1d2e;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 1rem;
  font-size: 0.95rem;
  line-height: 1.6;
  color: #e0e0e0;
}
.editor-preview h1 { font-size: 1.8rem; margin: 0.5rem 0; color: #fff; }
.editor-preview h2 { font-size: 1.4rem; margin: 0.8rem 0 0.4rem; color: #fff; border-bottom: 1px solid #333; padding-bottom: 0.3rem; }
.editor-preview h3 { font-size: 1.2rem; margin: 0.6rem 0 0.3rem; color: #fff; }
.editor-preview h4 { font-size: 1.05rem; margin: 0.5rem 0 0.3rem; color: #fff; }
.editor-preview p { margin: 0.5rem 0; }
.editor-preview code { background: #252840; padding: 2px 6px; border-radius: 4px; font-family: 'JetBrains Mono', monospace; font-size: 0.9em; }
.editor-preview pre { background: #0a0c14; padding: 1rem; border-radius: 8px; overflow-x: auto; margin: 0.5rem 0; }
.editor-preview pre code { background: none; padding: 0; }
.editor-preview blockquote { border-left: 3px solid #5b6abf; padding-left: 1rem; margin: 0.5rem 0; color: #aaa; }
.editor-preview ul, .editor-preview ol { padding-left: 1.5rem; margin: 0.5rem 0; }
.editor-preview li { margin: 0.25rem 0; }
.editor-preview a { color: #7c8aff; }
.editor-preview img { max-width: 100%; border-radius: 8px; }
.editor-preview table { width: 100%; border-collapse: collapse; margin: 0.5rem 0; }
.editor-preview th, .editor-preview td { padding: 0.5rem; border: 1px solid #333; }
.editor-preview strong { color: #fff; }
.editor-preview hr { border: none; border-top: 1px solid #333; margin: 1rem 0; }

/* Stats cards */
.stat-card { background: #1a1d2e; border: 1px solid #333; border-radius: 12px; padding: 1.5rem 2rem; min-width: 160px; }
.stat-label { color: #aaa; font-size: 0.85rem; margin-bottom: 0.5rem; }
.stat-value { color: #fff; font-size: 2rem; font-weight: 700; }

/* Post checkbox column */
th:first-child, td:first-child { width: 40px; text-align: center; }
td:first-child input[type=checkbox] { width: auto; margin: 0; cursor: pointer; accent-color: #5b6abf; }

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
  /* Hamburger visible */
  .hamburger-btn { display: block; }

  /* Sidebar as overlay */
  .sidebar {
    position: fixed !important;
    top: 0;
    left: -260px;
    width: 260px;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s ease;
    overflow-y: auto;
    padding-bottom: 4rem;
  }
  .sidebar.open { left: 0; }
  .sidebar .logout { width: 260px; }

  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
  }
  .sidebar-overlay.active { display: block; }

  /* Main content full width */
  .main { padding: 1rem; padding-top: 3.5rem; }

  /* Forms stack vertically */
  .form-row { flex-direction: column; gap: 0; }

  /* Editor split stacks vertically */
  .editor-split { flex-direction: column; }
  .editor-textarea { min-height: 250px; }
  .editor-preview { min-height: 200px; max-height: 400px; }

  /* Nav items fields stack */
  .nav-item { flex-wrap: wrap; }
  .nav-item-fields { flex-wrap: wrap; }

  /* Link row stack */
  .link-row { flex-wrap: wrap; }
  .link-row input { min-width: 120px; }

  /* Images grid smaller */
  .images-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.75rem; }

  /* Stat cards */
  .stat-card { min-width: 120px; padding: 1rem 1.5rem; }
  .stat-value { font-size: 1.5rem; }

  /* Auto-build bar */
  .auto-build-bar { margin-top: 0; }
}

@media (max-width: 480px) {
  .main { padding: 0.75rem; padding-top: 3.5rem; }
  .images-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .stat-card { min-width: 100px; }
  .btn { padding: 0.5rem 1rem; font-size: 0.85rem; }
}

/* 商店管理 */
.store-overview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.5rem;
}
.store-stat-card {
  padding: 1rem;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  text-align: center;
}
.store-stat-num {
  font-size: 1.6rem;
  font-weight: 800;
  color: #4dabf7;
  line-height: 1.2;
}
.store-stat-num.green { color: #51cf66; }
.store-stat-num.orange { color: #ffa94d; }
.store-stat-num.red { color: #ff6b6b; }
.store-stat-label {
  font-size: 0.75rem;
  color: #868e96;
  margin-top: 0.3rem;
}
.store-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid rgba(255,255,255,0.08);
}
.store-tab {
  padding: 0.6rem 1.2rem;
  background: none;
  border: none;
  color: #868e96;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}
.store-tab:hover {
  color: #c1c2c5;
}
.store-tab.active {
  color: #4dabf7;
  border-bottom-color: #4dabf7;
}
.store-product-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  margin-bottom: 0.6rem;
  transition: background 0.15s;
}
.store-product-card:hover {
  background: rgba(255,255,255,0.06);
}
.store-product-icon {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 8px;
  background: linear-gradient(135deg, #4dabf7, #228be6);
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.store-product-info { flex: 1; min-width: 0; }
.store-product-name { font-weight: 700; font-size: 0.95rem; color: #e0e0e0; }
.store-product-meta { font-size: 0.8rem; color: #868e96; margin-top: 0.15rem; }
.store-product-price { font-weight: 800; color: #ffa94d; font-size: 1rem; white-space: nowrap; }
.store-product-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }
.order-status { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
.order-status-paid { background: rgba(81,207,102,0.15); color: #51cf66; }
.order-status-pending { background: rgba(255,169,77,0.15); color: #ffa94d; }
.order-status-no-stock { background: rgba(255,107,107,0.15); color: #ff6b6b; }
