/* ============================================================
   Oln Blog — Custom Admin Panel Theme
   Minimal warm-carbon palette with amber accent
   ============================================================ */

:root {
  color-scheme: dark;
  --bg-base: #141311;
  --bg-surface: #1b1a17;
  --bg-elevated: #22211d;
  --bg-overlay: #2a2924;
  --bg-hover: #32302b;
  --bg-active: #3d3a34;
  --border: #33312b;
  --border-light: #403d36;
  --border-focus: #d88a3d;
  --text-primary: #ece9e3;
  --text-secondary: #a8a49a;
  --text-tertiary: #6f6b61;
  --text-muted: #4d4a42;
  --accent: #e0a458;
  --accent-bright: #f0c584;
  --accent-deep: #c97f35;
  --accent-glow: rgba(224, 164, 88, 0.13);
  --accent-glow-strong: rgba(224, 164, 88, 0.26);
  --success: #4fb566;
  --success-bg: rgba(52, 211, 153, 0.1);
  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.1);
  --error: #f87171;
  --error-bg: rgba(248, 113, 113, 0.1);
  --info: #60a5fa;
  --info-bg: rgba(96, 165, 250, 0.1);
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.65);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Noto Sans SC', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', 'Cascadia Code', Menlo, monospace;
  --sidebar-width: 260px;
  --header-height: 60px;
  --transition: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

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

button, input, textarea, select { font-family: inherit; font-size: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

:focus:not(:focus-visible) { outline: none; }

html, body, #app {
  height: 100%;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg-base);
  color: var(--text-primary);
  overflow: hidden;
}

::selection { background: var(--accent-glow-strong); color: var(--accent-bright); }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-active); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ===== Login Page ===== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, rgba(224, 164, 88, 0.06) 0%, transparent 55%);
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  width: 400px;
  max-width: 90vw;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  margin: 0 auto 20px;
  object-fit: cover;
  border: 2px solid var(--border);
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-tertiary);
  margin-bottom: 32px;
}

.login-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 28px;
  background: linear-gradient(135deg, var(--accent-deep), var(--accent));
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 2px 12px rgba(224, 164, 88, 0.3);
  text-decoration: none;
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(224, 164, 88, 0.45);
  filter: brightness(1.1);
}

.login-btn svg { width: 18px; height: 18px; }

.login-footer {
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== App Layout ===== */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-close {
  display: none;
}
.mobile-header,
.mobile-overlay { display: none; }

.sidebar-header {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  object-fit: cover;
  border: 1px solid var(--border);
}

.sidebar-brand {
  flex: 1;
  min-width: 0;
}

.sidebar-brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 16px 10px 6px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
}

.sidebar-nav-item:hover {
  background: var(--bg-overlay);
  color: var(--text-primary);
}

.sidebar-nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
}

.sidebar-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent-deep);
  border-radius: 0 2px 2px 0;
}

.sidebar-nav-item { position: relative; }

.sidebar-nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-nav-item.active svg { opacity: 1; }

.sidebar-nav-item .badge {
  margin-left: auto;
  background: var(--bg-overlay);
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: var(--radius-full);
}

.sidebar-nav-item.active .badge {
  background: var(--accent-glow-strong);
  color: var(--accent);
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}

.sidebar-user:hover { background: var(--bg-overlay); }

.sidebar-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  background: var(--accent-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  overflow: hidden;
}

.sidebar-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-logout {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.sidebar-logout svg { width: 14px; height: 14px; }

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

#page-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.main-header {
  height: var(--header-height);
  min-height: var(--header-height);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  position: relative;
  z-index: 10;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02);
}

.main-header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.main-header-subtitle {
  font-size: 13px;
  color: var(--text-tertiary);
}

.main-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 100%;
}

.media-tabs + .btn { margin-left: 2px; }

.main-body {
  flex: none;
  padding: 28px;
  min-width: 0;
}

.main-body > * { max-width: 1180px; }

.card { max-width: 1180px; }

#set-desc, #set-url, #set-footer, #editor-desc { max-width: 640px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
}

.btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.btn:active { transform: translateY(0) scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-deep), var(--accent));
  color: #fff;
  box-shadow: 0 2px 10px rgba(224, 164, 88, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  border-color: rgba(224, 164, 88, 0.4);
}

