@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;600&display=swap');

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

:root {
  --dirt: #8B6914;
  --dirt-dark: #6B4F12;
  --dirt-light: #A07D1A;
  --stone: #8A8A8A;
  --stone-dark: #6E6E6E;
  --stone-light: #A8A8A8;
  --grass: #5D8C2E;
  --grass-dark: #4A7024;
  --grass-light: #8BC34A;
  --wood: #BC9862;
  --wood-dark: #8B7244;
  --wood-light: #D4B07A;
  --bg: #3A3A3A;
  --bg-light: #454545;
  --card: #484848;
  --card-hover: #525252;
  --text: #F2F2F2;
  --text-secondary: #C8C8C8;
  --text-muted: #9A9A9A;
  --border: #666;
  --danger: #E57373;
  --danger-light: #EF9A9A;
  --success: #81C784;
  --gold: #FFE566;
  --diamond: #80DEEA;
  --redstone: #FF6B6B;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --pixel-border: 2px solid #333;
  --page-bg: #323232;
  --tab-bar-from: #2A2A2A;
  --shadow-block: #1a1a1a;
  --header-drop: #111;
  --divider: rgba(255,255,255,0.06);
  --inset-hi: rgba(255,255,255,0.08);
  --inset-lo: rgba(0,0,0,0.3);
  --panel-dim: rgba(0,0,0,0.15);
  --code-bg: rgba(0,0,0,0.25);
  --hard-border: #222;
  --video-bg: #111;
  --bubble-bg: rgba(62,62,62,0.9);
  --nav-bg: rgba(0,0,0,0.28);
  --hover-wash: rgba(255,255,255,0.05);
  --accent-soft: rgba(93,140,46,0.12);
  color-scheme: dark;
}

html[data-theme="light"] {
  --dirt: #C9A24A;
  --dirt-dark: #B08A32;
  --dirt-light: #E2C46A;
  --stone: #E4DFD4;
  --stone-dark: #D4CFC4;
  --stone-light: #F3EFE6;
  --grass: #4F8A22;
  --grass-dark: #3F7018;
  --grass-light: #2F6B14;
  --wood: #A67C42;
  --wood-dark: #8A6434;
  --wood-light: #6B4E28;
  --bg: #F3EEE3;
  --bg-light: #FBF8F1;
  --card: #FFFDF8;
  --card-hover: #F4EFE4;
  --text: #2C2A26;
  --text-secondary: #5C574E;
  --text-muted: #8A8478;
  --border: #C9C2B4;
  --danger: #C94A4A;
  --danger-light: #E57373;
  --success: #3E8F42;
  --gold: #9A6B08;
  --diamond: #1A8A9C;
  --redstone: #D03A3A;
  --pixel-border: 2px solid #C2BAA8;
  --page-bg: #E8E2D4;
  --tab-bar-from: #DDD6C8;
  --shadow-block: #C8C0AE;
  --header-drop: #B8B09C;
  --divider: rgba(80,70,50,0.12);
  --inset-hi: rgba(255,255,255,0.75);
  --inset-lo: rgba(80,70,50,0.12);
  --panel-dim: rgba(80,70,50,0.06);
  --code-bg: rgba(80,70,50,0.08);
  --hard-border: #C2BAA8;
  --video-bg: #1A1A1A;
  --bubble-bg: #FFFDF8;
  --nav-bg: rgba(80,70,50,0.06);
  --hover-wash: rgba(80,70,50,0.06);
  --accent-soft: rgba(79,138,34,0.12);
  color-scheme: light;
}

