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

body {
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft Yahei", sans-serif;
  color: #fff;
  background: #020826 url("../assets/bg-main.png") no-repeat center top;
  background-size: cover;
  overflow: hidden;
}

body.role-story-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body.wechat-home {
  background: #f5f6f4;
  color: #1f2937;
  overflow: hidden;
}

.wechat-shell {
  width: min(420px, 100%);
  margin: 0 auto;
  min-height: 100vh;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f5f6f4;
  position: relative;
}

.wechat-topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(180deg, #fbfbf8, #f2f3f0);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.wechat-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: 2px;
}

.wechat-logo-text {
  font-size: 16px;
}

.wechat-logo-text .logo-limi {
  color: #79c3ff;
  text-transform: uppercase;
  font-weight: 900;
  letter-spacing: 2px;
}

.wechat-logo-text .logo-chat {
  color: #ffffff;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 2px;
  -webkit-text-stroke: 0.6px #1f2937;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
  margin-left: 2px;
}

.wechat-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0 16px;
  scrollbar-width: none;
}
.wechat-list::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.wechat-empty {
  padding: 48px 24px;
  text-align: center;
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  justify-content: center;
}

.wechat-empty-btn {
  min-width: 120px;
}

.wechat-chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  background: #f5f6f4;
  cursor: pointer;
  transition: background 0.15s ease;
}

.wechat-chat-item:hover {
  background: #f8fafc;
}

.wechat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(135deg, #e2e8f0, #c7d2fe);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #475569;
  flex-shrink: 0;
}

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

.wechat-chat-main {
  flex: 1;
  min-width: 0;
}

.wechat-chat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.wechat-chat-name {
  font-size: 15px;
  font-weight: 600;
  color: #1f2937;
}

.wechat-chat-time {
  font-size: 12px;
  color: #9ca3af;
}

.wechat-chat-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.wechat-chat-last {
  font-size: 13px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.wechat-chat-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wechat-chat-badge.show {
  display: inline-flex;
}

.wechat-tabbar {
  height: 62px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  background: #ffffff;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.wechat-tab {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 12px;
  color: #64748b;
  cursor: pointer;
}

.wechat-tab img {
  width: 22px;
  height: 22px;
}

.wechat-tab.active {
  color: #1f2937;
  font-weight: 600;
}

.wechat-hidden-reset {
  position: fixed;
  left: 18px;
  top: 55%;
  transform: translateY(-50%);
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 6px;
  background: transparent;
  opacity: 0;
  cursor: pointer;
  z-index: 5;
}
.wechat-hidden-reset:hover {
  outline: none;
}

/* Sidebar */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 16px;
  z-index: 10;
}

.sidebar-title {
  font-size: 22px;
  letter-spacing: 1px;
  font-weight: 800;
  margin-bottom: 28px;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.view-toggle-wrap {
  margin-top: 22px;
  width: 100%;
  display: flex;
  justify-content: center;
}

.view-toggle {
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.35);
  color: #e5e7eb;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.view-toggle:hover {
  background: rgba(15, 23, 42, 0.6);
  border-color: rgba(148, 163, 184, 0.9);
  transform: translateY(-1px);
}

.nav-item {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.nav-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 74px;
  height: 74px;
  border-radius: 999px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.nav-icon-wrap img {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.nav-item .nav-icon-wrap {
  transform: scale(0.9);
}

.nav-item.active .nav-icon-wrap {
  transform: scale(1.08);
  box-shadow: 0 0 12px rgba(255, 230, 180, 0.45);
}

.nav-item:hover .nav-icon-wrap {
  transform: scale(1.02);
}
.chat-unread-dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #ef4444;
  display: none;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.8);
}
.chat-unread-dot.show {
  display: block;
}

/* Main scrollable area */
.main-scroll {
  position: absolute;
  left: 180px;
  top: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  padding: 24px 40px 40px;
  z-index: 5;
}

/* Content wrapper used on multiple pages */
.content-area {
  max-width: 1032px;
  margin: 0 auto;
}

