/* ===== 灰白色主题变量 ===== */
:root {
  --color-bg: #f5f5f5;
  --color-bg-alt: #ebebeb;
  --color-surface: #ffffff;
  --color-border: #d4d4d4;
  --color-text: #2d2d2d;
  --color-text-muted: #6b6b6b;
  --color-primary: #4a4a4a;
  --color-primary-hover: #333333;
  --color-accent: #5c5c5c;
  --color-success: #4a7c59;
  --color-error: #a94442;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --radius: 8px;
  --radius-lg: 12px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.container-narrow {
  max-width: 440px;
}

.container-profile {
  max-width: 960px;
}

/* ===== Header ===== */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--color-text);
  font-weight: 700;
  font-size: 1.25rem;
}

.logo-icon {
  font-size: 1.5rem;
}

.logo-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 4px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-link {
  text-decoration: none;
  color: var(--color-text-muted);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  transition: color 0.2s, background 0.2s;
}

.nav-link:hover,
.nav-link.active {
  color: var(--color-text);
  background: var(--color-bg);
}

.nav-logout-form {
  display: inline;
  margin-left: 0.25rem;
}

/* ===== Main ===== */
.main-content {
  flex: 1;
}

/* ===== Home Hero + Status ===== */
.home-hero {
  padding: 2.25rem 0 1.5rem;
  background:
    radial-gradient(ellipse 80% 60% at 10% 0%, rgba(74, 74, 74, 0.06), transparent 55%),
    linear-gradient(180deg, var(--color-surface) 0%, var(--color-bg) 100%);
}

.home-hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.95fr);
  gap: 1.5rem;
  align-items: stretch;
}

.home-intro {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 1.75rem 1.75rem 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.home-kicker {
  display: inline-flex;
  align-self: flex-start;
  margin-bottom: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.home-title {
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.25;
  margin-bottom: 0.65rem;
}

.home-desc {
  color: var(--color-text-muted);
  font-size: 1rem;
  line-height: 1.65;
  margin-bottom: 1.35rem;
  max-width: 36rem;
}

.home-ip-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0.95rem 1.1rem;
  margin-bottom: 1.25rem;
}

.home-ip-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.75rem;
  margin-bottom: 0.55rem;
}

.home-ip-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text);
}

.home-ip-hint {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.home-ip-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.server-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}

.server-status-dot.loading {
  background: var(--color-border);
}

.server-status-dot.online {
  background: var(--color-success);
  box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.2);
}

.server-status-dot.offline {
  background: var(--color-error);
  box-shadow: 0 0 0 3px rgba(169, 68, 66, 0.2);
}

.home-ip-row code {
  font-size: 1.25rem;
  font-weight: 650;
  color: var(--color-primary);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius);
  letter-spacing: 0.01em;
}

.home-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-top: auto;
}

.home-status {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 1.35rem 1.35rem 1.15rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.home-status-head {
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--color-border);
}

.home-status-title {
  font-size: 1rem;
  font-weight: 650;
  margin-bottom: 0.35rem;
}

.home-status-sub {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
  min-height: 1.3em;
  word-break: break-word;
}

.home-status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  flex: 1;
}

.home-stat {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.9rem 0.85rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.3rem;
}

.home-stat-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

.home-stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--color-text);
}

.home-stat-value.online {
  color: var(--color-success);
}

.home-stat-value.offline {
  color: var(--color-error);
}

.home-stat-value-sm {
  font-size: 0.95rem;
  font-weight: 600;
  word-break: break-all;
}

/* 兼容旧类名（其他页面若引用） */
.hero-title { font-size: 2rem; font-weight: 700; }
.hero-desc { color: var(--color-text-muted); }
.status-value.online { color: var(--color-success); }
.status-value.offline { color: var(--color-error); }

/* ===== Sections ===== */
.section {
  padding: 1.75rem 0 2.75rem;
}

.section-alt {
  background: var(--color-bg-alt);
}

.section-title {
  font-size: 1.35rem;
  font-weight: 650;
  margin-bottom: 0.5rem;
}

.section-desc {
  color: var(--color-text-muted);
  margin-bottom: 1.25rem;
}

