/* ==========================================================================
   DevFlow - Signature Feature Styles
   Sections: Command Palette, Reading Progress Bar, Vim Keyboard Navigation,
             Footer Keyboard Hints, Nav Active State, Design Fixes,
             Footer Expanded, Chat Comments
   ========================================================================== */

/* ==========================================================================
   34. Signature Feature: Command Palette
   ========================================================================== */

.cmd-palette {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  justify-content: center;
  padding-top: 20vh;
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease, visibility 200ms;
}

.cmd-palette.active {
  opacity: 1;
  visibility: visible;
}

.cmd-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.cmd-container {
  position: relative;
  width: 560px;
  max-width: 90vw;
  max-height: 420px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
  transform: translateY(-12px) scale(0.98);
  transition: transform 200ms ease;
  display: flex;
  flex-direction: column;
}

.cmd-palette.active .cmd-container {
  transform: translateY(0) scale(1);
}

.cmd-header {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  gap: 8px;
  flex-shrink: 0;
}

.cmd-prompt {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 13px;
  white-space: nowrap;
  user-select: none;
}

.cmd-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 14px;
  caret-color: var(--accent);
  line-height: 1.4;
}

.cmd-input::placeholder {
  color: var(--text-tertiary);
}

.cmd-shortcut {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-tertiary);
}

.cmd-results {
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
}