/* Hero section */
.hero {
  margin-bottom: 32px;
}

.hero-inner {
  position: relative;
  width: 100%;
  padding-top: 31%;
  border-radius: 26px;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 20%, #4f46e5, #15163b 55%, #020617);
  background-size: cover;
}

.hero-btn {
  position: absolute;
  left: 50%;
  top: 65%;
  transform: translate(-50%, -50%);
  padding: 14px 40px;
  border-radius: 999px;
  border: none;
  font-size: 18px;
  letter-spacing: 1px;
  cursor: pointer;
  background: linear-gradient(90deg, #a855f7, #3b82f6);
  color: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.hero-btn:hover {
  transform: translate(-50%, -52%);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.7);
  opacity: 0.95;
}

/* Gallery grid */
.gallery {
  padding-bottom: 40px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.gallery-item {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 20px;
  overflow: hidden;
  background: radial-gradient(circle at 10% 0%, #1f2937, #020617);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.7);
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.75);
  opacity: 0.96;
}

/* Auto Flow page */
.autoflow-page {
  max-width: 1200px;
}
.autoflow-hero {
  margin: 8px 0 28px;
}
.autoflow-hero h1 {
  font-size: 34px;
  margin-bottom: 8px;
}
.autoflow-hero p {
  color: rgba(226, 232, 240, 0.7);
}
.autoflow-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}
.autoflow-card {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 280px;
}
.autoflow-card h3 {
  margin-bottom: 4px;
}
.autoflow-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  background: rgba(2, 6, 23, 0.6);
  overflow: hidden;
}
.autoflow-preview.autoflow-thumb {
  width: 140px;
  height: 90px;
  aspect-ratio: auto;
}
.autoflow-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.autoflow-status {
  padding: 12px;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.6);
}
.autoflow-metrics {
  font-size: 13px;
  line-height: 1.6;
  color: rgba(226, 232, 240, 0.8);
}
.autoflow-output img {
  width: 100%;
  border-radius: 12px;
  background: #0f172a;
  cursor: pointer;
}
.autoflow-output-meta {
  font-size: 12px;
  color: rgba(226, 232, 240, 0.8);
}
.autoflow-output-meta pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(15, 23, 42, 0.6);
  padding: 10px;
  border-radius: 10px;
  margin-top: 6px;
}
.autoflow-output-controls {
  display: flex;
  gap: 12px;
  margin-top: 6px;
}
.autoflow-node-group {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 12px;
  background: rgba(2, 6, 23, 0.35);
}
.autoflow-node-title {
  font-size: 13px;
  color: rgba(226, 232, 240, 0.7);
  margin-bottom: 8px;
}
.autoflow-action-row {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
}
.autoflow-logs {
  margin-top: 24px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 16px;
  padding: 18px;
}
.autoflow-log-board {
  max-height: 280px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.6;
  color: rgba(226, 232, 240, 0.85);
  white-space: pre-wrap;
}
.autoflow-config {
  margin-top: 24px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 16px;
  padding: 18px;
}
.autoflow-config-block {
  margin-top: 18px;
  padding: 12px 0;
  border-top: 1px solid rgba(148, 163, 184, 0.15);
}
.autoflow-config label {
  display: block;
  margin-bottom: 10px;
}
.autoflow-config input,
.autoflow-config textarea {
  width: 100%;
  background: rgba(2, 6, 23, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: #fff;
  padding: 8px 10px;
  border-radius: 10px;
}

.autoflow-note-modal {
  width: 520px;
  max-width: 90%;
  gap: 16px;
}
.autoflow-note-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.autoflow-note-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(2, 6, 23, 0.6);
}
.autoflow-note-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}
.autoflow-note-text {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 12px;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  color: rgba(226, 232, 240, 0.9);
}
.autoflow-image-modal {
  width: 90vw;
  max-width: 1000px;
}
.autoflow-image-modal img {
  width: 100%;
  border-radius: 16px;
  background: #0f172a;
}
.autoflow-image-modal img {
  max-height: 85vh;
  object-fit: contain;
}
#theater-image-modal .autoflow-image-modal {
  width: 95vw;
  max-width: 1200px;
}
#theater-image-modal .autoflow-image-modal img {
  max-height: 90vh;
}

