/* TENIMPER v49.0 — Comments 2.0: clean book-style cards + reply threads */

.comments-section{
  --ti-c49-line:rgba(196,155,96,.26);
  --ti-c49-line-strong:rgba(196,155,96,.48);
  --ti-c49-paper:rgba(255,250,240,.018);
  --ti-c49-paper-hover:rgba(255,250,240,.028);
  --ti-c49-ink:inherit;
  --ti-c49-muted:rgba(220,205,184,.60);
  --ti-c49-thread:rgba(188,145,84,.31);
  --ti-c49-accent:#c49a61;
  --ti-c49-shadow:0 14px 34px rgba(0,0,0,.10);
}

.comments-section .comment-card.ti-c49-card{
  position:relative;
  margin:14px 0;
  padding:17px 18px 15px;
  border:1px solid var(--ti-c49-line);
  border-radius:15px;
  background:
    linear-gradient(180deg,rgba(255,255,255,.018),rgba(255,255,255,.007)),
    var(--ti-c49-paper);
  box-shadow:none;
  overflow:visible;
  transition:border-color .18s ease,background .18s ease,box-shadow .18s ease;
}

.comments-section .comment-card.ti-c49-card:hover{
  border-color:rgba(196,155,96,.34);
  background:
    linear-gradient(180deg,rgba(255,255,255,.024),rgba(255,255,255,.008)),
    var(--ti-c49-paper-hover);
}

.comments-section .ti-c49-card::before{
  content:"";
  position:absolute;
  left:18px;
  right:18px;
  top:0;
  height:1px;
  opacity:.42;
  background:linear-gradient(90deg,transparent,var(--ti-c49-line-strong),transparent);
}

/* Author/meta hierarchy. These selectors deliberately support several generations
   of the live comment markup without moving server-rendered nodes. */
.comments-section .ti-c49-card .comment-avatar{
  width:42px;
  height:42px;
  min-width:42px;
  border-radius:50%;
  overflow:hidden;
  border:1px solid rgba(196,155,96,.46);
  box-shadow:0 0 0 3px rgba(196,155,96,.055);
}

.comments-section .ti-c49-card .comment-avatar img,
.comments-section .ti-c49-card .comment-profile-avatar{
  width:100%;
  height:100%;
  display:block;
  object-fit:cover;
}

.comments-section .ti-c49-card :is(
  .comment-author,.comment-name,.comment-card__author,.comment-user,
  .comment-meta strong,.comment-head strong,.comment-header strong
){
  font-weight:650;
  letter-spacing:.01em;
}

.comments-section .ti-c49-card :is(
  time,.comment-date,.comment-time,.comment-meta small,.comment-head small,
  .comment-header small,.comment-role,.comment-title
){
  color:var(--ti-c49-muted);
  font-size:.82em;
}

/* Main comment text gets the visual priority. */
.comments-section .ti-c49-card .comment-text{
  margin-top:11px;
  line-height:1.72;
  font-size:1rem;
  overflow-wrap:anywhere;
}

.comments-section .ti-c49-card .comment-text > :first-child{margin-top:0}
.comments-section .ti-c49-card .comment-text > :last-child{margin-bottom:0}

/* Existing character sticker + 104-pack sticker stay readable but no longer dominate. */
.comments-section .ti-c49-card .ti-comment-sticker{
  display:inline-flex;
  vertical-align:top;
  margin:9px 4px 2px 0;
}
.comments-section .ti-c49-card .ti-comment-sticker img{
  display:block;
  width:auto;
  max-width:185px;
  max-height:185px;
  object-fit:contain;
}
.comments-section .ti-c49-card .comment-character-sticker{
  margin-top:9px;
  margin-bottom:5px;
}

/* Reply structure: one calm visual depth, never a staircase. */
.comments-section .ti-c49-card--reply{
  margin-left:23px !important;
  padding:14px 15px 13px !important;
  border-color:rgba(196,155,96,.20) !important;
}

.comments-section .ti-c49-card--reply::after{
  content:"";
  position:absolute;
  left:-16px;
  top:-8px;
  bottom:-8px;
  width:1px;
  background:linear-gradient(180deg,transparent,var(--ti-c49-thread) 10%,var(--ti-c49-thread) 90%,transparent);
}

.comments-section .ti-c49-card--reply .comment-avatar{
  width:34px;
  height:34px;
  min-width:34px;
}

/* Any deeper server nesting is visually flattened to one level. */
.comments-section .ti-c49-card--reply .ti-c49-card--reply{
  margin-left:0 !important;
}

.comments-section .ti-c49-reply-context{
  display:flex;
  align-items:center;
  gap:7px;
  margin:-2px 0 8px;
  color:var(--ti-c49-muted);
  font-size:.78rem;
  line-height:1.3;
}
.comments-section .ti-c49-reply-context::before{
  content:"↳";
  color:var(--ti-c49-accent);
  opacity:.82;
}
.comments-section .ti-c49-reply-context b{
  color:inherit;
  font-weight:600;
}