.cmd-group-label {
  padding: 6px 16px 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cmd-item {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background 80ms ease;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
}

.cmd-item.selected {
  background: var(--accent-subtle);
  outline: 1px solid var(--accent-glow);
  outline-offset: -1px;
}

.cmd-item:hover {
  background: rgba(217, 119, 6, 0.06);
}

.cmd-item-icon {
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.cmd-item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cmd-item-title mark {
  background: transparent;
  color: var(--accent);
  font-weight: 600;
}

.cmd-item-meta {
  font-size: 11px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.cmd-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: 13px;
}

.cmd-footer {
  display: flex;
  gap: 16px;
  padding: 8px 16px;
  border-top: 1px solid var(--border-color);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.cmd-footer kbd {
  font-size: 10px;
  padding: 1px 4px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  margin-right: 2px;
}

@media (max-width: 640px) {
  .cmd-palette {
    padding-top: 10vh;
  }
  .cmd-prompt {
    display: none;
  }
  .cmd-container {
    max-height: 60vh;
    border-radius: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cmd-palette,
  .cmd-container {
    transition: none !important;
  }
}

/* ==========================================================================
   35. Signature Feature: Reading Progress Terminal Bar
   ========================================================================== */

.reading-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1002;
  height: 28px;
  background: #1a1a1f;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 28px;
  overflow: hidden;
  transform: translateY(-100%);
  transition: transform 300ms ease;
  user-select: none;
}

.reading-bar.visible {
  transform: translateY(0);
}

.reading-bar.visible ~ .site-header {
  top: 28px;
}

.reading-bar-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  white-space: nowrap;
  height: 100%;
}

.reading-prompt {
  color: #28c840;
  font-weight: 600;
  flex-shrink: 0;
}

.reading-blocks {
  color: var(--accent);
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.reading-percent {
  color: #e8e6e3;
  font-weight: 700;
  min-width: 32px;
  text-align: right;
  flex-shrink: 0;
}

.reading-sep {
  color: #3a3a3f;
  flex-shrink: 0;
}

.reading-eta {
  color: #8a8a85;
  flex-shrink: 0;
}

.reading-title {
  color: #5a5a55;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.reading-bar.done .reading-prompt,
.reading-bar.done .reading-blocks,
.reading-bar.done .reading-percent {
  color: #10b981;
  transition: color 500ms ease;
}

.reading-bar.done .reading-bar-inner {
  animation: done-flash 0.8s ease;
}

@keyframes done-flash {
  0%, 100% { opacity: 1; }
  40% { opacity: 0.6; }
}

@media (max-width: 768px) {
  .reading-bar {
    height: 22px;
    font-size: 9px;
    line-height: 22px;
  }
  .reading-prompt,
  .reading-title {
    display: none;
  }
  .reading-bar-inner {
    justify-content: center;
    gap: 4px;
    padding: 0 8px;
  }
  .reading-blocks {
    letter-spacing: -1px;
  }
  .reading-eta {
    font-size: 8px;
  }
  .reading-bar.visible ~ .site-header {
    top: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reading-bar {
    transition: none !important;
  }
  .reading-bar.done .reading-prompt,
  .reading-bar.done .reading-blocks,
  .reading-bar.done .reading-percent {
    transition: none !important;
  }
}

/* ==========================================================================
   36. Signature Feature: Vim Keyboard Navigation
   ========================================================================== */

/* Article hover cursor — terminal pointer (hidden, border-left is used instead) */
.article-item::before {
  content: none;
}

/* Keyboard selected — prominent */
.article-item.kb-selected {
  background: var(--accent-subtle);
  border-left-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-glow);
}

@keyframes pointer-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.kb-indicator {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 100;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 5px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 400ms, transform 400ms, border-color 300ms, box-shadow 300ms;
  pointer-events: none;
}

/* Active state: prominent when user is navigating */
.kb-indicator.kb-active {
  opacity: 1;
  transform: translateY(0);
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
  pointer-events: auto;
}

/* Active content: mode + hints */
.kb-mode {
  display: none;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.kb-hint {
  display: none;
  color: var(--text-tertiary);
  margin-left: 8px;
}

.kb-indicator.kb-active .kb-mode,
.kb-indicator.kb-active .kb-hint {
  display: inline;
}

.kb-help {
  position: fixed;
  bottom: 56px;
  left: 16px;
  z-index: 101;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  font-family: var(--font-mono);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 200ms ease;
}

.kb-help.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.kb-help-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kb-help-table {
  font-size: 12px;
  border-collapse: collapse;
}

.kb-help-table td {
  padding: 3px 0;
}

.kb-help-table td:first-child {
  padding-right: 20px;
  white-space: nowrap;
}

.kb-help-table td:last-child {
  color: var(--text-secondary);
}

.kb-help-table kbd {
  display: inline-block;
  padding: 1px 5px;
  font-size: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  font-family: inherit;
  margin-right: 2px;
}

@media (max-width: 768px) {
  .kb-indicator,
  .kb-help {
    display: none !important;
  }
  .article-item.kb-selected {
    outline: none;
  }
  .article-item.kb-selected::before {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kb-indicator,
  .kb-help {
    transition: none !important;
  }
  @keyframes pointer-pulse {
    0%, 100% { opacity: 1; }
  }
}

/* ==========================================================================
   Footer Keyboard Hints (integrated into design)
   ========================================================================== */
.footer-keys {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-meta-light);
  opacity: 0.5;
  transition: opacity 0.3s ease;
}

.footer-keys:hover {
  opacity: 0.85;
}

.footer-prompt {
  color: var(--accent);
  font-weight: 700;
}

.footer-keys kbd {
  display: inline-block;
  padding: 1px 5px;
  background: var(--bg-card);
  border: 1px solid var(--border-list);
  border-radius: 3px;
  font-family: inherit;
  font-size: 11px;
}

/* Hide vim-specific keys on article detail pages */
#tt-body-page .footer-keys-vim {
  display: none;
}

@media (max-width: 768px) {
  .footer-keys {
    display: none;
  }
}

/* ==========================================================================
   Keyboard Hint (Top, above article list)
   ========================================================================== */
.kb-hint-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 0 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-body);
  opacity: 0.45;
  user-select: none;
  transition: opacity 0.3s ease;
}

.kb-hint-top:hover {
  opacity: 0.75;
}

.kb-hint-prompt {
  color: var(--accent);
  font-weight: 700;
}

.kb-hint-top kbd {
  display: inline-block;
  padding: 1px 5px;
  background: var(--bg-card);
  border: 1px solid var(--border-list);
  border-radius: 3px;
  font-size: 11px;
}

/* Hide on article detail pages and mobile */
#tt-body-page .kb-hint-top {
  display: none;
}

@media (max-width: 768px) {
  .kb-hint-top {
    display: none;
  }
}

/* ==========================================================================
   Page Entrance Animation
   ========================================================================== */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.main-content {
  animation: fadeUp 0.45s ease both;
}

@media (prefers-reduced-motion: reduce) {
  .main-content {
    animation: none;
  }
  .site-title::after {
    animation: none;
    opacity: 0;
  }
}

/* ==========================================================================
   35. Nav Active State (JS-added class)
   ========================================================================== */
.nav-categories > ul > li > ul > li > a.nav-active {
  color: var(--text-title);
}
.nav-categories > ul > li > ul > li > a.nav-active::after {
  width: 60%;
  left: 20%;
}

/* ==========================================================================
   36. Design Issue Fixes (27 items)
   ========================================================================== */

/* Issue 6 & 26: Hide Tistory "N" new-post GIF badges everywhere */
img[src*="new_ico"],
img[alt="N"].c_new,
.sidebar-categories img,
.nav-categories img {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

/* Issue 7: Sidebar card subtle background + visual separation */
.sidebar-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 16px;
  border-bottom: none !important;
  margin-bottom: 0;
}
.sidebar-card + .sidebar-card {
  margin-top: 8px;
}
.sidebar-card:last-child {
  margin-bottom: 0;
}
[data-theme="dark"] .sidebar-card {
  background: var(--bg-card);
}
/* Profile card — keep flush to card edges */
.sidebar-profile {
  padding: 16px;
}

/* Issue 8: Article hover — slightly stronger contrast */
.article-item:hover {
  background: var(--accent-subtle);
  border-left-color: var(--accent);
  box-shadow: 0 1px 6px rgba(0,0,0,0.04);
}
[data-theme="dark"] .article-item:hover {
  box-shadow: 0 1px 6px rgba(0,0,0,0.15);
}

/* Issue 9: Author card — elegant 2-row layout */
.post-author-card {
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 18px 20px;
}
.post-author-link {
  flex-shrink: 0;
}
.post-author-name {
  font-size: 14px;
}
.post-author-desc {
  flex-basis: 100%; /* force to own row */
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-meta);
  padding-left: 42px; /* align under the avatar (32px img + 10px gap) */
}