@media (max-width: 960px) {
  .autoflow-grid {
    grid-template-columns: 1fr;
  }
}

/* Upload modal backdrop */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-backdrop.show {
  display: flex;
}

/* Upload modal */
.modal {
  width: 540px;
  max-width: calc(100% - 40px);
  background: linear-gradient(145deg, #020617, #020617d9);
  border-radius: 18px;
  padding: 24px 28px 20px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.3);
  display: flex;
  flex-direction: column;
}

/* Greeting test modal */
#greeting-test-modal .modal {
  max-height: 85vh;
}
#greeting-test-modal .modal-body {
  overflow-y: auto;
  max-height: 55vh;
}
#greeting-test-result .test-raw {
  white-space: pre-wrap;
  word-break: break-word;
}

.modal.small {
  width: 420px;
}

.modal-header {
  font-size: 18px;
  margin-bottom: 18px;
}

.modal-body {
  padding: 8px 0 16px;
}

.upload-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.upload-slot {
  width: 110px;
  height: 80px;
  border-radius: 12px;
  border: 1px dashed rgba(148, 163, 184, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #94a3b8;
  font-size: 32px;
}

.upload-thumb {
  position: relative;
  width: 110px;
  height: 80px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
}

.upload-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: none;
  background: rgba(15, 23, 42, 0.86);
  color: #cbd5f5;
  font-size: 12px;
  cursor: pointer;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.upload-progress {
  flex: 1;
  height: 8px;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
  align-self: center;
  min-width: 120px;
}

.upload-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7aa2ff, #6b7bff);
  transition: width 0.1s ease;
}

.upload-status {
  flex: 1;
  color: #cbd5f5;
  font-size: 12px;
  align-self: center;
}

.upload-error {
  flex: 1;
  color: #fda4af;
  font-size: 13px;
  min-height: 18px;
  align-self: center;
}

.login-form label {
  display: block;
  margin-bottom: 10px;
}

.login-form input {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: #0b1224;
  color: #e5e7eb;
}

.login-form .code-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.login-error {
  color: #fca5a5;
  min-height: 18px;
  font-size: 13px;
}

.modal.small .modal-body {
  padding: 8px 0 4px;
}

.invite-text {
  white-space: pre-wrap;
  margin-bottom: 10px;
  color: #e5e7eb;
}

.btn {
  min-width: 88px;
  height: 34px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-size: 14px;
}

.btn.plain {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.7);
  color: #e5e7eb;
}

