:root {
  --bg: #0b1220;
  --card: #121b2e;
  --text: #e6ecff;
  --muted: #95a2c9;
  --accent: #6ea8ff;
  --border: #23304f;
  --header-bg: transparent;
  --desktop-side-column-width: 280px;
  --desktop-main-gap: 18px;
  --desktop-filter-popup-width: calc(var(--desktop-side-column-width) + var(--desktop-main-gap));
}

body[data-theme='light'] {
  --bg: #f6f8fc;
  --card: #ffffff;
  --text: #1f2a3d;
  --muted: #5d6b86;
  --accent: #2f73ff;
  --border: #d8e1f2;
  --header-bg: rgba(255,255,255,0.45);
}

body[data-theme='light'] .card {
  background: #ffffff;
}

body[data-theme='light'] .post-link {
  color: #1c2f52;
}

body[data-theme='light'] .btn {
  background: #f4f7ff;
  color: #1f2a3d;
  border-color: #c9d7ef;
}

body[data-theme='light'] .markdown-body {
  color: #27344d;
}

body[data-theme='light'] .markdown-body h1,
body[data-theme='light'] .markdown-body h2,
body[data-theme='light'] .markdown-body h3,
body[data-theme='light'] .markdown-body h4 {
  color: #13233d;
}

body[data-theme='light'] .markdown-body blockquote {
  background: #f2f6ff;
  color: #354968;
}

body[data-theme='light'] .markdown-body pre {
  background: #f5f8ff;
}

body[data-theme='light'] .md-table thead th {
  background: #edf3ff;
  color: #20375d;
}

body[data-theme='light'] .md-table tbody tr:nth-child(2n) {
  background: rgba(47, 115, 255, 0.04);
}

body[data-theme='light'] .index-panel {
  background: transparent;
}

body[data-theme='light'] .index-panel h3 {
  color: #3f5f8d;
}

body[data-theme='light'] .chip {
  background: #f5f8ff;
  color: #375683;
  border-color: #c7d7f0;
}

body[data-theme='light'] .chip.active {
  background: #2f73ff;
  border-color: #2f73ff;
  color: #fff;
}

body[data-theme='light'] .user-session {
  background: rgba(255, 255, 255, 0.9);
}

body[data-theme='light'] .user-avatar {
  border-color: rgba(31, 42, 61, 0.12);
}

body[data-theme='light'] .post-visibility.is-public {
  background: #f1f5fd;
  color: #60769c;
  border-color: #d7e2f3;
}

body[data-theme='light'] .post-visibility.is-internal {
  background: #f6f1e8;
  color: #8a7757;
  border-color: #ddd3c1;
}

body[data-theme='light'] .post-visibility.is-private {
  background: #f9ece8;
  color: #955640;
  border-color: #e9cbc1;
}

body[data-theme='light'] .post-visibility.is-draft {
  background: #f1f3f5;
  color: #67707c;
  border-color: #d8dde3;
}

body[data-theme='light'] .post-card {
  background: #ffffff;
}

body[data-theme='light'] .post-summary {
  color: #556888;
}

body[data-theme='light'] .btn-feishu {
  background: rgba(47, 115, 255, 0.06);
  border-color: rgba(47, 115, 255, 0.16);
  color: #24467a;
  box-shadow: none;
}

body[data-theme='light'] .viewer-actions-popover {
  background: rgba(255, 255, 255, 0.96);
}

body[data-theme='light'] .month-select {
  background: #eef3ff;
  color: #38527c;
}

body[data-theme='light'] .index-panel-body,
body[data-theme='light'] .search-panel,
body[data-theme='light'] .date-filter-panel {
  background: #ffffff;
  border-color: #d4e0f3;
  box-shadow: 0 18px 44px rgba(24, 48, 94, 0.14);
}

body[data-theme='light'] .date-filter-trigger,
body[data-theme='light'] .search-input,
body[data-theme='light'] .search-reset-btn,
body[data-theme='light'] .filter-action-btn {
  border-color: #c6d6ef;
}

body[data-theme='light'] .date-filter-trigger,
body[data-theme='light'] .search-reset-btn,
body[data-theme='light'] .filter-action-btn {
  background: #eff4ff;
  color: #24406b;
}