.toc-title::before {
  content: '$';
  color: var(--text-meta-light);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 11px;
  opacity: 0.7;
  flex-shrink: 0;
}

/* Issue 13: Code block — preserve terminal dots on all screen sizes */
.post-content pre {
  scroll-margin-top: calc(var(--header-height) + 24px);
}
@media (max-width: 480px) {
  .post-content pre {
    padding-top: 40px !important; /* preserve terminal dots space */
  }
}

/* Issue 14: Code language label — more legible */
.code-lang-label {
  opacity: 0.85;
  color: var(--text-meta);
}

/* Issue 17: Category/tag/search banner — more visual presence */
.list-header {
  border-bottom: 1px solid var(--border-list);
  padding-bottom: 16px;
  margin-bottom: 28px;
}
.section-title {
  font-size: 30px;
}
.tag-cloud-container .section-title {
  border-bottom: 1px solid var(--border-list);
  padding-bottom: 16px;
  margin-bottom: 28px;
}

/* Issue 19: Safety rule — hide any profile element that appears in mega panel */
.nav-mega-panel .profile-link,
.nav-mega-panel .profile-image,
.nav-mega-panel .sidebar-profile {
  display: none !important;
}

/* Issue 20: Prev/next — no blank column when only one direction exists */
.post-nav-item:only-child {
  grid-column: 1 / -1;
}
.post-nav-next {
  grid-column: unset; /* auto-place, not forced to col 2 */
}
/* Keep next right-aligned when it exists alongside prev */
.post-nav-prev ~ .post-nav-next {
  grid-column: 2;
  text-align: right;
}