.btn.primary {
  background: linear-gradient(90deg, #6366f1, #a855f7);
  color: #fff;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.2);
}

/* ============== Responsive tweaks ============== */
@media (max-width: 1024px) {
  .sidebar {
    width: 120px;
    padding-top: 24px;
  }
  .nav-icon-wrap {
    width: 60px;
    height: 60px;
  }
  .main-scroll {
    left: 120px;
    padding: 16px 20px 28px;
  }
  .gallery-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
  }
  .hero-btn {
    width: 70%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
  .modal,
  .note-modal {
    width: 90vw;
    max-width: 600px;
    padding: 16px;
  }
  .modal-footer {
    flex-wrap: wrap;
    justify-content: center;
  }
  .modal-footer .btn {
    min-width: 120px;
  }
}

@media (max-width: 768px) {
  body {
    background: #020826 url("../assets/bg-main-phone.jpg") no-repeat center top;
    background-size: cover;
    font-size: 80%;
  }
  .nav-icon-wrap img[src$="icon-square.png"],
  .nav-icon-wrap img[src$="icon-note.png"],
  .nav-icon-wrap img[src$="icon-message.png"],
  .nav-icon-wrap img[src$="icon-login.png"] {
    transform: scale(1.25);
    transform-origin: center;
  }
  .sidebar {
    width: 72px;
    padding-top: 16px;
  }
  .sidebar-title {
    display: none;
  }
  .nav-icon-wrap {
    width: 52px;
    height: 52px;
  }
  .main-scroll {
    left: 72px;
    padding: 12px 14px 24px;
  }
  .content-area {
    margin: 0;
    width: 100%;
  }
  .hero-inner {
    padding-top: 45%;
  }
  .hero-btn {
    width: 80%;
    font-size: 16px;
    padding: 12px 0;
  }
  .gallery-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
  }
  .note-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .note-paper-thumb {
    width: 100%;
    max-width: 260px;
    height: auto;
    aspect-ratio: 16 / 9;
  }
  .note-outer-text {
    width: 100%;
  }
  .note-modal,
  .modal {
    width: 92vw;
    padding: 14px;
  }
  .note-modal {
    max-height: 90vh;
  }
  .modal-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .modal-footer .btn {
    width: 100%;
  }
  .upload-list {
    gap: 10px;
  }
  .upload-slot,
  .upload-thumb {
    width: 100%;
    max-width: 220px;
  }
  .paper-card-large {
    max-width: 100%;
  }
  .note-modal-hint {
    font-size: 12px;
  }
  .login-form input,
  .invite-text {
    font-size: 14px;
  }
  .view-toggle-wrap {
    display: none;
  }
  .wechat-shell .notes-page {
    padding: 10px 12px 20px;
  }
  .wechat-shell .notes-day-body {
    padding: 12px 14px;
  }
  .invite-card-text {
    height: 60px;
    font-size: 13px;
  }
}

/* Force mobile view on desktop */
body.force-mobile {
  background: #020826 url("../assets/bg-main-phone.jpg") no-repeat center top;
  background-size: cover;
  font-size: 80%;
  width: min(390px, 100vw);
  height: min(844px, 100vh);
  margin: 16px auto;
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.55);
}

body.force-mobile .nav-icon-wrap img[src$="icon-square.png"],
body.force-mobile .nav-icon-wrap img[src$="icon-note.png"],
body.force-mobile .nav-icon-wrap img[src$="icon-message.png"],
body.force-mobile .nav-icon-wrap img[src$="icon-login.png"] {
  transform: scale(1.25);
  transform-origin: center;
}

body.force-mobile .sidebar {
  position: absolute;
  width: 72px;
  padding-top: 16px;
}

body.force-mobile .sidebar-title {
  display: none;
}

body.force-mobile .nav-icon-wrap {
  width: 52px;
  height: 52px;
}

body.force-mobile .main-scroll {
  position: absolute;
  left: 72px;
  padding: 12px 14px 24px;
}

body.force-mobile .content-area {
  margin: 0;
  width: 100%;
}

body.force-mobile .hero-inner {
  padding-top: 45%;
}

body.force-mobile .hero-btn {
  width: 80%;
  font-size: 16px;
  padding: 12px 0;
}

body.force-mobile .gallery-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

body.force-mobile .note-item {
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

body.force-mobile .note-paper-thumb {
  width: 100%;
  max-width: 260px;
  height: auto;
  aspect-ratio: 16 / 9;
}

body.force-mobile .note-outer-text {
  width: 100%;
}

body.force-mobile .note-modal,
body.force-mobile .modal {
  width: 92vw;
  padding: 14px;
}

body.force-mobile .note-modal {
  max-height: 90vh;
  width: calc(100% - 24px);
  max-width: none;
}

body.force-mobile #note-modal .paper-card-large,
body.force-mobile #note-modal .paper-inner,
body.force-mobile #note-modal .paper-face,
body.force-mobile #note-modal .paper-front {
  transform: none !important;
  transition: none !important;
  backface-visibility: visible !important;
}

body.force-mobile #note-modal .paper-card-large {
  display: none;
}

body.force-mobile #note-modal .paper-card-large.mobile-paper {
  display: block;
}

body.force-mobile .modal-footer {
  flex-direction: column;
  align-items: stretch;
}

body.force-mobile .modal-footer .btn {
  width: 100%;
}

