:root {
  --bg: #f5f5f5;
  --surface: #ffffff;
  --line: #efefef;
  --text: #222;
  --muted: #8a8a8a;
  --accent: #ff2442;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  font-family:
    "PingFang SC",
    "Hiragino Sans GB",
    "Microsoft YaHei",
    sans-serif;
}

body.viewer-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  background: none;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  width: 252px;
  height: 100vh;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
}

.logo {
  width: 64px;
  height: 32px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.main-nav {
  display: grid;
  gap: 4px;
  margin-top: 24px;
}

.nav-item {
  height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border-radius: 14px;
  color: #333;
  font-size: 16px;
  font-weight: 600;
  transition: background 0.15s;
}

.nav-item:hover { background: rgba(0,0,0,0.04); }

.nav-item.active {
  background: #fff;
  box-shadow: 0 0 0 1px #ebebeb inset;
}

.nav-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: #333;
}

/* search button */
.search-btn {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #888;
  cursor: pointer;
  transition: background 0.15s;
}
.search-btn:hover { background: #f0f0f0; color: #333; }

.primary-button,
.follow-button {
  height: 44px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.primary-button {
  margin-top: 18px;
}

.login-card {
  margin-top: 10px;
  background: #fff;
  border-radius: 18px;
  padding: 18px 16px;
  box-shadow: 0 0 0 1px #ededed inset;
}

.login-card h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.login-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.9;
  font-size: 14px;
}

.more-button {
  margin-top: auto;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 14px;
  color: #444;
}

.page {
  flex: 1;
  padding: 16px 18px 26px 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.search {
  position: relative;
  width: 434px;
}

.search input {
  width: 100%;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  padding: 0 42px 0 18px;
  box-shadow: 0 0 0 1px #ededed inset;
  outline: none;
}

.search-icon {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  color: #9d9d9d;
}

.topbar-actions {
  display: flex;
  gap: 12px;
}

.topbar-actions button {
  height: 40px;
  padding: 0 18px;
  background: #fff;
  border-radius: 999px;
  box-shadow: 0 0 0 1px #ededed inset;
  font-weight: 600;
}

.detail-shell {
  display: grid;
  grid-template-columns: minmax(0, 660px) minmax(360px, 420px);
  gap: 0;
  width: min(1080px, calc(100vw - 320px));
  margin: 0 auto;
  height: calc(100vh - 112px);
  min-height: 480px;
  max-height: 810px;
  border-radius: 22px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.media-panel {
  background: #111;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.gallery-frame {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  overflow: hidden;
  background: #0d0d0d;
}

.main-image-button {
  display: flex;
  width: 100%;
  height: 100%;
  padding: 0;
  cursor: zoom-in;
}

.gallery-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.gallery-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.36);
  color: #fff;
  font-size: 28px;
  line-height: 38px;
  cursor: pointer;
  z-index: 1;
}

.gallery-arrow.left {
  left: 14px;
}

.gallery-arrow.right {
  right: 14px;
}

/* dot indicators (replaces text "1/4") */
.gallery-dots {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  align-items: center;
}

.gallery-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transition: background 0.2s, transform 0.2s;
}

.gallery-dot.active {
  background: #fff;
  transform: scale(1.25);
}

.thumbnail-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.thumb {
  height: 72px;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  opacity: 0.72;
}

.thumb.active {
  border-color: #fff;
  opacity: 1;
}

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

.content-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;       /* clips children — only content-scroll scrolls */
  padding: 0;
  position: relative;
}

.author-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;         /* never shrink — always visible at top */
  padding: 16px 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  z-index: 3;
}

.content-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 18px 20px 0;
}

.author-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar,
.comment-avatar img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.author-name {
  font-size: 16px;
  font-weight: 700;
}

.author-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.follow-button {
  width: 92px;
  flex: none;
}

.note-title {
  margin: 22px 0 14px;
  font-size: 22px;
  line-height: 1.35;
}

.note-desc {
  color: #333;
  font-size: 15px;
  line-height: 1.9;
}

.note-desc p {
  margin: 0 0 10px;
}

.topic-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 10px;
}

.topic-list a {
  color: #2f5fa9;
  font-size: 15px;
}