/* Thread collapse button. */
.comments-section .ti-c49-thread-toggle{
  appearance:none;
  display:inline-flex;
  align-items:center;
  gap:7px;
  min-height:34px;
  margin:3px 0 8px 23px;
  padding:6px 10px;
  border:0;
  background:transparent;
  color:var(--ti-c49-muted);
  font:inherit;
  font-size:.82rem;
  cursor:pointer;
  border-radius:9px;
}
.comments-section .ti-c49-thread-toggle::before{
  content:"";
  width:18px;
  height:1px;
  background:var(--ti-c49-line-strong);
}
.comments-section .ti-c49-thread-toggle:hover{
  color:var(--ti-c49-accent);
  background:rgba(196,155,96,.055);
}
.comments-section .ti-c49-thread-toggle:focus-visible{
  outline:2px solid rgba(196,155,96,.58);
  outline-offset:2px;
}
.comments-section .ti-c49-card[hidden]{
  display:none !important;
}

/* Existing inline reply form becomes a clean in-thread editor. */
.comments-section .comment-inline-form{
  margin-top:9px;
}
.comments-section .comment-inline-form > summary{
  width:max-content;
  max-width:100%;
  list-style:none;
  cursor:pointer;
  color:var(--ti-c49-muted);
  font-size:.88rem;
  border-radius:8px;
  padding:5px 8px;
}
.comments-section .comment-inline-form > summary::-webkit-details-marker{display:none}
.comments-section .comment-inline-form > summary:hover{
  color:var(--ti-c49-accent);
  background:rgba(196,155,96,.055);
}
.comments-section .comment-inline-form[open]{
  margin-top:12px;
  padding:12px;
  border:1px solid rgba(196,155,96,.18);
  border-radius:12px;
  background:rgba(0,0,0,.045);
}
.comments-section .comment-inline-form[open] > summary{
  margin-bottom:9px;
  color:var(--ti-c49-accent);
}
.comments-section .comment-inline-form textarea,
.comments-section .comment-compose textarea{
  width:100%;
  max-width:100%;
  box-sizing:border-box;
  resize:vertical;
  line-height:1.55;
}

/* Keep v46 reactions intact, only separate them from the body more cleanly. */
.comments-section .ti-c49-card .character-reactions{
  margin-top:14px;
  padding-top:11px;
  border-top:1px solid rgba(196,155,96,.13);
}

/* Light theme support without turning comments into white cards. */
html[data-theme="light"] .comments-section,
body[data-theme="light"] .comments-section,
.theme-light .comments-section{
  --ti-c49-line:rgba(104,72,42,.18);
  --ti-c49-line-strong:rgba(139,96,48,.36);
  --ti-c49-paper:rgba(126,84,38,.025);
  --ti-c49-paper-hover:rgba(126,84,38,.04);
  --ti-c49-muted:rgba(77,57,42,.62);
  --ti-c49-thread:rgba(139,96,48,.30);
  --ti-c49-accent:#8b6037;
  --ti-c49-shadow:0 12px 28px rgba(79,48,24,.07);
}
html[data-theme="light"] .comments-section .comment-inline-form[open],
body[data-theme="light"] .comments-section .comment-inline-form[open],
.theme-light .comments-section .comment-inline-form[open]{
  background:rgba(126,84,38,.025);
}

/* Mobile: text keeps almost the full width; replies don't become a narrow column. */
@media(max-width:700px){
  .comments-section .comment-card.ti-c49-card{
    margin:11px 0;
    padding:14px 13px 13px;
    border-radius:13px;
  }
  .comments-section .ti-c49-card::before{
    left:13px;
    right:13px;
  }
  .comments-section .ti-c49-card .comment-avatar{
    width:40px;
    height:40px;
    min-width:40px;
  }
  .comments-section .ti-c49-card .comment-text{
    margin-top:9px;
    line-height:1.66;
  }
  .comments-section .ti-c49-card--reply{
    margin-left:13px !important;
    padding:12px 11px 12px !important;
  }
  .comments-section .ti-c49-card--reply::after{
    left:-8px;
  }
  .comments-section .ti-c49-card--reply .comment-avatar{
    width:33px;
    height:33px;
    min-width:33px;
  }
  .comments-section .ti-c49-thread-toggle{
    min-height:40px;
    margin-left:13px;
    padding:7px 8px;
  }
  .comments-section .ti-c49-card .ti-comment-sticker img{
    max-width:150px;
    max-height:150px;
  }
  .comments-section .comment-inline-form[open]{
    padding:10px;
  }
}

@media(max-width:390px){
  .comments-section .comment-card.ti-c49-card{
    padding-left:11px;
    padding-right:11px;
  }
  .comments-section .ti-c49-card--reply{
    margin-left:9px !important;
  }
  .comments-section .ti-c49-card--reply::after{
    left:-6px;
  }
  .comments-section .ti-c49-thread-toggle{
    margin-left:9px;
  }
}

/* Motion accessibility. */
@media(prefers-reduced-motion:reduce){
  .comments-section .comment-card.ti-c49-card{
    transition:none;
  }
}