body.force-mobile .upload-list {
  gap: 10px;
}

body.force-mobile .upload-slot,
body.force-mobile .upload-thumb {
  width: 100%;
  max-width: 220px;
}

body.force-mobile .paper-card-large {
  max-width: 100%;
  height: 68vh;
  padding-top: 0;
  overflow: visible;
}

body.force-mobile .paper-card-large .paper-inner,
body.force-mobile .paper-face,
body.force-mobile .paper-front {
  height: 100%;
}

body.force-mobile .note-modal-front {
  height: 100%;
}

body.force-mobile .note-modal-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

body.force-mobile .note-modal-hint {
  font-size: 12px;
}

body.force-mobile .login-form input,
body.force-mobile .invite-text {
  font-size: 14px;
}

body.force-mobile .modal-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

body.force-mobile .view-toggle {
  font-size: 11px;
  padding: 5px 10px;
}

/* Preview modal */
.preview-modal-inner {
  position: relative;
  max-width: 70vw;
  max-height: 70vh;
  border-radius: 18px;
  overflow: hidden;
  background: #020617;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.9);
}

#preview-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

#chat-image-modal .preview-modal-inner {
  width: auto;
  max-width: calc(100% - 48px);
  max-height: calc(100% - 48px);
  margin: 0 24px;
}
#chat-image-modal #chat-image-preview {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

#sim-image-modal .preview-modal-inner {
  width: auto;
  max-width: calc(100% - 48px);
  max-height: calc(100% - 48px);
  margin: 0 24px;
}
#sim-image-modal #sim-image-preview {
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 48px);
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.preview-close {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: none;
  background: rgba(15, 23, 42, 0.85);
  color: #e5e7eb;
  font-size: 18px;
  cursor: pointer;
}

/* Notes page styles */
.notes-page {
  padding-top: 32px;
  padding-bottom: 40px;
}

.notes-day {
  margin-bottom: 32px;
}

.notes-date {
  font-size: 20px;
  color: #b09474;
  margin-bottom: 12px;
}

.notes-day-body {
  background: radial-gradient(circle at 0% 0%, #111827, #020617);
  border-radius: 18px;
  padding: 16px 20px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.7);
}

.note-item {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.6);
  cursor: pointer;
}

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

.note-outer-text {
  font-size: 14px;
  color: #b09474;
  line-height: 1.6;
}

.note-paper-thumb {
  position: relative;
  width: 160px;
  height: 90px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.8);
  background: #000;
}

.note-paper-thumb .paper-inner {
  width: 100%;
  height: 100%;
  position: relative;
}

.note-paper-thumb .paper-front,
.note-paper-thumb .paper-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.note-paper-thumb .paper-front {
  background: #fdf7ec;
  color: #4b5563;
  font-size: 13px;
  padding: 10px 12px;
}

.note-paper-thumb .paper-back {
  background-color: #000;
  display: none;
}

.note-paper-thumb .paper-back img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  image-rendering: crisp-edges;
}

.note-paper-thumb.is-back .paper-front {
  display: none;
}

.note-paper-thumb.is-back .paper-back {
  display: block;
}

.notes-pending-bar {
  padding: 12px 0 4px;
  font-size: 14px;
  color: #b09474;
  opacity: 0.9;
}

/* Notes page (wechat layout) */
.wechat-shell .notes-page {
  padding: 12px 16px 24px;
  max-width: 520px;
  margin: 0 auto;
  color: #1f2937;
}

.invite-note {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 6px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  cursor: pointer;
}

.invite-note:last-child {
  border-bottom: none;
}

.invite-thumb {
  width: 92px;
  height: 76px;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(135deg, #e2e8f0, #f8fafc);
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12);
}

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