/* ===== Home Stats ===== */
.home-stats {
  padding-top: 0.5rem;
}

.home-stats-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.home-stats-heading {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem 0.85rem;
  min-width: 0;
}

.home-stats-title {
  font-size: 1.25rem;
  font-weight: 650;
  margin: 0;
}

.home-stats-desc {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* ===== Stats Charts ===== */
.stats-tabs {
  display: flex;
  gap: 0.45rem;
  flex-shrink: 0;
}

.line-range-tabs {
  display: flex;
  gap: 0.4rem;
  margin: 0;
}

.line-range-tabs[hidden] {
  display: none !important;
}

.line-range-tab {
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.line-range-tab:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.line-range-tab.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.stats-tab {
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.stats-tab:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.stats-tab.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.stats-view {
  display: none;
}

.stats-view.active {
  display: block;
}

.stats-chart-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 1.15rem 1.25rem;
  height: 360px;
  box-shadow: var(--shadow-sm);
}

.stats-empty {
  background: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: 16px;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--color-text-muted);
  gap: 0.5rem;
  padding: 2rem;
}

.stats-empty small {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.chart-placeholder-icon {
  font-size: 2.5rem;
}

/* ===== GitHub 风格热力图 ===== */
.gh-heatmap-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.gh-heatmap {
  position: relative;
  width: 100%;
  --gh-weeks: 52;
  --gh-gap: 4px;
  --gh-grid-height: 238px;
}

.gh-heatmap-tooltip {
  position: absolute;
  z-index: 5;
  padding: 0.4rem 0.55rem;
  border-radius: 6px;
  background: #24292f;
  color: #fff;
  font-size: 0.75rem;
  line-height: 1.35;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.gh-heatmap-tooltip[hidden] {
  display: none;
}

.gh-heatmap-months {
  display: grid;
  grid-template-columns: repeat(var(--gh-weeks), 1fr);
  gap: var(--gh-gap);
  margin-left: 2.5rem;
  margin-bottom: 0.5rem;
  min-height: 1rem;
}

.gh-month-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.gh-heatmap-body {
  display: flex;
  align-items: stretch;
  gap: 0.6rem;
}

.gh-heatmap-daylabels {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  gap: var(--gh-gap);
  width: 2.5rem;
  height: var(--gh-grid-height);
  flex-shrink: 0;
  font-size: 0.72rem;
  color: var(--color-text-muted);
}

.gh-heatmap-daylabels span {
  display: flex;
  align-items: center;
  line-height: 1;
  white-space: nowrap;
}

.gh-heatmap-grid {
  display: grid;
  grid-template-columns: repeat(var(--gh-weeks), 1fr);
  grid-template-rows: repeat(7, 1fr);
  gap: var(--gh-gap);
  flex: 1;
  height: var(--gh-grid-height);
  min-width: 0;
}

.gh-cell {
  width: 100%;
  height: 100%;
  border-radius: 3px;
  display: block;
  cursor: default;
  transition: outline 0.15s;
}

.gh-heatmap-grid .gh-cell[data-date]:hover {
  outline: 1px solid rgba(27, 31, 35, 0.35);
  outline-offset: 1px;
}

.gh-level-0 {
  background: #ebedf0;
}

.gh-level-1 {
  background: #9be9a8;
}

.gh-level-2 {
  background: #40c463;
}

.gh-level-3 {
  background: #30a14e;
}

.gh-level-4 {
  background: #216e39;
}

.gh-cell-empty {
  background: #ebedf0;
}

.gh-heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-top: 0.85rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.gh-heatmap-legend .gh-cell {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  cursor: default;
}

.gh-heatmap-legend .gh-cell:hover {
  outline: none;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-primary-hover);
}

.btn-secondary {
  background: var(--color-bg-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

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

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.btn-ghost:hover {
  background: var(--color-surface);
  color: var(--color-text);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-danger {
  background: var(--color-error);
  color: #fff;
}

.btn-danger:hover {
  background: #8b3634;
}

.btn-block {
  width: 100%;
}

/* ===== Auth ===== */
.auth-section {
  padding: 3rem 0;
}

.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-md);
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  text-align: center;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.auth-footer a {
  color: var(--color-primary);
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

/* ===== Forms ===== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--color-bg);
  color: var(--color-text);
  transition: border-color 0.2s, background 0.2s;
  width: 100%;
  box-sizing: border-box;
}

.form-group select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--color-text-muted) 50%),
    linear-gradient(135deg, var(--color-text-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 2px),
    calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2rem;
  cursor: pointer;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  background-color: var(--color-surface);
}

.form-group select:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ===== Alerts ===== */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: #fdf0f0;
  color: var(--color-error);
  border: 1px solid #f0c0c0;
}

.alert-success {
  background: #f0f7f2;
  color: var(--color-success);
  border: 1px solid #c0dcc8;
}

/* ===== Profile ===== */
.profile-section {
  padding-top: 2rem;
}

.profile-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.profile-sidebar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 76px;
}

.profile-sidebar-user {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-bottom: 1.25rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.profile-sidebar-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.75rem;
}

.profile-avatar-text {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-bg-alt);
  border: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-primary);
}

.profile-name {
  font-size: 1rem;
  font-weight: 600;
  word-break: break-all;
}

.profile-meta {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  word-break: break-all;
}

.profile-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.profile-nav-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.85rem;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

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

.profile-nav-item.active {
  background: var(--color-bg-alt);
  color: var(--color-text);
  font-weight: 500;
}

.profile-main {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  min-height: 400px;
}

.profile-panel-section {
  display: none;
}

.profile-panel-section.active {
  display: block;
}

.profile-panel-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.profile-panel-desc {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.profile-overview {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.profile-overview-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--color-border);
}

.profile-overview-item:last-child {
  border-bottom: none;
}

.profile-overview-label {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.profile-overview-value {
  font-weight: 500;
  font-size: 0.9rem;
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 400px;
}

.profile-settings-group {
  margin-bottom: 0.5rem;
}

.profile-settings-subtitle {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.profile-settings-divider {
  height: 1px;
  background: var(--color-border);
  margin: 1.75rem 0;
}

.profile-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.9rem;
}

.profile-item-card {
  border: 1px solid var(--color-border);
  border-radius: calc(var(--radius) + 2px);
  padding: 1rem 1.05rem;
  background: var(--color-surface, #fff);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.profile-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.profile-item-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.profile-item-qty {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--color-primary, #2f5d50);
}

.profile-item-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.profile-item-meta a {
  color: var(--color-primary);
}

.profile-item-meta code {
  font-size: 0.75rem;
  width: fit-content;
}

/* ===== Error Pages ===== */
.error-section {
  text-align: center;
  padding: 5rem 0;
}

.error-code {
  font-size: 5rem;
  font-weight: 700;
  color: var(--color-border);
  line-height: 1;
}

.error-message {
  font-size: 1.25rem;
  color: var(--color-text-muted);
  margin: 1rem 0 2rem;
}

/* ===== Footer ===== */
.site-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 1.5rem 0;
  margin-top: auto;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
}

.footer-copy {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.footer-server {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.footer-server code,
.server-ip {
  background: var(--color-bg);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* ===== Admin ===== */
.admin-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.admin-sidebar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 1rem;
}

.admin-sidebar-title {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.admin-sidebar-user {
  display: block;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.admin-nav-item {
  display: block;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius);
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.admin-nav-item:hover,
.admin-nav-item.active {
  background: var(--color-bg-alt);
  color: var(--color-text);
}

.admin-main {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.admin-panel-title {
  font-size: 1.35rem;
  margin-bottom: 0.35rem;
}

.admin-panel-desc {
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
}

.admin-form-section {
  margin-bottom: 1.5rem;
}

.admin-form-subtitle {
  font-size: 1rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.admin-form-divider {
  height: 1px;
  background: var(--color-border);
  margin: 1.75rem 0;
}

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

.radio-group {
  display: flex;
  gap: 1.25rem;
}

.radio-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.form-hint {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 0.35rem;
}

.admin-logo-preview {
  height: 36px;
  vertical-align: middle;
  margin-left: 0.5rem;
  border-radius: 4px;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
  padding: 0.75rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.admin-table th {
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.admin-inline-form {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-ban-form {
  flex-wrap: wrap;
}

.admin-ban-input {
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.8rem;
  min-width: 140px;
}

.admin-ban-reason {
  display: block;
  color: var(--color-text-muted);
  margin-top: 0.2rem;
}

.admin-muted {
  color: var(--color-text-muted);
}

.admin-items-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
}

.admin-card-form {
  padding: 1.1rem 1.15rem 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: calc(var(--radius) + 2px);
  background: var(--color-surface, #fff);
}

.admin-card-form .form-group {
  margin-bottom: 0.85rem;
}

.admin-card-form .btn {
  margin-top: 0.25rem;
}

@media (max-width: 900px) {
  .admin-items-grid {
    grid-template-columns: 1fr;
  }
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-success {
  background: rgba(74, 124, 89, 0.15);
  color: var(--color-success);
}

.badge-danger {
  background: rgba(169, 68, 66, 0.12);
  color: var(--color-error);
}

.badge-warning {
  background: rgba(201, 162, 39, 0.16);
  color: #8a6d12;
}

/* ===== Gallery ===== */
.gallery-page {
  padding-top: 1.5rem;
  padding-bottom: 2.75rem;
}

.gallery-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.gallery-header-actions {
  flex-shrink: 0;
}

.gallery-title {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.3rem;
}

.gallery-subtitle {
  color: var(--color-text-muted);
  font-size: 0.92rem;
}

.gallery-section-title {
  font-size: 1.1rem;
  font-weight: 650;
  margin-bottom: 0.75rem;
}

.gallery-upload-card,
.gallery-mine,
.gallery-public {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.15rem;
}

.gallery-hint {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.gallery-hint a {
  color: var(--color-primary);
}

.gallery-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.gallery-upload-form .form-group {
  margin-bottom: 0.9rem;
}

.gallery-upload-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.gallery-upload-form input[type="text"],
.gallery-upload-form input[type="file"],
.gallery-upload-form textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--color-surface);
}

.profile-gallery-block {
  margin-bottom: 1rem;
}

.profile-gallery-block:last-of-type {
  margin-bottom: 0.75rem;
}

.profile-gallery-link {
  margin-top: 0.5rem;
  font-size: 0.88rem;
  color: var(--color-text-muted);
}

.profile-gallery-link a {
  color: var(--color-primary);
}

.gallery-empty-sm {
  padding: 1.25rem 0.75rem;
}

.gallery-mine-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.gallery-mine-item {
  display: grid;
  grid-template-columns: 270px 1fr auto;
  gap: 0.9rem;
  align-items: center;
  padding: 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-bg);
}

.gallery-mine-thumb {
  width: 270px;
  height: 110px;
  border-radius: 8px;
  overflow: hidden;
  display: block;
  background: var(--color-bg-alt);
  flex-shrink: 0;
}

.gallery-mine-thumb img {
  width: 270px;
  height: 110px;
  object-fit: cover;
  display: block;
}

.gallery-mine-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.gallery-mine-meta strong {
  font-size: 0.95rem;
}

.gallery-mine-delete {
  flex-shrink: 0;
}

.gallery-reject {
  color: var(--color-error);
}

.gallery-time {
  color: var(--color-text-muted);
  font-size: 0.78rem;
}

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

.gallery-card {
  border: 1px solid var(--color-border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
}

.gallery-card-image {
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--color-bg-alt);
  overflow: hidden;
  width: 100%;
  padding: 0;
  border: 0;
  cursor: zoom-in;
  font: inherit;
  color: inherit;
  text-align: left;
}

.gallery-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
  pointer-events: none;
}

.gallery-card-image:hover img {
  transform: scale(1.04);
}

body.gallery-lightbox-open {
  overflow: hidden;
}

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.gallery-lightbox[hidden] {
  display: none !important;
}

.gallery-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 18, 22, 0.78);
  cursor: zoom-out;
}

.gallery-lightbox-dialog {
  position: relative;
  z-index: 1;
  max-width: min(96vw, 1100px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}

/* 关闭按钮相对「图片舞台」定位，保证始终在图片右上角 */
.gallery-lightbox-stage {
  position: relative;
  display: inline-block;
  max-width: 96vw;
  max-height: min(82vh, 900px);
  line-height: 0;
  overflow: hidden;
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  background: #111;
}

.gallery-lightbox-img {
  display: block;
  max-width: 96vw;
  max-height: min(82vh, 900px);
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transition: transform 0.08s ease-out;
  cursor: zoom-in;
  transform-origin: center center;
}

.gallery-lightbox-img.is-zoomed {
  cursor: zoom-out;
}

.gallery-lightbox-caption {
  color: #f5f5f5;
  font-size: 0.9rem;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  max-width: 90vw;
}

.gallery-lightbox-caption[hidden] {
  display: none !important;
}

.gallery-lightbox-hint {
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.75rem;
  text-align: center;
}

.gallery-lightbox-close {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  width: 2.15rem;
  height: 2.15rem;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.gallery-lightbox-close:hover {
  background: rgba(0, 0, 0, 0.78);
}

@media (max-width: 600px) {
  .gallery-lightbox-close {
    top: 0.35rem;
    right: 0.35rem;
  }

  .gallery-lightbox-hint {
    font-size: 0.7rem;
  }
}

.gallery-card-body {
  padding: 0.85rem 0.95rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.gallery-card-title {
  font-size: 0.98rem;
  font-weight: 650;
  line-height: 1.3;
}

.gallery-card-desc {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gallery-card-foot {
  margin-top: auto;
  padding-top: 0.45rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.gallery-empty {
  text-align: center;
  color: var(--color-text-muted);
  padding: 2rem 1rem;
}

.gallery-empty small {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.82rem;
}

.gallery-admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1.15rem;
}

.gallery-admin-tabs .stats-tab {
  text-decoration: none;
}

.gallery-admin-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.gallery-admin-item {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 1rem;
  padding: 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-bg);
}

.gallery-admin-thumb {
  display: block;
  width: 140px;
  height: 105px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--color-bg-alt);
}

.gallery-admin-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-admin-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.gallery-admin-desc {
  color: var(--color-text-muted);
  font-size: 0.88rem;
  margin-bottom: 0.35rem;
}

.gallery-admin-meta {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 0.65rem;
}

.gallery-admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.gallery-admin-reject-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.footer-extra {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* ===== Live Chat Page ===== */
.chat-page {
  padding-top: 1.5rem;
  padding-bottom: 2.5rem;
}

.chat-layout {
  max-width: 820px;
}

.chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.chat-title {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.chat-subtitle {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.chat-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.chat-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-border);
  flex-shrink: 0;
}

.chat-live-dot.connecting {
  background: #c9a227;
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.18);
}

.chat-live-dot.online {
  background: var(--color-success);
  box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.2);
}

.chat-live-dot.offline {
  background: var(--color-error);
  box-shadow: 0 0 0 3px rgba(169, 68, 66, 0.15);
}

.chat-panel {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.chat-messages {
  height: min(70vh, 620px);
  overflow-y: auto;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.chat-item {
  display: grid;
  grid-template-columns: 4.5rem auto 1fr;
  gap: 0.45rem 0.65rem;
  align-items: baseline;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
}

.chat-item:hover {
  background: var(--color-bg);
}

.chat-time {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.chat-type-tag {
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  background: var(--color-bg-alt);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.chat-type-chat .chat-type-tag {
  background: rgba(74, 74, 74, 0.1);
  color: var(--color-primary);
}

.chat-type-join .chat-type-tag,
.chat-type-advancement .chat-type-tag {
  background: rgba(74, 124, 89, 0.14);
  color: var(--color-success);
}

.chat-type-quit .chat-type-tag,
.chat-type-death .chat-type-tag {
  background: rgba(169, 68, 66, 0.12);
  color: var(--color-error);
}

.chat-type-broadcast .chat-type-tag,
.chat-type-system .chat-type-tag {
  background: rgba(90, 110, 160, 0.12);
  color: #4a5f8a;
}

.chat-type-join .chat-text,
.chat-type-quit .chat-text,
.chat-type-death .chat-text,
.chat-type-broadcast .chat-text,
.chat-type-advancement .chat-text,
.chat-type-system .chat-text {
  color: var(--color-text-muted);
  font-style: italic;
}

.chat-text {
  font-size: 0.95rem;
  color: var(--color-text);
  word-break: break-word;
  line-height: 1.45;
  font-family: ui-monospace, 'Cascadia Mono', 'Segoe UI Mono', Consolas, monospace;
}

.chat-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  color: var(--color-text-muted);
  pointer-events: none;
  text-align: center;
  padding: 1.5rem;
}

.chat-empty[hidden] {
  display: none !important;
}

.chat-empty small {
  font-size: 0.8rem;
}

.chat-footer-note {
  margin-top: 0.85rem;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.chat-footer-note a {
  color: var(--color-primary);
}

.chat-type-horn .chat-type-tag {
  background: rgba(201, 162, 39, 0.2);
  color: #8a6d12;
}

.chat-type-horn .chat-text {
  font-weight: 500;
}

.chat-compose {
  margin-top: 0.85rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface, #fff);
}

.chat-compose-guest {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.chat-compose-guest p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.92rem;
}

.chat-compose-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  font-size: 0.88rem;
  margin-bottom: 0.65rem;
  color: var(--color-text-muted);
}

.chat-compose-meta strong {
  color: var(--color-primary);
}

.chat-compose-as code {
  font-size: 0.85rem;
}

.chat-compose-form {
  display: flex;
  gap: 0.6rem;
}

.chat-compose-form input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.chat-compose-form input[type="text"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-compose-hint {
  margin: 0.55rem 0 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.chat-compose-error {
  margin: 0.45rem 0 0;
  font-size: 0.85rem;
  color: var(--color-error);
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .home-hero-inner {
    grid-template-columns: 1fr;
  }

  .home-status {
    min-height: auto;
  }
}

@media (max-width: 600px) {
  .home-hero {
    padding: 1.25rem 0 0.75rem;
  }

  .home-intro,
  .home-status {
    padding: 1.2rem;
    border-radius: 14px;
  }

  .home-title {
    font-size: 1.55rem;
  }

  .home-ip-row code {
    font-size: 1.05rem;
  }

  .home-status-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
  }

  .home-stats-header {
    align-items: stretch;
  }

  .stats-tabs {
    width: 100%;
  }

  .stats-tab {
    flex: 1;
    text-align: center;
  }

  .header-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 0.75rem 0;
    gap: 0.5rem;
  }

  .chat-item {
    grid-template-columns: 4rem auto 1fr;
    gap: 0.3rem 0.45rem;
  }

  .chat-text {
    grid-column: 1 / -1;
  }

  .chat-messages {
    height: min(72vh, 560px);
  }

  .gallery-form-row {
    grid-template-columns: 1fr;
  }

  .gallery-mine-item {
    grid-template-columns: 1fr;
  }

  .gallery-mine-thumb,
  .gallery-mine-thumb img {
    width: 100%;
    max-width: 270px;
    height: 110px;
  }

  .gallery-mine-item form {
    grid-column: 1 / -1;
  }

  .gallery-admin-item {
    grid-template-columns: 1fr;
  }

  .gallery-admin-thumb {
    width: 100%;
    height: 180px;
  }

  .gh-heatmap-wrap {
    overflow-x: auto;
  }

  .gh-heatmap {
    --gh-grid-height: 154px;
    --gh-gap: 3px;
    min-width: 640px;
  }

  .gh-heatmap-daylabels {
    width: 2.1rem;
    font-size: 0.65rem;
  }

  .gh-heatmap-months {
    margin-left: 2.1rem;
  }

  .profile-layout {
    grid-template-columns: 1fr;
  }

  .profile-sidebar {
    position: static;
  }

  .profile-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .profile-nav-item {
    flex: 1 1 auto;
    text-align: center;
    min-width: calc(50% - 0.25rem);
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
  }

  .admin-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}