.btn-primary:hover {
  box-shadow: 0 4px 18px rgba(224, 164, 88, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.btn-primary:active { transform: translateY(0) scale(0.97); }

.btn-secondary {
  background: var(--bg-overlay);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--text-tertiary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-overlay);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--error-bg);
  color: var(--error);
  border-color: rgba(248, 113, 113, 0.22);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.18);
  border-color: var(--error);
}

.btn-sm {
  min-height: 30px;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 8px;
}

.btn-sm svg { width: 12px; height: 12px; }

.btn-icon {
  padding: 7px;
  border-radius: var(--radius-sm);
}

.btn[disabled] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ===== Cards ===== */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.card-title svg { width: 16px; height: 16px; color: var(--accent); }

.card-body { padding: 22px; }

/* ===== Record table (nav / links) ===== */
.record-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.record-list-head {
  display: grid;
  align-items: center;
  gap: 12px 16px;
  padding: 10px 16px;
  background: var(--bg-overlay);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
.record-list-head--nav { grid-template-columns: 34px minmax(0, 1.1fr) minmax(0, 1.4fr) auto; }
.record-list-head--link { grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1.6fr) minmax(0, 1.4fr) auto; }
.record-list-head .zone-head-4,
.record-list-head .zone-head-5 { text-align: right; }

.record-list-body > .record-row:first-child { border-top: none; }

.record-row {
  display: grid;
  gap: 12px 16px;
  padding: 12px 16px;
  align-items: center;
}
.record-row--nav { grid-template-columns: 34px minmax(0, 1.1fr) minmax(0, 1.4fr) auto; }
.record-row--link { grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1.6fr) minmax(0, 1.4fr) auto; }
.record-row--link .rec-desc input { font-size: 13px; }

.record-row + .record-row { border-top: 1px solid var(--border); }
.record-row:hover { background: rgba(224, 164, 88, 0.03); }

.record-card-index {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent-glow);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.rec-field label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 5px;
  letter-spacing: 0.02em;
  font-weight: 500;
}

.rec-field input {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.rec-field input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.rec-field input::placeholder { color: var(--text-muted); }

.record-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

.nav-external-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--bg-surface);
  transition: border-color var(--transition), color var(--transition);
}

.nav-external-label:hover { border-color: var(--accent-deep); }
.nav-external-label input { accent-color: var(--accent); width: 13px; height: 13px; margin: 0; }

.btn-danger { color: var(--error); }
.btn-danger:hover { background: var(--error-bg); color: var(--error); }

.record-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.8;
}
.record-empty-hint { font-size: 12px; color: var(--text-tertiary); margin-top: 4px; }

/* ===== Comment Management ===== */
.comment-manage-item {
  display: flex;
  gap: 16px;
  padding: 16px;
  align-items: flex-start;
  border-bottom: 1px solid var(--border);
}
.comment-manage-item:last-child { border-bottom: none; }
.comment-manage-item:hover { background: rgba(224, 164, 88, 0.03); }

.comment-manage-main { flex: 1; min-width: 0; }
.comment-manage-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-tertiary);
}
.comment-manage-name { font-weight: 600; color: var(--text-primary); font-size: 13px; }
.comment-manage-site { color: var(--accent); text-decoration: none; }
.comment-manage-site:hover { text-decoration: underline; }
.comment-manage-page {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-overlay);
  border-radius: var(--radius-xs);
  padding: 2px 8px;
  margin-left: auto;
}
.comment-manage-body {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-primary);
  overflow-wrap: break-word;
  word-break: break-word;
}
.comment-ai {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-tertiary);
  border-left: 2px solid var(--border);
  padding-left: 8px;
}

.comment-manage-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
.comment-status {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 100px;
  white-space: nowrap;
}
.status-approved { background: var(--success-bg); color: var(--success); }
.status-rejected { background: var(--error-bg); color: var(--error); }
.status-pending { background: var(--warning-bg); color: var(--warning); }
.comment-manage-actions { display: flex; gap: 6px; }

@media (max-width: 720px) {
  .comment-manage-item { flex-direction: column; }
  .comment-manage-side { flex-direction: row; align-items: center; justify-content: space-between; width: 100%; }
  .comment-manage-page { margin-left: 0; }
}

/* ===== Image Field (settings) ===== */
.img-field {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  margin-bottom: 14px;
}

.img-field-preview {
  width: 88px;
  height: 88px;
  border-radius: var(--radius);
  border: 1px dashed var(--border-light);
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.img-field-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.img-field-info { flex: 1; min-width: 0; }

.img-field-btns {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

.img-field .form-input { max-width: none; }

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent-deep), transparent);
  opacity: 0.6;
}