.invite-thumb.is-empty {
  background: linear-gradient(135deg, #e2e8f0, #cbd5f5);
}

.invite-card-text {
  flex: 1;
  font-size: 14px;
  line-height: 1.55;
  color: #334155;
  white-space: pre-wrap;
  word-break: break-word;
  height: 66px;
  overflow: hidden;
}

.wechat-shell .notes-date {
  color: #475569;
  font-weight: 600;
}

.wechat-shell .notes-day-body {
  background: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

.wechat-shell .note-item {
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.wechat-shell .note-outer-text,
.wechat-shell .notes-pending-bar {
  color: #64748b;
}

.wechat-shell .note-paper-thumb {
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.18);
}

.note-modal-front {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 22px;
  min-height: 0;
}

.note-modal-title {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 2px;
  text-align: center;
}

.note-modal-body {
  flex: 1;
  overflow-y: auto;
  font-size: 14px;
  color: #1f2937;
  line-height: 1.7;
  white-space: pre-wrap;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  min-height: 0;
}

.note-modal-body .invite-plot {
  color: #9aa0aa;
  font-style: italic;
  margin: 2px 0;
}

.note-modal-body .invite-dialog {
  color: #1f2937;
  margin: 2px 0;
}

.note-modal-body .invite-dialog-name {
  font-weight: 600;
  margin-right: 4px;
}

.note-modal .note-flip-btn {
  background: linear-gradient(90deg, #5b8cff, #7c6cff);
  box-shadow: 0 10px 24px rgba(91, 140, 255, 0.35);
}

/* Large note modal for flipping */
.note-modal {
  position: relative;
  width: 640px;
  max-width: calc(100% - 40px);
  max-height: 86vh;
  background: #020617ee;
  border-radius: 20px;
  padding: 24px 24px 22px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.paper-card-large {
  width: 100%;
  max-width: 520px;
  height: 0;
  padding-top: 56.25%; /* 16:9 */
  position: relative;
  overflow: hidden;
  perspective: 1200px;
}

.paper-card-large.mobile-paper {
  display: none;
  height: auto;
  padding-top: 0;
  background: #fdf7ec;
  border-radius: 20px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.9);
}

.paper-card-large.mobile-paper .note-modal-front {
  padding: 18px 20px;
  height: auto;
  max-height: 60vh;
}

.paper-card-large.mobile-paper .note-modal-body {
  max-height: 50vh;
  overflow-y: auto;
}

.paper-card-large .paper-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
}

.paper-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
}

.paper-front {
  background: #fdf7ec;
  color: #4b5563;
  align-items: stretch;
  justify-content: stretch;
}

.paper-front-text {
  padding: 24px 28px;
  font-size: 16px;
  color: #4b5563;
  line-height: 1.8;
  max-height: 100%;
  overflow-y: auto;
}

.paper-back {
  background: #020617;
  transform: rotateY(180deg);
}

.paper-back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.paper-card-large.flipped .paper-inner {
  transform: rotateY(180deg);
}

.note-modal-hint {
  color: #94a3b8;
  font-size: 13px;
  margin-top: 6px;
  text-align: center;
}

.flip-btn {
  align-self: center;
  margin-top: 6px;
}

.image-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.4);
  font-size: 14px;
  z-index: 2;
}

.image-loading.error {
  background: rgba(127, 29, 29, 0.65);
  color: #fee2e2;
}

/* Admin page */
.admin-page {
  padding-top: 32px;
  padding-bottom: 40px;
}

.admin-section {
  margin-bottom: 32px;
}

.admin-section h2 {
  font-size: 20px;
  margin-bottom: 12px;
  color: #b09474;
}

.admin-section label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
}
.flow-mode-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.flow-mode-row label {
  margin-bottom: 0;
}
.flow-mode-link {
  padding: 6px 12px;
  height: auto;
}
.admin-subtitle {
  margin: 12px 0 8px;
  font-size: 14px;
  font-weight: 700;
  color: #cbd5f5;
}
.greeting-provider-block {
  display: none;
  padding: 8px 0 0;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  margin-top: 6px;
}
.admin-tip {
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}