body[data-theme='light'] .search-input {
  background: #ffffff;
  color: #20324d;
}

body[data-theme='light'] .search-input::placeholder {
  color: #6c7f9f;
}

body[data-theme='light'] .index-panel-actions {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

body[data-theme='light'] .filter-toggle-btn,
body[data-theme='light'] .search-toggle-btn {
  border-color: #b7cae8;
  background: #ffffff;
  color: #27416a;
}

body[data-theme='light'] .index-panel.open-filter-popup .filter-toggle-btn,
body[data-theme='light'] .index-panel.open-search-popup .search-toggle-btn {
  border-color: #9fb9e3;
  background: #eaf2ff;
  color: #1f3558;
}

body[data-theme='light'] .search-toggle-btn.has-active {
  border-color: #9fb9e3;
  background: #eaf2ff;
}

* { box-sizing: border-box; }

.site-toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 10050;
  max-width: min(80vw, 320px);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(11, 18, 32, 0.92);
  color: #fff;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.site-toast.hidden {
  display: none;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 95%, #000 5%), var(--bg));
  color: var(--text);
}
.container { width: min(1100px, 94vw); margin: 0 auto; }
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 22px 0 20px;
  background: var(--header-bg);
}

.header-banner {
  width: 100%;
  max-height: 170px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 14px;
}