html, body {
  height: 100%;
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

#app { display: flex; flex-direction: column; height: 100%; width: 100%; max-width: 720px; margin: 0 auto; position: relative; background: var(--bg); }

.content-shell { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; }

.sidebar-brand { display: none; }

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

/* Chat UI */
.chat-top { padding: 10px 14px; border-bottom: 1px solid var(--divider); background: var(--panel-dim); }
.chat-peer { display: flex; align-items: center; gap: 10px; }
.chat-peer-name { font-weight: 500; font-size: 14px; color: var(--grass-light); }
.chat-list { padding: 10px 14px 0; height: calc(100vh - 200px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.chat-bubble { max-width: 80%; margin: 8px 0; padding: 10px 10px; border: var(--pixel-border); background: var(--bubble-bg); box-shadow: inset 1px 1px 0 var(--inset-hi); }
.chat-bubble.me { margin-left: auto; background: rgba(93,140,46,0.14); border-color: rgba(124,179,66,0.35); }
.chat-text { font-size: 14px; white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.chat-time { margin-top: 4px; font-size: 10px; color: var(--text-muted); }
.chat-input-wrap { display: flex; gap: 8px; padding: 10px 14px; border-top: var(--pixel-border); background: var(--card); position: sticky; bottom: 0; }
.chat-input-wrap input { flex: 1; }

/* Desktop layout */
@media (min-width: 900px) {
  html, body { background: var(--page-bg); }

  #app {
    flex-direction: row;
    max-width: 1200px;
    height: 100vh;
    margin: 0 auto;
    border-left: var(--pixel-border);
    border-right: var(--pixel-border);
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
  }

  #tab-bar {
    flex-direction: column;
    width: 180px;
    flex-shrink: 0;
    border-top: none;
    border-right: var(--pixel-border);
    padding: 12px 0;
    position: relative;
  }

  .sidebar-brand {
    display: block;
    text-align: center;
    color: var(--gold);
    font-size: 16px;
    font-weight: 600;
    padding: 8px 0 16px;
    text-shadow: none;
    letter-spacing: 1px;
  }

  .tab {
    flex: 0;
    flex-direction: row;
    justify-content: flex-start;
    gap: 10px;
    padding: 12px 20px;
    font-size: 12px;
    border-left: 3px solid transparent;
    border-bottom: none;
  }

  .tab.active { border-left-color: var(--grass-light); background: rgba(93,140,46,0.1); }

  .content-shell { flex: 1; }

  main { padding-bottom: 16px; }

  .post-card { margin: 10px 16px; }

  .mc-banner { padding: 24px 20px; }
  .mc-banner h2 { font-size: 22px; }

  .stats-bar { margin: 0 16px 8px; }

  /* Friends split view */
  .friends-desktop {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: calc(100vh - 52px);
    min-height: 400px;
  }

  .friends-panel {
    border-right: var(--pixel-border);
    overflow-y: auto;
    background: var(--panel-dim); }
  }

  .chat-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--bg);
  }

  .chat-panel .chat-list {
    flex: 1;
    height: auto;
    min-height: 0;
  }

  .chat-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 13px;
  }

  .friend-row { cursor: pointer; }
  .friend-row.active { background: rgba(93,140,46,0.15); border-color: var(--grass-dark); }

  .mobile-chat { height: calc(100vh - 52px); display: flex; flex-direction: column; }
  .mobile-chat .chat-list { flex: 1; height: auto; }

  .form-page { max-width: 640px; margin: 0 auto; }
  .login-form { max-width: 400px; }
}

@media (min-width: 1400px) {
  #app { max-width: 1400px; }
  .friends-desktop { grid-template-columns: 380px 1fr; }
}

/* Header - MC inventory bar style */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  background: linear-gradient(180deg, var(--stone) 0%, var(--stone-dark) 100%);
  border-bottom: var(--pixel-border);
  position: sticky; top: 0; z-index: 100; min-height: 48px;
  box-shadow: inset 0 1px 0 var(--inset-hi), 0 2px 0 var(--header-drop);
}
header h1 { font-size: 16px; font-weight: 600; flex: 1; text-align: center; color: var(--gold); text-shadow: none; letter-spacing: 0.5px; }
.header-left, .header-right { min-width: 36px; display: flex; align-items: center; gap: 2px; }
.header-left { justify-content: flex-start; }
.header-right { justify-content: flex-end; }
.header-btn { background: none; border: none; color: var(--text); cursor: pointer; padding: 4px; border-radius: 0; display: flex; align-items: center; justify-content: center; }
.header-btn:active { opacity: 0.6; }
.header-btn svg { fill: currentColor; }

/* Main */
main { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 8px; background: repeating-linear-gradient(0deg, transparent, transparent 48px, rgba(0,0,0,0.03) 48px, rgba(0,0,0,0.03) 49px); }

/* Tab Bar - MC hotbar style */
#tab-bar {
  display: flex;
  border-top: var(--pixel-border);
  background: linear-gradient(0deg, var(--tab-bar-from) 0%, var(--card) 100%);
  padding-bottom: var(--safe-bottom);
  position: sticky; bottom: 0; z-index: 100;
  box-shadow: inset 0 1px 0 var(--inset-hi);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; border: none; background: none;
  color: var(--text-secondary); font-size: 11px; cursor: pointer;
  transition: color .15s; font-family: inherit;
  border-left: 1px solid var(--divider);
}
.tab:first-child { border-left: none; }
.tab svg { fill: currentColor; }
.tab.active { color: var(--grass-light); background: var(--accent-soft); }
.tab:active { background: var(--hover-wash); }