.publish-time {
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.comments-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.comment-note {
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f7f7f7;
  color: #8a8a8a;
  font-size: 13px;
  line-height: 1.6;
}

.comment-header {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
}

.comment-list {
  padding-right: 8px;
}

.comment {
  display: flex;
  gap: 12px;
  margin-bottom: 22px;
}

.comment-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex: none;
}

.gradient-a {
  background: linear-gradient(135deg, #ffb36c, #ff6a88);
}

.gradient-b {
  background: linear-gradient(135deg, #7dd3fc, #818cf8);
}

.gradient-c {
  background: linear-gradient(135deg, #86efac, #22c55e);
}

.gradient-d {
  background: linear-gradient(135deg, #f9a8d4, #f97316);
}

.gradient-e {
  background: linear-gradient(135deg, #d8b4fe, #60a5fa);
}

.gradient-f {
  background: linear-gradient(135deg, #fde68a, #f59e0b);
}

.small {
  width: 28px;
  height: 28px;
}

.comment-body {
  min-width: 0;
  flex: 1;
}

.comment-topline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.comment-user {
  font-weight: 600;
  color: #404040;
}

.comment-meta {
  color: var(--muted);
  font-size: 12px;
}

.author-badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #666;
  font-size: 11px;
}

.comment-body p {
  margin: 0;
  font-size: 14px;
  line-height: 1.8;
}

.comment-actions {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.sub-comment {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.expand-replies {
  margin-top: 10px;
  color: #5b7bb2;
  font-size: 13px;
  cursor: default;
}

.expand-replies.standalone {
  margin: -8px 0 18px 52px;
}

.author-avatar {
  overflow: hidden;
}

.action-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px 14px;
  border-top: 1px solid var(--line);
  background: #fff;
  flex-shrink: 0;         /* never shrink — always visible at bottom */
  z-index: 3;
}

.action-comment-trigger {
  flex: 1;
  min-width: 0;
  height: 38px;
  border-radius: 999px;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  padding: 0 16px;
  cursor: text;
  transition: background 0.15s;
}
.action-comment-trigger:hover { background: #efefef; }

.action-comment-placeholder {
  color: #b8b8b8;
  font-size: 14px;
  pointer-events: none;
}

.action-icon-group {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.action-btn:hover { background: #f5f5f5; }
.action-btn:active { opacity: 0.65; }

.action-btn-icon {
  font-size: 22px;
  line-height: 1;
  color: #444;
  display: block;
}

.action-btn-count {
  font-size: 11px;
  color: #999;
  line-height: 1;
  letter-spacing: 0.01em;
}

/* active states */
.action-btn.liked    .action-btn-icon { color: var(--accent); }
.action-btn.collected .action-btn-icon { color: #f59e0b; }

/* icon pop animation */
@keyframes icon-pop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.5); }
  70%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}
.icon-popping { animation: icon-pop 0.32s cubic-bezier(0.34, 1.56, 0.64, 1); }

/* ─── compose overlay ─────────────────────────────────────────────────────── */
.compose-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
}
.compose-overlay.hidden { display: none; }
.compose-overlay:not(.hidden) { pointer-events: auto; }

.compose-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.18);
  cursor: pointer;
}

.compose-panel {
  position: relative;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 12px 16px 20px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.08);
  animation: compose-slide-up 0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes compose-slide-up {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.compose-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: #f5f5f5;
  border-radius: 12px;
  padding: 9px 14px;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
}

.compose-send {
  height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.compose-send:hover  { opacity: 0.88; }
.compose-send:active { opacity: 0.72; }

/* ─── comment interactive enhancements ───────────────────────────────────── */
.comment-like-btn,
.comment-reply-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  margin-left: -6px;
  transition: background 0.12s, color 0.15s;
}
.comment-like-btn:hover  { background: #f5f5f5; }
.comment-reply-btn:hover { background: #f5f5f5; }
.comment-like-btn.liked  { color: var(--accent); }

/* inline reply box */
.reply-box {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
  animation: reply-fade-in 0.18s ease;
}

@keyframes reply-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.reply-field {
  flex: 1;
  height: 34px;
  border: 1px solid #e8e8e8;
  border-radius: 999px;
  padding: 0 14px;
  font: inherit;
  font-size: 13px;
  outline: none;
  background: #fafafa;
  color: var(--text);
  transition: border-color 0.15s;
}
.reply-field:focus { border-color: #bbb; background: #fff; }

.reply-submit-btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.reply-submit-btn:hover  { opacity: 0.88; }
.reply-submit-btn:active { opacity: 0.7; }

.viewer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.88);
}

.viewer.hidden {
  display: none;
}

.viewer-stage {
  position: relative;
  width: min(86vw, 980px);
  height: min(78vh, 880px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.viewer-close,
.viewer-arrow {
  position: fixed;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
}

.viewer-close {
  top: 28px;
  right: 32px;
  width: 44px;
  height: 44px;
  font-size: 28px;
  line-height: 44px;
}

.viewer-arrow {
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  font-size: 30px;
  line-height: 48px;
}

.viewer-arrow.left {
  left: 28px;
}

.viewer-arrow.right {
  right: 28px;
}

.viewer-indicator {
  position: absolute;
  right: 18px;
  bottom: 18px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 13px;
}

.viewer-thumb-row {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  width: min(520px, calc(100vw - 120px));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.viewer-thumb {
  height: 84px;
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid transparent;
  opacity: 0.66;
  cursor: pointer;
}

.viewer-thumb.active {
  border-color: #fff;
  opacity: 1;
}

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

@media (max-width: 1180px) {
  .sidebar {
    width: 220px;
  }

  .detail-shell {
    width: min(100%, calc(100vw - 256px));
    grid-template-columns: minmax(0, 1fr) 360px;
  }
}

/* ─── context bubble menu ─────────────────────────────────────────────────── */

#ctx-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 500;
}

.ctx-anchor {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(30, 30, 32, 0.45);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  border: 0.5px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.75);
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  z-index: 3;
  transition: background 0.15s;
}
.ctx-anchor:hover { background: rgba(40, 40, 44, 0.65); }

.ctx-bubble {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  border: none;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  z-index: 2;
}

/* icon bubble */
.ctx-icon {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(24px) saturate(1.8);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.1),
    0 0 0 0.5px rgba(255, 255, 255, 0.55) inset;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  overflow: visible;
  transition: transform 0.12s ease, opacity 0.12s;
}
/* 展示态 icon：不可交互，略微降透表达"可用但未接入" */
.ctx-icon-display {
  pointer-events: none;
  opacity: 0.82;
  cursor: default;
}

.ctx-ig { font-size: 18px; line-height: 1; }

.ctx-il {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: rgba(30, 30, 32, 0.75);
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(12px) saturate(1.5);
  -webkit-backdrop-filter: blur(12px) saturate(1.5);
  padding: 2px 6px;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  pointer-events: none;
  letter-spacing: 0.01em;
}

/* text pill bubble */
.ctx-text {
  height: 33px;
  padding: 0 12px 0 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(24px) saturate(1.8);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.09),
    0 0 0 0.5px rgba(255, 255, 255, 0.5) inset;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: #1c1c1e;
  white-space: nowrap;
  letter-spacing: 0.01em;
  transition: transform 0.12s ease, opacity 0.12s;
}
.ctx-text:hover  { filter: brightness(1.05); }
.ctx-text:active { opacity: 0.6; }

.ctx-spark { font-size: 9px; color: var(--accent); flex-shrink: 0; opacity: 0.9; }

/* press ring */
.ctx-ring {
  position: fixed;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 36, 66, 0.5);
  background: rgba(255, 36, 66, 0.07);
  pointer-events: none;
  z-index: 498;
  transform: translate(-50%, -50%) scale(0.2);
  opacity: 0;
}

/* AI loading dots */
.ctx-loader {
  position: absolute;
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, calc(-50% - 110px));
  pointer-events: none;
  z-index: 2;
}
.ctx-loader i {
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 36, 66, 0.5);
  animation: ctx-dot 0.72s ease-in-out infinite;
}
.ctx-loader i:nth-child(2) { animation-delay: 0.16s; }
.ctx-loader i:nth-child(3) { animation-delay: 0.32s; }

@keyframes ctx-dot {
  0%, 80%, 100% { transform: scale(0.5); opacity: 0.3; }
  40%           { transform: scale(1);   opacity: 1;   }
}

/* toast */
.ctx-toast {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: rgba(28, 28, 30, 0.82);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  color: #fff;
  padding: 9px 20px;
  border-radius: 999px;
  font-size: 13.5px;
  font-family: "PingFang SC", sans-serif;
  pointer-events: none;
  z-index: 600;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
  border: 0.5px solid rgba(255, 255, 255, 0.12);
}
.ctx-toast.ctx-toast-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ─── selection collapse flash ───────────────────────────────────────────── */
.aha-sel-flash {
  position: fixed;
  background: rgba(255, 36, 66, 0.18);
  border-radius: 3px;
  pointer-events: none;
  z-index: 498;
  transition: transform 0.34s cubic-bezier(0.55, 0, 1, 0.45), opacity 0.34s ease;
}

/* ─── aha chat sidebar ────────────────────────────────────────────────────── */

.aha-chat {
  position: fixed;
  top: 16px;
  right: 16px;
  bottom: 16px;
  width: 340px;
  border-radius: 20px;
  background: rgba(242, 242, 247, 0.82);
  backdrop-filter: blur(40px) saturate(1.8);
  -webkit-backdrop-filter: blur(40px) saturate(1.8);
  border: 0.5px solid rgba(255, 255, 255, 0.5);
  box-shadow:
    -4px 0 32px rgba(0, 0, 0, 0.1),
    0 8px 32px rgba(0, 0, 0, 0.08);
  z-index: 700;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(calc(100% + 24px));
  transition: transform 0.32s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              opacity 0.32s ease;
  opacity: 0;
}

.aha-chat.open {
  transform: translateX(0);
  opacity: 1;
}

.aha-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.07);
  flex-shrink: 0;
}