.site-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.site-actions {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.utility-bar {
  width: 100%;
  display: flex;
  justify-content: flex-end;
}

.theme-toggle-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.theme-icon {
  font-size: 18px;
  line-height: 1;
}

.auth-controls {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.auth-row {
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
  min-height: 40px;
}

.auth-note {
  max-width: 320px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.btn-feishu {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(220, 232, 255, 0.9);
  border-color: rgba(153, 184, 232, 0.18);
  font-weight: 600;
  box-shadow: none;
}

.btn-feishu:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(153, 184, 232, 0.24);
}

.feishu-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.feishu-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.user-session {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(23, 35, 63, 0.72);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.user-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.user-meta strong,
.user-meta span {
  display: block;
  text-align: left;
}

.hidden { display: none !important; }
.card {
  background: color-mix(in srgb, var(--card) 92%, black 8%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
}

.main-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--desktop-side-column-width);
  gap: var(--desktop-main-gap);
  padding: 18px 0 30px;
}

.content-column {
  min-width: 0;
  display: grid;
  gap: 16px;
}

.content-column > * {
  min-width: 0;
}

.post-list { list-style: none; margin: 0; padding: 0; color: var(--text); }
.post-list li { display: block; padding: 6px 0; border-bottom: none; }
.post-list li:last-child { border-bottom: none; }
.post-list-featured { margin-bottom: 10px; }
.post-list-featured li { padding: 10px 0; }
.post-item { display: block; }
.post-section-heading {
  margin: 14px 0 8px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.post-list > .post-section-heading:first-child {
  margin-top: 2px;
}

.post-card {
  display: block;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: rgba(255,255,255,0.02);
}

.post-card.is-private {
  border-color: color-mix(in srgb, #d97b56 28%, var(--border) 72%);
  background: color-mix(in srgb, #d97b56 8%, transparent);
}

.post-card.is-draft {
  border-color: color-mix(in srgb, #9ba5b1 26%, var(--border) 74%);
  background: color-mix(in srgb, #c8d0d8 12%, transparent);
}
.post-card-title-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.post-title-inline {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.post-link {
  color: var(--text);
  font-weight: 700;
  font-size: 18px;
  line-height: 1.45;
  min-width: 0;
}
.post-date {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.post-summary {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.7;
}
.post-card-foot {
  margin-top: 12px;
}
.post-visibility {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
}

.post-visibility-inline {
  vertical-align: middle;
  flex: 0 0 auto;
}

.post-visibility.is-internal { background: rgba(255, 214, 102, 0.08); }
.post-visibility.is-public { background: rgba(124, 182, 255, 0.08); }
.post-visibility.is-private { background: rgba(232, 145, 118, 0.14); }
.post-visibility.is-draft { background: rgba(185, 193, 201, 0.16); }

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.section-kicker,
.site-kicker {
  display: inline-block;
  letter-spacing: 0.18em;
  font-size: 12px;
  color: color-mix(in srgb, var(--accent) 85%, white 15%);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.site-header h1 { margin: 0 0 8px; }
.site-header p { margin: 0 0 12px; color: var(--muted); }
.site-header nav a {
  color: var(--accent);
  text-decoration: none;
  margin-right: 14px;
}

.btn {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
}
.btn-small {
  padding: 6px 10px;
  font-size: 13px;
}
.month-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
}
.date-filter {
  position: relative;
}

.date-filter-trigger {
  width: 100%;
  justify-content: space-between;
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.7);
}

body[data-theme='dark'] .date-filter-trigger {
  background: rgba(15, 24, 42, 0.7);
}

.date-filter-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 50;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
  background: var(--card);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.14);
  touch-action: pan-y;
}

.date-filter-panel.hidden {
  display: none;
}

.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

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

.calendar-select {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.7);
  color: var(--text);
  border-radius: 10px;
  padding: 6px 8px;
  font-size: 13px;
}

body[data-theme='dark'] .calendar-select {
  background: rgba(15, 24, 42, 0.7);
}

.calendar-nav {
  display: flex;
  gap: 6px;
}

.calendar-nav button {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.calendar-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.calendar-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 4px 2px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(120, 130, 150, 0.12);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  line-height: 1.05;
}

.calendar-day-main {
  font-weight: 600;
}

.calendar-day-count {
  font-size: 10px;
  opacity: 0.88;
}

.calendar-day.has-post {
  color: #fff;
  background: #ff5757;
}

.calendar-day.is-selected {
  border-color: #1f6feb;
  box-shadow: 0 0 0 2px rgba(31, 111, 235, 0.18);
}

.calendar-day.is-today:not(.has-post) {
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
}

.calendar-day.is-empty {
  background: transparent;
  cursor: default;
}

.calendar-day.is-empty:hover {
  background: transparent;
}

.calendar-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  gap: 8px;
}

.calendar-actions button {
  flex: 1;
  border-radius: 10px;
}

.filter-actions {
  display: flex;
  margin-top: 2px;
}

.filter-action-btn {
  width: 100%;
  justify-content: center;
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 600;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  cursor: pointer;
}
.chip.active {
  background: rgba(110,168,255,0.18);
  border-color: color-mix(in srgb, var(--accent) 65%, var(--border) 35%);
}

.viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.viewer-toolbar-left,
.viewer-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.viewer-toolbar-right {
  margin-left: auto;
  justify-content: flex-end;
}

body.webslides-view-active .post-fab-actions {
  display: none;
}

.post-meta-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  flex-wrap: wrap;
}

.post-id-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  background: rgba(110, 168, 255, 0.12);
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.post-meta-footer {
  position: relative;
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  min-height: 28px;
}

.post-id-footer {
  position: absolute;
  bottom: 0;
  right: 0;
  font-size: 12px;
  opacity: 0.6;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  padding: 3px 8px;
  border-radius: 8px;
  z-index: 1;
}

@media (max-width: 900px) {
  .post-id-footer {
    position: static;
    display: inline-block;
    margin-top: 8px;
    margin-left: auto;
    opacity: 0.5;
    font-size: 11px;
  }
  
  .post-meta-footer {
    margin-top: 16px;
    padding-top: 10px;
  }
}

.post-time {
  white-space: nowrap;
}

.viewer-actions-menu {
  position: relative;
}

.viewer-actions-menu summary {
  list-style: none;
}

.viewer-actions-menu summary::-webkit-details-marker {
  display: none;
}

.viewer-actions-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.viewer-actions-trigger::after {
  content: '▾';
  font-size: 11px;
  color: var(--muted);
}

.viewer-actions-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  min-width: 150px;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--border) 86%, transparent);
  border-radius: 12px;
  background: rgba(14, 24, 43, 0.92);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.viewer-actions-menu:not([open]) .viewer-actions-popover {
  display: none;
}

.viewer-action-btn {
  width: 100%;
  justify-content: flex-start;
}

.post-fab-actions {
  position: fixed;
  right: max(22px, calc((100vw - 1180px) / 2 + 320px));
  bottom: 22px;
  z-index: 10020;
  display: flex;
  align-items: center;
  gap: 10px;
}

.post-nav-fab-actions {
  position: fixed;
  left: max(22px, calc((100vw - 1180px) / 2 + 22px));
  bottom: 22px;
  z-index: 10020;
  display: none;
  align-items: center;
  gap: 10px;
}

.list-refresh-fab-wrap {
  position: fixed;
  left: max(22px, calc((100vw - 1180px) / 2 + 22px));
  bottom: 22px;
  z-index: 10020;
  display: none !important;
}

#posts:not(.hidden) + .list-refresh-fab-wrap {
  display: none !important;
}