.admin-auth-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.admin-auth-modal.show {
  display: flex;
}
.admin-auth-dialog {
  background: #0f172a;
  padding: 24px;
  border-radius: 12px;
  width: 320px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

#chat-role-modal .admin-auth-dialog {
  max-height: min(84vh, 720px);
  overflow-y: auto;
}
.admin-auth-dialog h2 {
  margin-top: 0;
  margin-bottom: 12px;
}
.admin-auth-dialog input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  margin-bottom: 12px;
}
.admin-auth-msg {
  min-height: 18px;
  color: #f87171;
  font-size: 13px;
  margin-bottom: 8px;
}
.admin-tip {
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}

.admin-auth-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.admin-auth-modal.show {
  display: flex;
}
.admin-auth-dialog {
  background: #0f172a;
  padding: 24px;
  border-radius: 12px;
  width: 320px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.admin-auth-dialog h2 {
  margin-top: 0;
  margin-bottom: 12px;
}
.admin-auth-dialog input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  margin-bottom: 12px;
}
.admin-auth-msg {
  min-height: 18px;
  color: #f87171;
  font-size: 13px;
  margin-bottom: 8px;
}

.admin-head-preview {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.7);
  margin-bottom: 12px;
}

.admin-head-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.admin-samples {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.admin-sample-item {
  position: relative;
  width: 150px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.7);
}

.admin-sample-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.admin-sample-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  border: none;
  color: #e5e7eb;
  font-size: 14px;
  cursor: pointer;
}

.admin-role-preview {
  width: 100%;
  max-width: 320px;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.7);
  margin-bottom: 8px;
}

.admin-role-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.admin-role-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.admin-avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.6);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  margin-bottom: 8px;
}

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

.admin-avatar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.admin-file-input {
  margin-top: 8px;
  margin-bottom: 16px;
}

.admin-test-workflow {
  margin-top: 12px;
}

#workflow-test-modal {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.78);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 80;
}

#workflow-test-modal.show {
  display: flex;
}

#workflow-test-modal .modal-content {
  position: relative;
  width: 560px;
  max-width: calc(100% - 40px);
  background: #020617f2;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 18px;
  padding: 18px 18px 22px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.9);
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: none;
  background: rgba(15, 23, 42, 0.85);
  color: #e5e7eb;
  font-size: 18px;
  cursor: pointer;
}

#workflow-test-result .test-preview {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

#workflow-test-result img {
  max-width: 100%;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.8);
}

#workflow-test-result .test-text {
  width: 100%;
  background: #0b1224;
  border-radius: 12px;
  padding: 12px 14px;
  color: #e5e7eb;
  line-height: 1.6;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

/* Responsive tweaks */
@media (max-width: 1400px) {
  .main-scroll {
    padding: 20px 20px 32px;
  }
}

@media (max-width: 1200px) {
  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.image-preview-modal .preview-modal-inner,
#image-preview-modal .preview-modal-inner {
  max-width: 95vw;
  max-height: 95vh;
}

#image-preview-img {
  max-width: 95vw;
  max-height: 90vh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

/* 弹窗小图居中裁切，避免顶部对齐 */
#note-modal .paper-back img {
  width: 100% !important;
  height: 100% !important;
  display: block !important;
  object-fit: cover !important;
  object-position: center 40% !important;
}

/* Ensure modal (view mode) image在16:9容器内居中裁切 */
#paper-back-image {
  object-fit: cover;
  object-position: center center;
}


/* ===== 缩略图强制显示图片（关键修复） ===== */
.note-paper-thumb .paper-back {
  background: transparent !important;
  position: relative !important;
  z-index: 1 !important;
}

.note-paper-thumb .paper-back img {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  display: block !important;
  object-fit: cover !important;
  object-position: center !important;
  z-index: 9999 !important;
  opacity: 1 !important;
  mix-blend-mode: normal !important;
  filter: none !important;
}

/* 缩略图前后面层级/显示控制，避免被覆盖后只剩黑底 */
.note-paper-thumb .paper-front {
  z-index: 2;
}
.note-paper-thumb .paper-back {
  z-index: 1;
  opacity: 0;
}
.note-paper-thumb.is-back .paper-front {
  display: none;
}
.note-paper-thumb.is-back .paper-back {
  opacity: 1;
}