/* Post Cards - MC chest/inventory panel style */
.post-card {
  background: var(--card);
  margin: 8px 10px;
  padding: 12px 14px;
  border: var(--pixel-border);
  box-shadow: inset 1px 1px 0 var(--inset-hi), inset -1px -1px 0 var(--inset-lo), 2px 2px 0 var(--shadow-block);
  cursor: pointer;
  transition: background .15s;
}
.post-card:active { background: var(--card-hover); }
.post-body-wrap { position: relative; margin-top: 2px; }
.post-body-wrap.is-clamped .post-body-inner {
  max-height: 220px;
  overflow: hidden;
  mask-image: linear-gradient(180deg, #000 55%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, #000 55%, transparent 100%);
}
.post-body-wrap.is-expanded .post-body-inner {
  max-height: none;
  mask-image: none;
  -webkit-mask-image: none;
}
.post-expand-btn {
  display: block; width: 100%; margin-top: 6px; padding: 6px 0;
  border: none; background: none; color: var(--grass-light);
  font-family: inherit; font-size: 12px; cursor: pointer; text-align: left;
}
.post-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.post-header .user-tap { flex: 1; min-width: 0; }
.avatar {
  width: 34px; height: 34px;
  background: var(--grass-dark);
  border: 2px solid var(--hard-border);
  color: var(--gold); display: flex; align-items: center; justify-content: center;
  font-weight: 500; font-size: 13px; flex-shrink: 0;
  box-shadow: inset 1px 1px 0 var(--inset-hi);
  image-rendering: pixelated;
}
.post-meta { flex: 1; }
.post-username { font-weight: 500; font-size: 14px; color: var(--grass-light); }
.post-time { font-size: 11px; color: var(--text-muted); }
.post-title { font-weight: 600; font-size: 16px; margin-bottom: 4px; color: var(--gold); text-shadow: none; }
.post-content { font-size: 14px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; color: var(--text); }
.post-content.md-body { white-space: normal; }
.md-body > *:first-child { margin-top: 0; }
.md-body > *:last-child { margin-bottom: 0; }
.md-body p { margin: 0.55em 0; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4 {
  color: var(--gold); font-weight: 600; margin: 0.8em 0 0.4em; line-height: 1.3;
}
.md-body h1 { font-size: 1.35em; }
.md-body h2 { font-size: 1.2em; }
.md-body h3 { font-size: 1.08em; }
.md-body ul, .md-body ol { margin: 0.5em 0; padding-left: 1.4em; }
.md-body li { margin: 0.2em 0; }
.md-body blockquote {
  margin: 0.6em 0; padding: 6px 10px; border-left: 3px solid var(--grass-dark);
  background: var(--panel-dim); color: var(--text-secondary);
}
.md-body code {
  font-family: ui-monospace, Consolas, monospace; font-size: 0.9em;
  background: var(--code-bg); padding: 1px 5px; border: 1px solid var(--hard-border);
}
.md-body pre {
  margin: 0.6em 0; padding: 10px; overflow-x: auto;
  background: var(--code-bg); border: var(--pixel-border);
}
.md-body pre code { background: none; border: none; padding: 0; }
.md-body a { color: var(--grass-light); text-decoration: underline; }
.md-body hr { border: none; border-top: 1px solid var(--divider); margin: 12px 0; }
.md-body table {
  width: 100%; border-collapse: collapse; margin: 0.7em 0;
  font-size: 13px; display: block; overflow-x: auto;
}
.md-body th, .md-body td {
  border: 2px solid var(--hard-border); padding: 6px 8px; text-align: left;
  background: var(--bg-light);
}
.md-body th { background: var(--card); color: var(--gold); font-weight: 600; }
.md-empty { color: var(--text-muted); margin: 0; }

.md-tabs { display: flex; gap: 0; margin-bottom: 6px; }
.md-tab {
  flex: 1; padding: 7px 10px; border: var(--pixel-border); background: var(--bg-light);
  color: var(--text-muted); font-family: inherit; cursor: pointer; font-size: 13px;
}
.md-tab.active { background: var(--card); color: var(--grass-light); }
.md-toolbar {
  display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px;
}
.md-tool {
  padding: 4px 8px; border: var(--pixel-border); background: var(--card);
  color: var(--text); font-family: inherit; font-size: 12px; cursor: pointer;
  min-width: 28px;
}
.md-tool:hover { color: var(--grass-light); }
.md-tool i { font-style: italic; }
.md-editor { min-height: 180px; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.md-preview {
  min-height: 180px; padding: 10px 12px;
  border: var(--pixel-border); background: var(--bg-light); overflow: auto;
}
.md-hint { font-size: 11px; color: var(--text-muted); margin: 6px 0 0; }

.auth-switch {
  margin-top: 18px; background: none; border: none; color: var(--grass-light);
  font-family: inherit; font-size: 13px; cursor: pointer; text-decoration: underline;
}
.code-row { display: flex; gap: 8px; align-items: stretch; }
.code-row .form-input { flex: 1; min-width: 0; }
.code-row .btn { flex-shrink: 0; white-space: nowrap; }
.post-images { display: grid; gap: 3px; margin-top: 8px; border: 2px solid var(--hard-border); overflow: hidden; }
.post-images.count-1 { grid-template-columns: 1fr; }
.post-images.count-2 { grid-template-columns: 1fr 1fr; }
.post-images.count-3 { grid-template-columns: 1fr 1fr 1fr; }
.post-images img { width: 100%; aspect-ratio: 1; object-fit: cover; cursor: pointer; image-rendering: auto; }
.post-images.count-1 img { aspect-ratio: 16/9; }
.post-videos { margin-top: 8px; border: 2px solid var(--hard-border); overflow: hidden; background: var(--video-bg); }
.post-videos video { width: 100%; max-height: 360px; display: block; background: #000; }
.post-videos video::-webkit-media-controls-download-button { display: none !important; }
.post-videos video::-webkit-media-controls-enclosure { overflow: hidden; }
.video-preview { margin-top: 6px; }
.compose-video { width: 100%; max-height: 220px; border: 2px solid var(--hard-border); background: var(--video-bg); }
.compose-video::-webkit-media-controls-download-button { display: none !important; }
.video-preview-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 12px; color: var(--text-muted); }
.post-actions {
  display: flex; gap: 20px; margin-top: 10px; padding-top: 8px;
  border-top: 1px solid var(--divider);
}
.action-btn {
  display: flex; align-items: center; gap: 4px;
  border: none; background: none; color: var(--text-muted);
  font-size: 12px; cursor: pointer; padding: 3px 0; font-family: inherit;
  transition: color .15s;
}
.action-btn:hover { color: var(--text); }
.action-btn.liked { color: var(--redstone); }
.action-btn.favorited { color: var(--gold); }
.action-btn svg { fill: currentColor; width: 16px; height: 16px; }

/* Forms - MC sign/book style */
.form-page { padding: 14px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 500; margin-bottom: 5px; color: var(--text-secondary); letter-spacing: 0.3px; }
.form-input {
  width: 100%; padding: 10px 12px;
  border: var(--pixel-border); background: var(--bg-light);
  font-size: 14px; color: var(--text); outline: none; resize: vertical;
  font-family: inherit;
  box-shadow: inset 1px 1px 0 var(--inset-lo), inset -1px -1px 0 var(--inset-hi);
}
.form-input:focus { border-color: var(--grass); box-shadow: 0 0 0 1px var(--grass); }
.form-input::placeholder { color: var(--text-muted); }
textarea.form-input { min-height: 110px; }

/* Buttons - MC stone button style */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 8px 16px; border: var(--pixel-border);
  font-size: 13px; font-weight: 500; cursor: pointer; font-family: inherit;
  letter-spacing: 0.2px;
  box-shadow: inset 1px 1px 0 var(--inset-hi), inset -1px -1px 0 var(--inset-lo), 2px 2px 0 var(--header-drop);
  transition: all .1s;
}
.btn:active { box-shadow: inset 1px 1px 0 rgba(0,0,0,0.3); transform: translate(1px, 1px); }
.btn-primary { background: linear-gradient(180deg, var(--grass-light) 0%, var(--grass-dark) 100%); color: #fff; }
.btn-danger { background: linear-gradient(180deg, var(--danger-light) 0%, var(--danger) 100%); color: #fff; }
.btn-outline { background: var(--card); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 10px; }
.btn-block { width: 100%; }

/* Image preview */
.image-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.image-preview-item { position: relative; width: 72px; height: 72px; border: 2px solid var(--hard-border); overflow: hidden; }
.image-preview-item img { width: 100%; height: 100%; object-fit: cover; image-rendering: auto; }
.image-preview-item .remove-img { position: absolute; top: 0; right: 0; width: 18px; height: 18px; background: rgba(0,0,0,0.7); color: var(--redstone); border: none; font-size: 11px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-family: inherit; }
.upload-btn {
  width: 72px; height: 72px;
  border: 2px dashed var(--border); background: var(--bg-light);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--grass-light); font-size: 22px; font-family: inherit;
}

/* Detail page */
.detail-content { padding: 14px; }
.comment-list { padding: 0 14px; }
.comment-item { padding: 10px 0; border-bottom: 1px solid var(--divider); }
.comment-item.is-reply { border-bottom: none; border-left: 2px solid rgba(93,140,46,0.35); padding-left: 10px; margin-top: 4px; }
.comment-children { margin-top: 2px; padding-left: 14px; }
.comment-header { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; flex-wrap: wrap; }
.comment-reply-to { font-size: 11px; color: var(--grass-light); }
.comment-reply-to b { font-weight: 600; }
.comment-actions { display: flex; gap: 14px; margin-top: 5px; flex-wrap: wrap; }
.comment-input-wrap {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 14px; border-top: var(--pixel-border); background: var(--card); position: sticky; bottom: 0;
}
.comment-input-row { display: flex; gap: 6px; }
.comment-input-row input { flex: 1; }
.comment-reply-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 12px; color: var(--grass-light); padding: 4px 2px 0;
}
.comment-reply-bar.hidden { display: none; }
.comment-reply-cancel {
  background: transparent; border: none; color: var(--text-muted); cursor: pointer; font-size: 12px; font-family: inherit;
}
.comment-reply-cancel:hover { color: var(--danger); }

/* Login page - MC main menu style */
.login-page { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 36px 20px; min-height: 60vh; }
.login-page .logo { font-size: 26px; font-weight: 600; color: var(--gold); margin-bottom: 4px; text-shadow: none; letter-spacing: 1px; }
.login-page .subtitle { color: var(--text-secondary); margin-bottom: 28px; font-size: 13px; }
.login-form { width: 100%; max-width: 300px; }
.auth-tabs {
  display: flex; width: 100%; max-width: 300px; gap: 0; margin-bottom: 14px;
  border: var(--pixel-border); overflow: hidden;
}
.auth-tab {
  flex: 1; padding: 8px 10px; border: none; background: var(--bg-light);
  color: var(--text-muted); font-family: inherit; font-size: 13px; cursor: pointer;
}
.auth-tab.active { background: var(--card); color: var(--grass-light); }
.captcha-box {
  width: 100%;
  max-width: 300px;
}
.captcha-prompt {
  font-size: 13px;
  color: var(--gold);
  margin-bottom: 8px;
  font-weight: 600;
  line-height: 1.4;
}
.captcha-widget {
  min-height: 78px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--code-bg);
  border: var(--pixel-border);
  padding: 8px;
  overflow: hidden;
}
.captcha-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}
.captcha-hint {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
  text-align: left;
  flex: 1;
}