#viewer:not(.hidden) ~ .list-refresh-fab-wrap,
#posts.hidden + .list-refresh-fab-wrap {
  display: none !important;
}

.post-fab-btn,
.post-nav-fab-btn {
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: color-mix(in srgb, var(--card) 58%, transparent 42%);
  border: 1px solid color-mix(in srgb, var(--border) 62%, transparent 38%);
  color: color-mix(in srgb, var(--text) 82%, transparent 18%);
}

.post-fab-btn {
  padding: 10px 16px;
  font-weight: 600;
}

.post-nav-fab-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  line-height: 1;
  font-weight: 500;
}

.post-refresh-fab-btn {
  font-size: 24px;
  font-weight: 400;
}

@media (min-width: 901px) {
  .list-refresh-fab-wrap {
    display: none;
  }
}

.post-fab-btn:hover,
.post-nav-fab-btn:hover {
  transform: translateY(-1px);
  background: color-mix(in srgb, var(--card) 70%, transparent 30%);
  border-color: color-mix(in srgb, var(--accent) 18%, var(--border) 82%);
}

.slide-embed-wrap {
  display: grid;
  gap: 14px;
  margin: 18px 0 22px;
}

.slide-embed-action {
  appearance: none;
  border: 0;
  background: transparent;
  color: color-mix(in srgb, var(--accent) 82%, var(--text) 18%);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.2;
  padding: 4px 2px;
  text-decoration: none;
}

.slide-embed-action:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.slide-embed-iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0a1020;
  overflow: hidden;
  scrollbar-width: none;
}

.slide-embed-mobile-controls {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.slide-embed-wrap.is-fullscreen {
  width: 100vw;
  height: 100dvh;
  padding: 12px;
  background: #f8fbff;
  grid-template-rows: minmax(0, 1fr);
}

.slide-embed-wrap.is-mobile-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 10080;
  margin: 0;
  width: 100vw;
  height: 100dvh;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  background: var(--card);
}

.slide-embed-fullscreen-lock {
  overflow: hidden;
  touch-action: none;
}

.slide-embed-wrap.is-fullscreen .slide-embed-iframe {
  height: 100%;
  min-height: 0;
  aspect-ratio: auto;
  border-radius: 10px;
}

.slide-embed-iframe::-webkit-scrollbar {
  display: none;
}

@media (max-width: 700px) {
  .slide-embed-wrap {
    gap: 10px;
    margin: 12px 0 18px;
  }

  .slide-embed-action {
    font-size: 13px;
    min-height: 32px;
  }

  .slide-embed-iframe {
    aspect-ratio: auto;
    height: min(68dvh, 620px);
    min-height: 460px;
    border-radius: 10px;
  }

  .slide-embed-mobile-controls {
    display: flex;
  }

  .slide-embed-wrap.is-fullscreen {
    padding: 8px;
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .slide-embed-wrap.is-fullscreen .slide-embed-iframe {
    min-height: 0;
  }
}

.pdf-embed-wrap {
  display: grid;
  gap: 12px;
  margin: 18px 0 22px;
}

.pdf-embed-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.pdf-embed-iframe {
  width: 100%;
  min-height: 78vh;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

.posts-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 18px;
  align-items: start;
}

.index-panel {
  position: sticky;
  align-self: start;
  top: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #101a2f;
  overflow: visible;
}

.index-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.index-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.index-panel-body {
  margin-top: 8px;
}

.index-panel.collapsed-desktop .index-panel-body {
  display: none;
}

.search-panel {
  margin-top: 8px;
}

.index-panel h3 {
  margin: 14px 0 8px;
  font-size: 14px;
  color: #c9d7ff;
}

.filter-title {
  font-size: 14px;
  font-weight: 700;
}

.filter-toggle-btn,
.search-toggle-btn,
.tag-more-btn {
  white-space: nowrap;
}

.search-toggle-btn.has-active {
  border-color: var(--accent);
  color: var(--text);
}

.search-filter {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.search-input {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font: inherit;
}

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

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(107, 155, 255, 0.18);
}

.search-reset-btn {
  padding-left: 10px;
  padding-right: 10px;
}

.search-reset-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.markdown-body {
  line-height: 1.8;
}
.markdown-body h1 {
  font-size: clamp(1.9rem, 2.4vw, 2.5rem);
  line-height: 1.18;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0 0 0.62em;
}
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  line-height: 1.35;
}
.md-image {
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.md-figure {
  margin: 18px 0;
}
.md-figure figcaption {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}
.md-table-wrap {
  overflow-x: auto;
}
.md-table {
  width: 100%;
  border-collapse: collapse;
}
.md-table th,
.md-table td {
  border: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
}
.md-table thead th {
  background: rgba(255,255,255,0.04);
}
.markdown-body blockquote {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 4px solid var(--accent);
  background: rgba(255,255,255,0.03);
}
.markdown-body pre {
  overflow-x: auto;
  padding: 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
}
.markdown-body code {
  background: rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: 6px;
}

.mermaid-block {
  margin: 16px 0 12px;
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--card) 94%, transparent);
  overflow-x: auto;
  overflow-y: hidden;
}