/* Issue 21: Mobile sidebar nav links */
.sidebar-mobile-nav {
  display: none; /* hidden on desktop */
  flex-direction: row;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--border-list);
  margin-bottom: 4px;
}
@media (max-width: 768px) {
  .sidebar-mobile-nav {
    display: flex;
  }
}
.sidebar-mobile-nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-body);
  background: var(--bg-secondary);
  border-radius: var(--radius-btn);
  text-decoration: none;
  transition: color var(--transition), background-color var(--transition);
}
.sidebar-mobile-nav-item:hover {
  color: var(--text-title);
  background: var(--accent-subtle);
}

/* Issue 22: Mobile keyboard hint — already handled in section 22, reinforce */
@media (max-width: 768px) {
  .kb-hint-top {
    display: none !important;
  }
}

/* Issue 23: Related posts — add accent dot + card hover */
.related-posts-list li a {
  border-left: 2px solid transparent;
  transition: background-color var(--transition), border-color var(--transition);
}
.related-posts-list li a:hover {
  background: var(--accent-subtle);
  border-left-color: var(--accent);
}
.related-post-title::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
  margin-right: 10px;
  vertical-align: middle;
  opacity: 0.45;
  flex-shrink: 0;
}
.related-posts-list li a:hover .related-post-title::before {
  opacity: 1;
}

/* Issue 25: Guestbook write form — ensure always visible */
.guestbook .tt_comment_area,
.guestbook .tt-comment-area,
#tt-body-guestbook .tt_comment_area,
#tt-body-guestbook .tt-comment-area {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
}
.guestbook .tt-box-write,
.guestbook .tt-area-write,
.guestbook .tt-comment-write,
#tt-body-guestbook .tt-box-write,
#tt-body-guestbook .tt-area-write,
#tt-body-guestbook .tt-comment-write {
  display: block !important;
  visibility: visible !important;
}

/* Issue 27: Author card mobile overflow fix */
@media (max-width: 768px) {
  .post-author-card {
    flex-wrap: wrap;
    overflow: hidden;
  }
  .post-author-desc {
    flex-basis: 100%;
    padding-left: 0;
    white-space: normal;
    word-break: keep-all;
    overflow-wrap: break-word;
  }
  .post-author-link {
    min-width: 0;
    overflow: hidden;
  }
  .post-author-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ==========================================================================
   37. Footer — Expanded (Issue 10)
   ========================================================================== */
.footer-profile {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  max-width: var(--layout-max);
  margin: 0 auto 28px;
  padding: 0 24px;
  text-align: left;
}
.footer-profile-link {
  flex-shrink: 0;
}
.footer-profile-img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 3px var(--border-list);
}
.footer-profile-info {
  min-width: 0;
}
.footer-profile-name {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-title);
  letter-spacing: -0.01em;
  margin-bottom: 4px;
  transition: color var(--transition);
}
.footer-profile-name:hover {
  color: var(--accent);
}
.footer-profile-desc {
  font-size: 13px;
  color: var(--text-body);
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: break-word;
  white-space: pre-line;
}
.footer-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 16px;
  max-width: var(--layout-max);
  margin: 0 auto 20px;
  padding: 0 24px;
}
.footer-nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-meta-light);
  transition: color var(--transition);
}
.footer-nav-link:hover {
  color: var(--text-title);
}
.footer-nav-link + .footer-nav-link::before {
  content: '·';
  margin-right: 16px;
  opacity: 0.4;
  pointer-events: none;
}
/* Footer border separator */
.site-footer::before {
  margin-bottom: 28px;
}
@media (max-width: 768px) {
  .footer-profile {
    padding: 0 16px;
  }
  .footer-nav {
    padding: 0 16px;
  }
}

/* --------------------------------------------------------------------------
   Chat Comments (Channel Talk style)
   -------------------------------------------------------------------------- */

/* Custom s_rp comment block — hidden, chat panel parses the DOM */
.custom-comments {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Floating chat button — bottom-left */
/* ============================================================
   Chat Button
   ============================================================ */
.chat-btn {
  display: none; /* JS shows on detail pages only */
  position: fixed;
  bottom: 28px;
  left: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2), 0 2px 6px rgba(0,0,0,0.12);
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1),
              box-shadow 0.2s ease,
              background 0.2s ease;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-btn.visible {
  display: flex;
}