/* Friends */
.friend-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--card);
  margin: 4px 10px;
  border: var(--pixel-border);
  box-shadow: inset 1px 1px 0 var(--inset-hi), 2px 2px 0 var(--shadow-block);
}
.friend-item .avatar { width: 36px; height: 36px; font-size: 14px; }
.friend-info { flex: 1; }
.friend-name { font-weight: 500; font-size: 14px; color: var(--text); }
.request-badge { background: var(--redstone); color: #fff; font-size: 11px; padding: 2px 7px; border: 1px solid rgba(0,0,0,0.2); font-weight: 500; }

/* My page */
.my-page { padding: 20px 14px; }
.user-card {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 14px; background: var(--card);
  border: var(--pixel-border); margin-bottom: 14px;
  box-shadow: inset 1px 1px 0 var(--inset-hi), 2px 2px 0 var(--shadow-block);
}
.user-card .avatar { width: 50px; height: 50px; font-size: 20px; }
.user-info { flex: 1; }
.user-info h2 { font-size: 17px; font-weight: 600; color: var(--text); text-shadow: none; }
.user-info p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.menu-list { background: var(--card); border: var(--pixel-border); overflow: hidden; box-shadow: 2px 2px 0 var(--shadow-block); }
.menu-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--divider);
  cursor: pointer; font-size: 14px; color: var(--text);
  transition: background .15s;
}
.menu-item:last-child { border-bottom: none; }
.menu-item:active { background: var(--card-hover); }
.menu-item .menu-icon { margin-right: 8px; }