.aha-chat-title {
  font-weight: 700;
  font-size: 16px;
  color: #1c1c1e;
  letter-spacing: 0.01em;
}

.aha-chat-sub {
  font-size: 11px;
  color: #8e8e93;
  margin-top: 2px;
}

.aha-chat-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.07);
  color: #555;
  font-size: 17px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.aha-chat-close:hover { background: rgba(0, 0, 0, 0.12); }

.aha-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.aha-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.65;
  word-break: break-all;
  white-space: pre-wrap;
}

.aha-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 5px;
}

.aha-msg.ai {
  align-self: flex-start;
  background: #fff;
  color: #1c1c1e;
  border-bottom-left-radius: 5px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.07);
}

.aha-msg.streaming::after {
  content: '▋';
  opacity: 1;
  animation: aha-blink 0.75s step-end infinite;
  font-size: 12px;
  margin-left: 1px;
}

@keyframes aha-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.aha-chat-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 14px 16px;
  border-top: 0.5px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

.aha-chat-input {
  flex: 1;
  height: 38px;
  border: none;
  border-radius: 999px;
  background: #fff;
  padding: 0 14px;
  font: inherit;
  font-size: 14px;
  outline: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08) inset;
  color: #1c1c1e;
}
.aha-chat-input:focus { box-shadow: 0 0 0 1.5px rgba(255, 36, 66, 0.4) inset; }
.aha-chat-input:disabled { opacity: 0.5; }

.aha-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.15s;
}
.aha-chat-send:hover  { opacity: 0.88; }
.aha-chat-send:active { transform: scale(0.92); }
.aha-chat-send:disabled { opacity: 0.35; cursor: default; }

/* ─── responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 980px) {
  .app {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .page {
    padding: 12px;
  }

  .topbar {
    margin-bottom: 12px;
  }

  .search {
    width: 100%;
  }

  .topbar-actions {
    display: none;
  }

  .detail-shell {
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    grid-template-columns: 1fr;
    border-radius: 0;
    box-shadow: none;
  }

  .media-panel {
    padding: 12px;
    min-height: 500px;
  }

  .content-panel {
    min-height: 0;
    padding: 0;
  }

  .author-row {
    padding: 14px 16px;
  }

  .content-scroll {
    overflow-y: auto;
    padding: 14px 16px 0;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .viewer-stage {
    width: min(92vw, 980px);
    height: min(70vh, 880px);
  }

  .viewer-thumb-row {
    width: min(360px, calc(100vw - 40px));
  }

  .action-bar {
    flex-direction: row;
    align-items: center;
    padding: 10px 16px 14px;
  }

  .action-icon-group {
    justify-content: space-between;
  }

  .compose-overlay {
    position: fixed;
  }
}