.chat-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.1);
  box-shadow: 0 8px 28px rgba(0,0,0,0.24);
}

.chat-btn:active {
  transform: scale(0.94);
}

/* Comment count badge */
.chat-badge {
  display: none;
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  background: var(--text-title);
  color: var(--bg-primary);
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-sans);
  border-radius: 100px;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid var(--bg-primary);
  line-height: 1;
}

.chat-badge.visible {
  display: flex;
}

/* ============================================================
   Chat Panel
   ============================================================ */
.chat-panel {
  position: fixed;
  bottom: 92px;
  left: 24px;
  width: 360px;
  height: 500px;
  background: var(--bg-primary);
  border-radius: 20px;
  box-shadow:
    0 0 0 1px var(--border-list),
    0 4px 6px rgba(0,0,0,0.04),
    0 12px 32px rgba(0,0,0,0.12),
    0 24px 64px rgba(0,0,0,0.08);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  transform-origin: bottom left;
  transition: opacity 0.25s cubic-bezier(0.4,0,0.2,1),
              visibility 0.25s cubic-bezier(0.4,0,0.2,1),
              transform 0.25s cubic-bezier(0.34,1.4,0.64,1);
  pointer-events: none;
}

.chat-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ============================================================
   Chat Header
   ============================================================ */
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px 15px;
  border-bottom: 1px solid var(--border-list);
  flex-shrink: 0;
  background: var(--bg-primary);
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(34,197,94,0.15);
  animation: chat-pulse 2.5s ease-in-out infinite;
}

@keyframes chat-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(34,197,94,0.15); }
  50% { box-shadow: 0 0 0 5px rgba(34,197,94,0.08); }
}

.chat-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-title);
  letter-spacing: -0.02em;
}

.chat-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--text-meta);
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
  padding: 0;
}

.chat-close:hover {
  background: var(--bg-card);
  color: var(--text-title);
}

/* ============================================================
   Chat Body
   ============================================================ */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  scroll-behavior: smooth;
}

.chat-body::-webkit-scrollbar {
  width: 3px;
}

.chat-body::-webkit-scrollbar-track {
  background: transparent;
}

.chat-body::-webkit-scrollbar-thumb {
  background: var(--border-list);
  border-radius: 2px;
}

/* ============================================================
   Empty State
   ============================================================ */
.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex: 1;
  color: var(--text-meta-light);
  padding: 32px 16px;
}

.chat-empty svg {
  opacity: 0.25;
  margin-bottom: 2px;
}

.chat-empty span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-meta);
}

.chat-empty-sub {
  font-size: 12px !important;
  font-weight: 400 !important;
  color: var(--text-meta-light) !important;
  margin-top: -4px;
}

/* ============================================================
   Chat Bubbles
   ============================================================ */

/* Bubble wrapper */
.chat-bubble-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 82%;
  margin-bottom: 10px;
}

.chat-bubble-wrap.reply {
  margin-left: 8px;
  opacity: 0.92;
}

.chat-bubble-wrap.owner {
  align-self: flex-end;
  align-items: flex-end;
}

/* Meta row (avatar + name) */
.chat-bubble-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

/* Avatar circle */
.chat-bubble-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-subtle);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-sans);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1.5px solid color-mix(in srgb, var(--accent) 18%, transparent);
  overflow: hidden;
  text-transform: uppercase;
}

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

/* Author name */
.chat-bubble-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-meta);
  letter-spacing: 0.01em;
}

/* Bubble itself */
.chat-bubble {
  padding: 10px 14px;
  border-radius: 4px 18px 18px 18px;
  background: var(--bg-card);
  color: var(--text-body);
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  border: 1px solid var(--border-list);
  font-family: var(--font-sans);
}

.chat-bubble-wrap.owner .chat-bubble {
  background: var(--accent);
  border-color: var(--accent);
  border-radius: 18px 4px 18px 18px;
  color: #fff;
}

/* Timestamp */
.chat-bubble-time {
  font-size: 10px;
  color: var(--text-meta-light);
  margin-top: 4px;
  padding-left: 2px;
  font-family: var(--font-sans);
}