.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg { width: 20px; height: 20px; }

.stat-icon.amber { background: var(--accent-glow); color: var(--accent); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.yellow { background: var(--warning-bg); color: var(--warning); }
.stat-icon.blue { background: var(--info-bg); color: var(--info); }

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* ===== Table ===== */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.015);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-primary);
  vertical-align: middle;
  transition: background var(--transition);
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: rgba(224, 164, 88, 0.04); }

tr:last-child td { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

td .btn + .btn,
td button + button { margin-left: 6px; }

/* ===== Post List ===== */
.post-list-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  margin: 0 -8px;
  border-radius: var(--radius);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}

.post-list-item:last-child { border-bottom: none; }
.post-list-item:hover { background: rgba(224, 164, 88, 0.04); }

.post-list-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 3px;
  transition: color var(--transition);
}

.post-list-item:hover .post-list-title { color: var(--accent-bright); }

.post-list-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 12px;
}

.post-list-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-muted);
}

.post-list-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
}

.post-list-item:hover .post-list-actions { opacity: 1; }

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 18px 6px 4px;
  margin-top: 10px;
  border-top: 1px solid var(--border);
  justify-content: center;
}
.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.page-btn:hover:not(:disabled):not(.active) {
  border-color: var(--accent-deep);
  color: var(--accent);
}
.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-ellipsis { color: var(--text-muted); font-size: 13px; padding: 0 2px; }
.page-info {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 8px;
  font-variant-numeric: tabular-nums;
}

/* ===== Tags ===== */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(224, 164, 88, 0.18);
  line-height: 1.5;
}

.tag-remove {
  cursor: pointer;
  opacity: 0.6;
  transition: opacity var(--transition);
  display: inline-flex;
  padding: 0 1px;
}

.tag-remove:hover { opacity: 1; color: var(--error); }

.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.tag-grid-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
}

.tag-grid-item:hover {
  border-color: var(--accent-deep);
  background: var(--accent-glow);
  transform: translateY(-1px);
}

.tag-count {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
  white-space: nowrap;
}

.nav-row-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

/* ===== Form ===== */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-help {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.6;
}

.card-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

.provider-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
  background: var(--bg-surface);
}
.provider-block[hidden] { display: none; }

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  min-height: 40px;
  padding: 9px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
}

.form-input:hover,
.form-textarea:hover,
.form-select:hover {
  border-color: var(--border-light);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--accent-deep);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--bg-overlay);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-input:-webkit-autofill,
.form-input:-webkit-autofill:hover,
.form-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text-primary);
  -webkit-box-shadow: 0 0 0 1000px var(--bg-elevated) inset;
  transition: background-color 6000s ease-in-out 0s;
}

input[type='date'], input[type='time'] {
  appearance: none;
  -webkit-appearance: none;
  min-height: 40px;
  cursor: pointer;
}

input[type='date']::-webkit-calendar-picker-indicator {
  filter: invert(0.6);
  cursor: pointer;
}