/* Toast - MC chat style */
.toast {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.85); color: var(--gold);
  padding: 6px 16px; border: 2px solid #444;
  font-size: 13px; z-index: 999; transition: opacity .3s;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.5);
}
.toast.hidden { opacity: 0; pointer-events: none; }
.hidden { display: none !important; }

/* Empty state */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 50px 16px; color: var(--text-muted); }
.empty-state svg { fill: currentColor; margin-bottom: 10px; opacity: 0.3; }
.empty-state p { font-size: 14px; color: var(--text-secondary); }

/* Image lightbox */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 12px;
  touch-action: none;
}
.lightbox-download {
  position: absolute; top: 14px; right: 14px; z-index: 3;
  gap: 6px;
}
.lightbox-stage {
  flex: 1; width: 100%; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.lightbox-img {
  max-width: 95%; max-height: calc(100vh - 80px); object-fit: contain;
  border: var(--pixel-border); transform-origin: center center;
  transition: transform .08s ease-out; user-select: none; -webkit-user-drag: none;
  touch-action: none;
}
.lightbox-img.is-zoomed { cursor: grab; max-width: none; max-height: none; }
.lightbox-img.is-zoomed:active { cursor: grabbing; }
.lightbox-hint { font-size: 11px; color: rgba(255,255,255,0.55); pointer-events: none; }

/* Loading */
.loading { display: flex; align-items: center; justify-content: center; padding: 36px; color: var(--text-secondary); font-size: 14px; }
.loading::before { content: ''; width: 16px; height: 16px; border: 3px solid var(--grass-dark); border-top-color: var(--grass-light); animation: spin .8s linear infinite; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

.section-title { font-size: 12px; font-weight: 500; color: var(--text-muted); padding: 10px 14px 4px; letter-spacing: 0.3px; }

/* MC decorative banner on home */
.mc-banner {
  background: linear-gradient(135deg, var(--dirt-dark) 0%, var(--dirt) 50%, var(--dirt-light) 100%);
  border-bottom: var(--pixel-border);
  padding: 16px 14px;
  text-align: center;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.3);
}
.mc-banner h2 { color: var(--gold); font-size: 19px; font-weight: 600; text-shadow: none; margin: 0; }
.mc-banner p { color: var(--wood-light); font-size: 12px; letter-spacing: 0.3px; }

/* Stats bar */
.stats-bar {
  display: flex; justify-content: space-around; padding: 10px;
  background: var(--card); border-bottom: var(--pixel-border);
  margin: 0 10px 4px; border: var(--pixel-border);
  box-shadow: 2px 2px 0 var(--shadow-block);
}
.stat-item { text-align: center; }
.stat-value { font-size: 17px; font-weight: 600; color: var(--gold); }
.stat-label { font-size: 11px; color: var(--text-muted); letter-spacing: 0.2px; }

/* Online indicator */
.online-dot { width: 8px; height: 8px; background: var(--grass-light); border: 1px solid var(--hard-border); display: inline-block; margin-right: 4px; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Search & category */
.home-toolbar { padding: 10px 12px 6px; }
.search-row { display: flex; gap: 8px; margin-bottom: 8px; }
.search-row .form-input { flex: 1; }
.cat-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sort-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.sort-chip, .cat-chip {
  padding: 5px 12px; border: 1px solid var(--border); background: var(--card);
  color: var(--text-secondary); font-size: 12px; cursor: pointer; font-family: inherit;
}
.sort-chip.active, .cat-chip.active {
  background: rgba(93,140,46,0.2); color: var(--grass-light); border-color: var(--grass-dark);
}
.cat-badge {
  display: inline-block; font-size: 10px; padding: 1px 6px; margin-left: 4px;
  background: rgba(93,140,46,0.15); color: var(--grass-light); border: 1px solid rgba(93,140,46,0.3);
  font-weight: 500;
}
.cat-badge-lg {
  display: inline-block; margin: 0 14px 8px; font-size: 11px; padding: 2px 8px;
  background: rgba(93,140,46,0.15); color: var(--grass-light); border: 1px solid rgba(93,140,46,0.3);
}

/* Reports admin */
.admin-filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 12px 4px; }
.report-card {
  margin: 8px 12px; padding: 12px; background: var(--card);
  border: var(--pixel-border); box-shadow: 2px 2px 0 var(--shadow-block);
}
.report-meta { display: flex; justify-content: space-between; margin-bottom: 6px; }
.report-body { font-size: 13px; line-height: 1.5; margin-bottom: 6px; color: var(--text); }
.report-info { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.report-ai { font-size: 11px; color: var(--gold); margin-bottom: 8px; }
.report-ai-box {
  margin: 8px 0; padding: 8px; background: var(--code-bg);
  border: 1px solid var(--divider); font-size: 12px; line-height: 1.45;
}
.report-ai-title { color: var(--gold); font-weight: 600; margin-bottom: 4px; }
.report-ai-row { color: var(--text-muted); margin-top: 2px; }
.report-ai-msg { white-space: pre-wrap; color: var(--text); margin-top: 6px; }
.report-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Versions */
.version-list { padding: 0 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.version-card {
  display: flex; gap: 12px; padding: 10px; background: var(--card);
  border: var(--pixel-border); box-shadow: 2px 2px 0 var(--shadow-block); cursor: pointer;
}
.version-card:hover { filter: brightness(1.05); }
.version-cover {
  width: 88px; height: 88px; object-fit: cover; border: 2px solid var(--hard-border); flex-shrink: 0; background: var(--video-bg);
}
.version-cover-empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--gold); font-size: 12px; font-weight: 600;
}
.version-card-body { min-width: 0; flex: 1; }
.version-card-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.version-card-summary {
  font-size: 12px; color: var(--text-muted); line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.version-card-meta { margin-top: 6px; font-size: 11px; color: var(--text-muted); }
.version-download-links {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px;
}
.version-download-links.compact { margin-top: 8px; gap: 6px; }
.version-download-btn { text-decoration: none; }
.version-detail-name { font-size: 20px; font-weight: 600; margin: 0 0 6px; color: var(--gold); }
.version-detail-summary { font-size: 13px; color: var(--text-secondary); margin-bottom: 10px; line-height: 1.5; }

.ver-download-list { display: flex; flex-direction: column; gap: 8px; }
.ver-download-row {
  display: grid; grid-template-columns: 120px 1fr auto; gap: 8px; align-items: center;
}
@media (max-width: 700px) {
  .ver-download-row { grid-template-columns: 1fr; }
}

/* Admin console */
.admin-console {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 0;
  min-height: calc(100vh - 120px);
}
.admin-nav {
  background: var(--nav-bg);
  border-right: 1px solid var(--divider);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.admin-nav-brand { font-size: 14px; font-weight: 700; color: var(--gold); padding: 4px 8px 0; }
.admin-nav-sub { font-size: 11px; color: var(--text-muted); padding: 0 8px 10px; }
.admin-nav-item {
  text-align: left; border: 1px solid transparent; background: transparent;
  color: var(--text-secondary); padding: 9px 10px; cursor: pointer; font-family: inherit; font-size: 13px;
}
.admin-nav-item:hover { background: var(--hover-wash); color: var(--text); }
.admin-nav-item.active {
  background: rgba(93,140,46,0.18); border-color: rgba(93,140,46,0.45); color: var(--grass-light);
}
.admin-nav-item.ghost { margin-top: auto; color: var(--text-muted); }
.admin-main { padding: 12px; min-width: 0; }
.admin-hero {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  margin-bottom: 14px; padding: 14px; background: linear-gradient(135deg, var(--accent-soft), var(--panel-dim));
  border: var(--pixel-border);
}
.admin-hero.compact { padding: 12px; }
.admin-hero h2 { margin: 0 0 4px; font-size: 18px; color: var(--text); }
.admin-hero p { margin: 0; font-size: 12px; color: var(--text-muted); line-height: 1.45; }
.admin-hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-stat-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px;
}
.admin-stat {
  background: var(--card); border: var(--pixel-border); padding: 12px; box-shadow: 2px 2px 0 var(--shadow-block);
}
.admin-stat.warn { border-color: #b45309; }
.admin-stat-num { font-size: 22px; font-weight: 700; color: var(--gold); }
.admin-stat-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.admin-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.admin-panel {
  background: var(--card); border: var(--pixel-border); padding: 10px; box-shadow: 2px 2px 0 var(--shadow-block);
}
.admin-panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.admin-panel-head h3 { margin: 0; font-size: 14px; }
.admin-row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 0; border-top: 1px solid var(--divider);
}
.admin-row-title { font-size: 13px; color: var(--text); }
.admin-row-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.admin-badge {
  display: inline-block; font-size: 11px; padding: 2px 7px;
  border: 1px solid var(--divider); color: var(--text-muted);
}
.admin-badge.ok { color: var(--grass-light); border-color: rgba(93,140,46,0.45); }
.admin-badge.muted { color: #c4a574; border-color: rgba(196,165,116,0.4); }
.admin-empty { padding: 18px 8px; text-align: center; color: var(--text-muted); font-size: 13px; }
.admin-empty.tiny { padding: 8px; font-size: 12px; }
.admin-version-grid { display: flex; flex-direction: column; gap: 10px; }
.admin-version-card {
  display: grid; grid-template-columns: 120px 1fr; gap: 12px;
  background: var(--card); border: var(--pixel-border); padding: 10px; box-shadow: 2px 2px 0 var(--shadow-block);
}
.admin-version-cover {
  width: 120px; height: 90px; object-fit: cover; border: 2px solid var(--hard-border); background: var(--video-bg);
}
.admin-version-cover.empty {
  display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 11px;
}
.admin-version-body h3 { margin: 0; font-size: 15px; }
.admin-version-body p { margin: 6px 0; font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.admin-version-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.admin-version-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.admin-editor {
  background: var(--card); border: var(--pixel-border); padding: 14px; box-shadow: 2px 2px 0 var(--shadow-block);
}
.admin-editor-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.admin-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); margin-top: 8px; }
.admin-editor-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.admin-media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.admin-media-item { position: relative; border: 2px solid var(--hard-border); background: var(--video-bg); }
.admin-media-item img, .admin-media-item video { width: 100%; height: 90px; object-fit: cover; display: block; }
.admin-media-item.video video { height: 120px; }
.admin-media-remove {
  position: absolute; right: 4px; top: 4px; border: none; background: rgba(0,0,0,0.7);
  color: #fff; font-size: 11px; padding: 2px 6px; cursor: pointer; font-family: inherit;
}
.admin-report-card { margin-left: 0; margin-right: 0; }
.admin-filters { margin-left: 0; margin-right: 0; }

@media (max-width: 900px) {
  .admin-console { grid-template-columns: 1fr; }
  .admin-nav {
    flex-direction: row; flex-wrap: wrap; border-right: none;
    border-bottom: 1px solid var(--divider); align-items: center;
  }
  .admin-nav-brand, .admin-nav-sub { width: 100%; }
  .admin-nav-item.ghost { margin-top: 0; }
  .admin-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-split, .admin-editor-row, .admin-version-card { grid-template-columns: 1fr; }
}

/* Clickable user (avatar / name → profile) */
.user-tap {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 2px;
}
.user-tap:hover .post-username,
.user-tap:hover .friend-name { color: var(--grass-light); }
.user-tap .avatar { flex-shrink: 0; }
.profile-actions { display: flex; gap: 8px; margin: 0 12px 14px; flex-wrap: wrap; }
.profile-actions .btn { flex: 1; min-width: 100px; }

/* Profile extras */
.avatar-wrap { position: relative; cursor: pointer; flex-shrink: 0; }
.avatar-wrap .avatar { width: 64px; height: 64px; font-size: 22px; }
.avatar-edit {
  display: block; text-align: center; font-size: 10px; color: var(--grass-light);
  margin-top: 4px;
}
.profile-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); gap: 6px;
  margin-bottom: 14px;
}
.profile-stat {
  background: var(--card); border: var(--pixel-border); padding: 10px 4px;
  text-align: center; cursor: pointer; color: var(--text); font-family: inherit;
}
.profile-stat b { display: block; font-size: 16px; color: var(--gold); font-weight: 600; }
.profile-stat span { font-size: 11px; color: var(--text-muted); }
.notif-item {
  margin: 6px 12px; padding: 12px; background: var(--card);
  border: var(--pixel-border); cursor: pointer;
}
.notif-item.unread { border-color: var(--grass-dark); background: rgba(93,140,46,0.08); }
.notif-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.notif-body { font-size: 13px; color: var(--text-secondary); line-height: 1.5; word-break: break-word; }

.theme-menu-item { cursor: pointer; }
.theme-switch {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-muted);
}
.theme-switch-track {
  width: 42px; height: 22px; border: var(--pixel-border);
  background: var(--bg-light); position: relative;
  box-shadow: inset 1px 1px 0 var(--inset-lo);
}
.theme-switch-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; background: var(--text-muted);
  transition: left .15s ease, background .15s ease;
}
.theme-switch.is-light .theme-switch-thumb {
  left: 22px; background: var(--grass);
}
html[data-theme="light"] .mc-banner p { color: #5A4630; }
html[data-theme="light"] .post-videos video { background: #000; }
html[data-theme="light"] .toast {
  background: rgba(255,253,248,0.96); color: var(--gold);
  border-color: var(--border);
}