.mermaid-diagram {
  width: 100%;
  min-width: 0;
}

.mermaid-diagram svg {
  display: block;
  width: auto;
  max-width: 100% !important;
  height: auto;
  font-size: 16px !important;
}

.mermaid-diagram text,
.mermaid-diagram .nodeLabel,
.mermaid-diagram .edgeLabel,
.mermaid-diagram .label {
  font-size: 16px !important;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 18px 0 36px;
  color: var(--muted);
}

@media (min-width: 901px) {
  .post-nav-fab-actions {
    display: none !important;
  }

  .site-actions {
    width: var(--desktop-side-column-width);
    min-width: var(--desktop-side-column-width);
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 10px;
    margin-left: auto;
  }

  .auth-controls {
    order: 1;
    flex: 1 1 auto;
    display: grid;
    justify-items: start;
    gap: 8px;
  }

  .auth-row {
    width: 100%;
    justify-content: flex-start;
  }

  .auth-note {
    text-align: left;
    max-width: 100%;
  }

  .utility-bar {
    order: 2;
    width: auto;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    flex-wrap: nowrap;
  }

  .index-panel {
    border: none;
    border-radius: 0;
    padding: 0;
    background: transparent;
    justify-self: start;
    width: max-content;
  }

  .index-panel-head {
    justify-content: flex-end;
  }

  .index-panel .filter-title {
    display: none;
  }

  .index-panel-actions {
    padding: 4px;
    border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
    border-radius: 16px;
    background: color-mix(in srgb, var(--card) 96%, transparent);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
  }

  .filter-toggle-btn,
  .search-toggle-btn {
    min-width: 86px;
    padding: 8px 16px;
    border-radius: 999px;
    border-color: transparent;
    background: transparent;
    font-size: 15px;
    font-weight: 650;
  }

  .index-panel-body,
  .search-panel {
    position: absolute;
    left: 0;
    right: auto;
    top: calc(100% + 8px);
    width: var(--desktop-filter-popup-width);
    max-width: min(var(--desktop-filter-popup-width), calc(100vw - 40px));
    margin-top: 0;
    padding: 18px 20px 20px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: color-mix(in srgb, var(--card) 92%, black 8%);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    overflow: visible;
    z-index: 60;
  }

  .index-panel-body {
    max-height: none;
  }

  .search-panel {
    padding: 12px 14px;
    border-radius: 16px;
    max-height: none;
  }

  .index-panel h3 {
    margin-top: 12px;
    margin-bottom: 10px;
    font-size: 15px;
    font-weight: 700;
  }

  .search-filter {
    gap: 10px;
  }

  .search-input {
    min-height: 52px;
    font-size: 16px;
  }

  .search-reset-btn,
  .filter-action-btn,
  .date-filter-trigger {
    min-height: 52px;
    font-size: 16px;
    font-weight: 600;
  }

  .search-panel .search-filter {
    gap: 8px;
  }

  .search-panel .search-input,
  .search-panel .search-reset-btn {
    min-height: 46px;
    font-size: 15px;
  }

  .chips {
    column-gap: 12px;
    row-gap: 6px;
    margin-bottom: 8px;
  }

  .index-panel-body .chip,
  body[data-theme='light'] .index-panel-body .chip {
    border: 0;
    background: transparent;
    border-radius: 0;
    padding: 1px 0;
    font-size: 13px;
    line-height: 1.25;
    font-weight: 520;
    color: color-mix(in srgb, var(--text) 86%, transparent);
  }

  .index-panel-body .chip:hover {
    color: var(--text);
  }

  .index-panel-body .chip.active,
  body[data-theme='light'] .index-panel-body .chip.active {
    background: transparent;
    border-color: transparent;
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
  }

  .index-panel-body .tag-more-btn {
    border: 0;
    background: transparent;
    border-radius: 0;
    padding: 2px 0 0;
    min-height: 0;
    font-size: 12px;
    color: var(--muted);
  }

  .index-panel.open-filter-popup .filter-toggle-btn,
  .index-panel.open-search-popup .search-toggle-btn {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 16%, var(--card) 84%);
  }
  
  .search-toggle-btn.has-active {
    background: color-mix(in srgb, var(--accent) 12%, var(--card) 88%);
  }
}