input[type='checkbox'] {
  accent-color: var(--accent-deep);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.form-textarea {
  resize: vertical;
  min-height: 140px;
  line-height: 1.65;
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6b90' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

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

.main-body > .form-group > .form-input { max-width: 640px; }

/* ===== Markdown Editor ===== */
.editor-container {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 7px 12px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 5;
}

.editor-toolbar .edit-tools { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }

.editor-toolbar .toolbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.editor-toolbar .divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 6px;
}

.editor-toolbar button {
  padding: 6px 8px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 30px;
}

.editor-toolbar button:hover {
  background: var(--accent-glow);
  color: var(--accent);
}

.editor-toolbar button:active { background: var(--accent-glow-strong); }

.editor-toolbar button svg { width: 15px; height: 15px; }

.editor-toolbar .toolbar-seg {
  display: inline-flex;
  align-items: center;
  background: var(--bg-overlay);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
  gap: 2px;
}

.editor-toolbar .toolbar-seg button {
  min-width: 30px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.editor-toolbar .toolbar-seg button svg { width: 13px; height: 13px; }

.editor-toolbar .toolbar-seg button:hover { color: var(--text-primary); }
.editor-toolbar .toolbar-seg button.active { background: var(--accent); color: #fff; }

.editor-toolbar .zoom-label {
  display: inline-flex;
  align-items: center;
  margin-right: 2px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 2px;
}

.editor-body {
  display: flex;
  align-items: stretch;
  --editor-min: 55vh;
  min-height: var(--editor-min);
}

.editor-body.edit-only .editor-preview { display: none; }
.editor-body.preview-only .editor-write { display: none; }

/* 缩放：调整编辑区基准高度（页面随内容整体滚动） */
.editor-body.zoom-lg { --editor-min: 72vh; }
.editor-body.zoom-xl { --editor-min: 92vh; }

.editor-write {
  flex: 1 1 50%;
  min-width: 0;
  border-right: 1px solid var(--border);
  display: flex;
}

.editor-body.preview-only .editor-write { display: none; }
.editor-body.edit-only .editor-write { flex: 1 1 100%; border-right: none; }

.editor-write textarea {
  width: 100%;
  padding: 18px;
  background: transparent;
  border: none;
  outline: none;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.75;
  color: var(--text-primary);
  tab-size: 2;
  caret-color: var(--accent);
  min-height: calc(var(--editor-min) - 36px);
  overflow-y: visible;
}

.editor-write textarea::placeholder { color: var(--text-muted); }

.editor-preview {
  flex: 1 1 50%;
  min-width: 0;
  padding: 18px;
  overflow-x: auto;
  background: rgba(255, 255, 255, 0.012);
}

.editor-preview h1 { font-size: 1.6em; margin: 0.6em 0 0.4em; font-weight: 700; color: var(--text-primary); }
.editor-preview h2 { font-size: 1.3em; margin: 0.6em 0 0.3em; font-weight: 600; color: var(--text-primary); }
.editor-preview h3 { font-size: 1.1em; margin: 0.5em 0 0.3em; font-weight: 600; color: var(--text-primary); }
.editor-preview p { margin-bottom: 0.8em; line-height: 1.7; }
.editor-preview a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.editor-preview code { background: var(--bg-overlay); padding: 2px 6px; border-radius: var(--radius-xs); font-size: 0.9em; font-family: var(--font-mono); }
.editor-preview pre { background: var(--bg-base); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; overflow-x: auto; margin-bottom: 1em; }
.editor-preview pre code { background: none; padding: 0; }
.editor-preview blockquote { border-left: 3px solid var(--accent-deep); padding-left: 14px; color: var(--text-secondary); margin-bottom: 0.8em; }
.editor-preview ul, .editor-preview ol { padding-left: 22px; margin-bottom: 0.8em; }
.editor-preview li { margin-bottom: 4px; line-height: 1.6; }
.editor-preview hr { border: none; border-top: 1px solid var(--border); margin: 1.5em 0; }
.editor-preview img { max-width: 100%; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.editor-preview table { border-collapse: collapse; width: 100%; margin-bottom: 1em; }
.editor-preview th, .editor-preview td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.editor-preview th { background: var(--bg-elevated); font-weight: 600; }

.editor-toggle {
  display: flex;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 0 10px;
}

.editor-toggle button {
  padding: 8px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}

.editor-toggle button:hover { color: var(--text-primary); }
.editor-toggle button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  margin: 8px 0;
}

.empty-state svg {
  width: 44px;
  height: 44px;
  margin-bottom: 14px;
  opacity: 0.35;
  color: var(--accent);
}

.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}

.empty-state-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* ===== Search Bar ===== */
.search-bar {
  position: relative;
  max-width: 320px;
}

.search-bar svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-bar input {
  width: 100%;
  min-height: 36px;
  padding: 8px 12px 8px 36px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.search-bar input:focus {
  border-color: var(--accent-deep);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: var(--bg-overlay);
}

.search-bar input::placeholder { color: var(--text-muted); }

/* ===== Modal / Dialog ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 16, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(224, 164, 88, 0.08);
  width: 480px;
  max-width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.22s cubic-bezier(0.32, 0.72, 0.35, 1);
}

.modal-header {
  padding: 20px 24px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-title svg { width: 17px; height: 17px; color: var(--accent); }

.modal-close {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover { background: var(--bg-overlay); color: var(--text-primary); }
.modal-close svg { width: 18px; height: 18px; }

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 24px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  background: var(--bg-surface);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 18px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight 0.2s ease;
  min-width: 280px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }
.toast.warning { border-left: 3px solid var(--warning); }

.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast.success svg { color: var(--success); }
.toast.error svg { color: var(--error); }
.toast.warning svg { color: var(--warning); }

@keyframes slideInRight { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ===== Media Grid ===== */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.media-item {
  aspect-ratio: 1;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
}

.media-item:hover {
  border-color: var(--accent-deep);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.media-item:active { transform: translateY(0) scale(0.98); }

.media-item-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.media-item img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-item-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 10px 8px;
  font-size: 11px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  pointer-events: none;
}

.media-tabs {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.media-tab {
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.media-tab:hover { color: var(--text-primary); }

.media-tab.active {
  background: var(--accent);
  color: #fff;
}

.picker-upload {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 14px;
  transition: all var(--transition);
  background: var(--bg-surface);
}

.picker-upload:hover { border-color: var(--accent-deep); background: var(--accent-glow); }

.picker-modal { width: min(640px, 92vw); max-height: 80vh; display: flex; flex-direction: column; }

.picker-modal .modal-body { overflow-y: auto; }

.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}

.upload-zone {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-lg);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-surface);
}

.upload-zone:hover {
  border-color: var(--accent-deep);
  background: var(--accent-glow);
}

.upload-zone:active { transform: scale(0.995); }

.upload-zone svg { width: 34px; height: 34px; color: var(--accent); opacity: 0.6; margin-bottom: 10px; }
.upload-zone-text { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; font-weight: 500; }
.upload-zone-hint { font-size: 12px; color: var(--text-muted); }

/* ===== Settings ===== */
.settings-section {
  margin-bottom: 32px;
}

.settings-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.settings-section-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ===== Loading ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ===== Confirm Dialog ===== */
.confirm-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ===== Dropdown ===== */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  padding: 4px;
  z-index: 100;
  animation: fadeIn 0.1s ease;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
}

.dropdown-item:hover {
  background: var(--bg-overlay);
  color: var(--text-primary);
}

.dropdown-item.danger { color: var(--error); }
.dropdown-item.danger:hover { background: var(--error-bg); }
.dropdown-item svg { width: 14px; height: 14px; }

.dropdown-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .app-layout { flex-direction: column; }
  .sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    width: 280px;
    min-width: 280px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close {
    display: flex;
    justify-content: flex-end;
    padding: 10px 12px 0;
  }
  .mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 199;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.25s ease;
  }
  .mobile-overlay.show { display: block; opacity: 1; }
  .mobile-header {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 52px;
    flex-shrink: 0;
    padding: 0 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
  }
  .mobile-header-brand {
    flex: 1;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mobile-header-brand span { font-size: 11px; color: var(--text-muted); font-weight: 500; }
  .main-content { overflow: hidden; }
  .main-body { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .nav-row-actions { justify-content: flex-start; }
  .editor-body { flex-direction: column; align-items: stretch; --editor-min: 45vh; }
  .editor-write { flex: none; width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .editor-preview { flex: none; width: 100%; }
  .toolbar-right { margin-left: 0; width: 100%; justify-content: flex-end; margin-top: 6px; }
  .main-header { padding: 0 16px; gap: 10px; flex-wrap: wrap; height: auto; min-height: var(--header-height); padding-top: 8px; padding-bottom: 8px; }
  .main-header-subtitle { display: none; }
  .record-list-head { display: none; }
  .record-row--nav,
  .record-row--link {
    grid-template-columns: 28px minmax(0, 1fr) auto;
    gap: 10px 12px;
    padding: 14px 14px;
  }
  .record-row--nav .rec-field:nth-child(3),
  .record-row--link .rec-field:nth-child(3) { grid-column: 2 / -1; grid-row: 2; }
  .record-row--link .rec-field:nth-child(4) { grid-column: 2 / -1; grid-row: 3; }
  .record-row--link .record-row-actions { grid-column: 3; grid-row: 1; }
  .record-row--nav .record-row-actions { grid-column: 3; grid-row: 1; }
  .nav-external-label { padding: 4px 8px; }
  .record-row-actions { justify-content: flex-end; gap: 8px; }
  .img-field { flex-direction: column; }
  .img-field-preview { width: 100%; height: 120px; }
  .post-list-item { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px 14px; }
  .post-list-actions { opacity: 1; justify-content: flex-end; margin-top: 2px; }
  .post-list-meta { flex-wrap: wrap; gap: 8px 10px; }
  .pagination { padding: 14px 0 2px; gap: 4px; }
  .page-info { order: 99; width: 100%; text-align: center; margin: 4px 0 0; }
  .search-bar { flex: 1; min-width: 0; max-width: none; }
  .main-header-actions { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .modal { max-height: 90vh; }
}