.chat-bubble-wrap.owner .chat-bubble-time {
  padding-left: 0;
  padding-right: 2px;
}

/* Owner meta row — aligns admin badge to the right */
.chat-bubble-meta.owner-meta {
  justify-content: flex-end;
}

/* Admin badge */
.chat-admin-badge {
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  background: #f59e0b;
  padding: 1px 7px;
  border-radius: 100px;
}

/* Bubble action buttons (reply / delete) — visible on hover only */
.chat-bubble-actions {
  display: none;
  gap: 10px;
  margin-top: 4px;
  padding-left: 2px;
}

.chat-bubble-wrap.owner .chat-bubble-actions {
  padding-left: 0;
  padding-right: 2px;
  justify-content: flex-end;
}

.chat-bubble-wrap:hover .chat-bubble-actions {
  display: flex;
}

.chat-bubble-action {
  color: var(--text-meta-light);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-size: 11px;
  font-family: var(--font-sans);
  line-height: 1;
}

.chat-bubble-action:hover {
  color: var(--text-title);
}

.chat-bubble-action-delete:hover {
  color: #e05252;
}

/* Date divider */
.chat-date-divider {
  align-self: center;
  font-size: 11px;
  color: var(--text-meta-light);
  background: var(--bg-card);
  border: 1px solid var(--border-list);
  padding: 3px 12px;
  border-radius: 100px;
  margin: 10px 0 6px;
  letter-spacing: 0.02em;
  font-family: var(--font-sans);
}

/* ============================================================
   Chat Footer
   ============================================================ */
.chat-footer {
  border-top: 1px solid var(--border-list);
  flex-shrink: 0;
  background: var(--bg-primary);
}

/* Clean chat input UI */
.chat-input-wrap {
  display: flex;
  flex-direction: column;
}

/* Guest name row */
.chat-guest-row {
  display: flex;
  align-items: center;
  padding: 10px 14px 0;
  border-bottom: 1px solid var(--border-list);
}

.chat-guest-name {
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
  font-size: 12px;
  font-family: var(--font-sans);
  background: transparent;
  border: none;
  color: var(--text-body);
  padding: 0 2px 8px;
  outline: none;
  transition: none;
}

.chat-guest-name::placeholder {
  color: var(--text-meta-light);
}

.chat-guest-pw {
  flex: 0 0 80px;
  box-sizing: border-box;
  font-size: 12px;
  font-family: var(--font-sans);
  background: transparent;
  border: none;
  border-left: 1px solid var(--border-list);
  color: var(--text-body);
  padding: 0 2px 8px 10px;
  outline: none;
  transition: none;
}

.chat-guest-pw::placeholder {
  color: var(--text-meta-light);
}

/* Input + send button row */
.chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 14px;
}

.chat-input {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-family: var(--font-sans);
  background: transparent;
  border: none;
  color: var(--text-body);
  padding: 0;
  outline: none;
  line-height: 1.5;
}

.chat-input::placeholder {
  color: var(--text-meta-light);
}

.chat-send {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s cubic-bezier(0.34,1.56,0.64,1);
  padding: 0;
}

.chat-send:hover {
  background: var(--accent-hover);
  transform: scale(1.08);
}

.chat-send:active {
  transform: scale(0.92);
}

/* "Write comment" CTA button in footer when form unavailable */
.chat-footer-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 16px;
  gap: 8px;
  color: var(--text-meta);
  font-size: 13px;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  transition: color 0.15s;
  font-family: var(--font-sans);
}

.chat-footer-cta:hover {
  color: var(--text-title);
}

.chat-footer-cta svg {
  flex-shrink: 0;
  opacity: 0.6;
}

/* ============================================================
   Mobile
   ============================================================ */
@media (max-width: 600px) {
  .chat-panel {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 72vh;
    height: 72dvh;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
    transform: translateY(40px) scale(1);
    transform-origin: bottom center;
  }

  .chat-panel.open {
    transform: translateY(0) scale(1);
  }

  .chat-btn {
    bottom: 20px;
    left: 20px;
  }
}