@media (max-width: 900px) {
  .container {
    width: 100%;
    max-width: 100%;
    padding-left: 12px;
    padding-right: 12px;
    margin: 0;
  }

  .main-layout {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100%;
    gap: 12px;
    padding: 14px 0 28px;
  }

  .site-header {
    padding: 12px 0 10px;
  }

  .header-banner {
    margin-bottom: 12px;
    border-radius: 12px;
  }

  .site-identity {
    min-width: 0;
  }

  .content-column,
  #posts,
  #viewer,
  #about {
    width: 100%;
    max-width: 100%;
    margin: 0;
  }

  .card {
    border-radius: 14px;
  }

  .site-title-row {
    display: grid;
    grid-template-columns: 1fr;
    align-items: flex-start;
    gap: 10px;
  }

  .site-title-row > div:first-child {
    min-width: 0;
  }

  .site-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-left: 0;
    width: 100%;
    min-width: 0;
  }

  .utility-bar {
    order: 2;
  }

  .auth-controls {
    display: grid;
    justify-items: end;
    gap: 8px;
    width: auto;
    order: 1;
  }

  #theme-toggle.theme-toggle-icon {
    width: 38px;
    height: 38px;
    padding: 0;
  }

  .theme-icon {
    font-size: 16px;
  }

  .utility-bar {
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    flex-wrap: nowrap;
    width: auto;
  }

  .auth-row {
    width: auto;
    justify-content: flex-end;
  }

  #login-btn,
  #user-session {
    order: 1;
  }

  #theme-toggle {
    order: 2;
  }

  .auth-note {
    max-width: none;
  }

  .site-header h1 {
    margin: 0 0 4px;
    font-size: 20px;
    line-height: 1.25;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .site-header p {
    margin: 0;
    font-size: 13px;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .viewer-toolbar {
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
  }

  .markdown-body h1 {
    font-size: 1.38rem;
    line-height: 1.2;
    margin-bottom: 0.56em;
  }

  .viewer-toolbar-right {
    width: 100%;
  }

  .post-fab-actions {
    right: 12px;
    bottom: calc(14px + env(safe-area-inset-bottom));
  }

  #viewer:not(.hidden) .post-nav-fab-actions {
    display: flex !important;
    left: 12px;
    bottom: calc(14px + env(safe-area-inset-bottom));
    gap: 8px;
  }

  #viewer.hidden .post-nav-fab-actions {
    display: none !important;
  }

  .list-refresh-fab-wrap {
    left: 12px;
    bottom: calc(14px + env(safe-area-inset-bottom));
  }

  .post-share-btn {
    display: inline-flex;
  }

  .post-fab-btn {
    padding: 9px 14px;
    font-size: 13px;
  }

  .post-nav-fab-btn {
    width: 42px;
    height: 42px;
    font-size: 18px;
  }

  .index-panel {
    position: fixed;
    right: 12px;
    top: auto;
    bottom: calc(14px + env(safe-area-inset-bottom));
    z-index: 9999;
    width: auto;
    order: initial;
    padding: 0;
    border: none;
    background: transparent;
    pointer-events: none;
  }

  .index-panel-head {
    justify-content: flex-end;
    pointer-events: auto;
  }

  .index-panel .filter-title {
    display: none;
  }

  .index-panel-actions {
    position: fixed;
    right: 12px;
    bottom: calc(14px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    pointer-events: auto;
    z-index: 10000;
  }

  body.post-view-active .index-panel-actions .search-toggle-btn {
    display: none;
  }

  body.post-view-active .search-panel {
    display: none !important;
  }

  .filter-toggle-btn,
  .search-toggle-btn {
    position: static;
    border-radius: 999px;
    padding: 8px 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(6px);
    background: color-mix(in srgb, var(--card) 90%, black 10%);
    border-color: var(--border);
    color: var(--text);
    min-width: 60px;
    font-size: 13px;
    touch-action: manipulation;
  }

  .index-panel-body,
  .search-panel {
    position: fixed;
    right: 12px;
    bottom: calc(102px + env(safe-area-inset-bottom));
    width: min(90vw, 360px);
    margin-top: 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: color-mix(in srgb, var(--card) 92%, black 8%);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    max-height: 58vh;
    overflow: auto;
    pointer-events: auto;
    z-index: 9998;
  }

  .search-panel {
    padding: 10px 12px;
    max-height: none;
  }

  .search-panel .search-filter {
    gap: 8px;
  }

  .search-panel .search-input,
  .search-panel .search-reset-btn {
    min-height: 42px;
    font-size: 16px;
  }

  .search-reset-btn,
  .filter-action-btn,
  .date-filter-trigger {
    touch-action: manipulation;
  }

  .date-filter-panel {
    position: fixed;
    left: 12px;
    right: 12px;
    top: 50%;
    width: min(calc(100vw - 24px), 420px);
    margin: 0 auto;
    transform: translateY(-50%);
    padding: 16px;
    max-height: min(76vh, 560px);
    overflow: auto;
    border-radius: 18px;
    z-index: 10030;
  }

  .calendar-head {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .calendar-title {
    width: 100%;
    gap: 10px;
  }

  .calendar-select {
    flex: 1 1 0;
    min-width: 0;
    padding: 8px 10px;
    font-size: 15px;
  }

  .calendar-nav {
    justify-content: flex-end;
  }

  .calendar-nav button {
    width: 34px;
    height: 34px;
    font-size: 18px;
  }

  .calendar-week {
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
  }

  .calendar-grid {
    gap: 8px;
  }

  .calendar-day {
    height: 50px;
    font-size: 16px;
    gap: 2px;
  }

  .calendar-day-count {
    font-size: 11px;
  }

  .calendar-actions {
    margin-top: 12px;
  }

  .calendar-actions button {
    min-height: 42px;
    font-size: 15px;
  }

  .index-panel.collapsed-mobile .index-panel-body {
    display: none;
  }

  .index-panel.open-filter-popup .filter-toggle-btn {
    border-color: var(--accent);
  }

  .index-panel.open-search-popup .search-toggle-btn {
    border-color: var(--accent);
  }

  .chips {
    gap: 6px;
  }

  .chip {
    padding: 4px 9px;
    font-size: 12px;
  }

  .post-card {
    padding: 18px;
  }

  #posts.card,
  #viewer.card,
  #about.card {
    padding: 16px;
  }

  .post-card-title-row {
    gap: 12px;
  }

  .post-link {
    font-size: 17px;
  }

  .post-date {
    font-size: 12px;
    padding-top: 2px;
  }

  .post-summary {
    margin-top: 16px;
  }
}

@media print {
  .site-header,
  .site-footer,
  #posts,
  #about,
  #index-panel,
  .viewer-toolbar,
  .post-fab-actions,
  #filter-toggle {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
  }

  .container,
  .main-layout,
  .content-column,
  #viewer,
  #post-content {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .main-layout,
  .content-column {
    display: block !important;
  }

  #viewer {
    display: block !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
  }

  .markdown-body {
    color: #000 !important;
  }

  .markdown-body a {
    color: #000 !important;
    text-decoration: none !important;
  }
}
