/* /assets/css/app.css */

/* base */
:root {
  --z-bar: 10;
  --z-overlay: 40;
  --z-modal: 50;
}
* { font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body {
  margin: 0;
  background: #f5f5f5;
}
#app-shell{
  position: relative;
  --composer-offset: 98px;
  transform-origin: center top;
  transition: transform 320ms cubic-bezier(0.32, 0.72, 0, 1), border-radius 320ms cubic-bezier(0.32, 0.72, 0, 1), box-shadow 320ms cubic-bezier(0.32, 0.72, 0, 1);
}

body.thread-sheet-open #app-shell{
  transform: scale(0.992);
  border-radius: 14px !important;
  box-shadow: 0 18px 60px -28px rgba(15, 23, 42, 0.45);
}

/* send */
.send-button {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.75rem;
  border: 1px solid #dc2626;
  background: #ef4444;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  transition: opacity 200ms ease-out, transform 150ms ease-out;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.send-button:active:not(:disabled) { transform: scale(0.95); }
.send-button:disabled { opacity: 0.5; cursor: not-allowed; }
.send-button:focus-visible{
  outline: 2px solid rgba(239, 68, 68, 0.35);
  outline-offset: 2px;
}

/* input wrapper focus */
.input-wrapper:focus-within{
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.10);
}

/* edit mode: yellow focus for input wrapper */
body.is-editing .input-wrapper:focus-within{
  box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.18);
}

/* topbar */
.topbar{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  padding: 14px 18px 12px 18px;
  border-bottom: 1px solid #f1f1f1;
  position: relative;
}
.topbar-left{ display:flex; align-items:center; }
.top-nav-bar{
  display: inline-flex;
  align-items: center;
  gap: 14px;
}
.top-nav-btn{
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #9ca3af;
  display:flex;
  align-items:center;
  justify-content:center;
  position: relative;
  cursor:pointer;
  transition: color 170ms ease-out, transform 150ms ease-out, box-shadow 170ms ease-out;
}
.top-nav-btn:active{
  transform: scale(0.96);
}
.top-nav-btn:focus-visible{
  outline: 2px solid #d1d5db;
  outline-offset: 2px;
}
.top-nav-btn:hover{
  color: #4b5563;
  background: rgba(17, 24, 39, 0.05);
}
.top-nav-btn.is-active{
  background: transparent;
  color: #ef4444;
  box-shadow: none;
}
.top-nav-btn.is-active::after{
  content: "";
  position: absolute;
  width: 4px;
  height: 4px;
  left: 50%;
  transform: translateX(-50%);
  bottom: -8px;
  border-radius: 999px;
  background: #ef4444;
}

.topbar-right{
  display:flex;
  align-items:center;
  gap: 8px;
}
.topbar-email{
  font-size: 12px;
  line-height: 1.3;
  color: #6b7280;
  text-align: right;
  max-width: 230px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logout-icon-btn{
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #9ca3af;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  transition: transform 150ms ease-out, color 150ms ease-out, background-color 150ms ease-out;
}
.logout-icon-btn:active{
  transform: scale(0.96);
}
.logout-icon-btn:focus-visible{
  outline: 2px solid #d1d5db;
  outline-offset: 2px;
}
.logout-icon-btn:hover{
  color: #4b5563;
  background: rgba(17, 24, 39, 0.05);
}

/* === daily review === */

/* banner in feed */
.review-banner{
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
  border: 1px solid #fecaca;
  border-left: 4px solid #ef4444;
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  text-align: left;
}
.review-banner:active{
  transform: scale(0.98);
}
.review-banner-icon{
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #fef2f2;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ef4444;
}
.review-banner-body{
  flex: 1;
  min-width: 0;
}
.review-banner-title{
  font-size: 14px;
  font-weight: 700;
  color: #111827;
}
.review-banner-sub{
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}
.review-banner-arrow{
  color: #9ca3af;
  flex-shrink: 0;
}

/* modal */
.review-modal{
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease-out;
}
.review-modal.is-open{
  pointer-events: auto;
  opacity: 1;
}
.review-modal-bg{
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.review-modal-content{
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px 20px;
  gap: 24px;
}
.review-header{
  text-align: center;
}
.review-title{
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  text-wrap: balance;
}
.review-progress{
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* card */
.review-card-area{
  width: 100%;
  max-width: 360px;
  perspective: 800px;
  touch-action: pan-y;
  user-select: none;
}
.review-card{
  position: relative;
  background: #fff;
  border-radius: 20px;
  padding: 28px 24px;
  min-height: 180px;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  will-change: transform;
  transition: transform 200ms ease-out, box-shadow 200ms ease-out;
  overflow: hidden;
}
.review-card.is-dragging{
  transition: none;
}

/* swipe direction labels */
.review-card-label{
  position: absolute;
  top: 16px;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 12px;
  border-radius: 8px;
  border: 2px solid;
  opacity: 0;
  transition: opacity 150ms ease-out;
}
.review-card-label-left{
  left: 16px;
  color: #9ca3af;
  border-color: #d1d5db;
}
.review-card-label-right{
  right: 16px;
  color: #10b981;
  border-color: #10b981;
}

.review-card-text{
  font-size: 17px;
  font-weight: 600;
  color: #111827;
  line-height: 1.4;
  text-wrap: pretty;
}
.review-card-meta{
  font-size: 12px;
  color: #9ca3af;
  font-variant-numeric: tabular-nums;
}

/* exit animations */
.review-card.exit-right{
  animation: reviewExitRight 200ms ease-in forwards;
}
.review-card.exit-left{
  animation: reviewExitLeft 200ms ease-in forwards;
}
@keyframes reviewExitRight{
  to{ opacity: 0; transform: translateX(120%) rotate(15deg); }
}
@keyframes reviewExitLeft{
  to{ opacity: 0; transform: translateX(-120%) rotate(-15deg); }
}

/* onboarding hint — sway left then right, repeating */
.review-card.onboarding-hint{
  animation: reviewHint 1.6s ease-in-out;
}
@keyframes reviewHint{
  0%   { transform: translateX(0) rotate(0); }
  15%  { transform: translateX(-24px) rotate(-4deg); }
  30%  { transform: translateX(0) rotate(0); }
  50%  { transform: translateX(24px) rotate(4deg); }
  65%  { transform: translateX(0) rotate(0); }
  100% { transform: translateX(0) rotate(0); }
}

/* buttons */
.review-buttons{
  display: flex;
  gap: 16px;
}
.review-btn{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 150ms ease-out, opacity 150ms ease-out;
}
.review-btn:active{
  transform: scale(0.95);
}
.review-btn.skip{
  background: rgba(255,255,255,0.15);
  color: #fff;
}
.review-btn.done{
  background: #10b981;
  color: #fff;
}
.review-btn.close{
  background: #fff;
  color: #111827;
  padding: 14px 40px;
  margin-top: 16px;
}

/* intro stats screen */
.review-intro{
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 24px 20px;
}
.review-intro-content{
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  opacity: 0;
  transform: scale(0.9) translateY(12px);
  animation: reviewIntroIn 400ms ease-out 100ms forwards;
}
@keyframes reviewIntroIn{
  to{ opacity: 1; transform: scale(1) translateY(0); }
}
.review-intro-title{
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 32px;
  text-wrap: balance;
}
.review-intro-stats{
  display: flex;
  gap: 48px;
  justify-content: center;
  margin-bottom: 32px;
}
.review-intro-stat{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.review-intro-stat-num{
  font-size: 44px;
  font-weight: 800;
  color: #fff;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.review-intro-stat-label{
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.55);
}
.review-intro-pending{
  font-size: 15px;
  font-weight: 600;
  color: rgba(255,255,255,0.8);
  margin-bottom: 28px;
  text-wrap: balance;
}
.review-intro-start{
  padding: 16px 48px;
  font-size: 16px;
}
.review-btn.review-intro-dismiss{
  margin-top: 12px;
  padding: 10px 32px;
  background: transparent;
  color: rgba(255,255,255,0.5);
  font-size: 14px;
}
.review-btn.review-intro-dismiss:active{
  color: rgba(255,255,255,0.7);
}

/* summary */
.review-summary{
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.review-summary-content{
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  opacity: 0;
  transform: scale(0.8);
  animation: reviewSummaryIn 400ms ease-out 100ms forwards;
}
@keyframes reviewSummaryIn{
  to{ opacity: 1; transform: scale(1); }
}
.review-summary-title{
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 28px;
  text-wrap: balance;
}
.review-summary-stats{
  display: flex;
  gap: 40px;
  justify-content: center;
  margin-bottom: 8px;
}
.review-stat{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.review-stat-num{
  font-size: 48px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.review-stat.done .review-stat-num{
  color: #10b981;
}
.review-stat.skipped .review-stat-num{
  color: rgba(255,255,255,0.5);
}
.review-stat-label{
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
}

.composer-wrap{
  background: #fff;
}

.composer-input{
  min-height: 52px;
}

/* organized mode */
.folder-mode{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  align-content: start;
}

.folder-card{
  position: relative;
  appearance: none;
  text-align: left;
  border-radius: 18px;
  min-height: 132px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  padding: 16px;
  overflow: hidden;
  transform: translateY(10px) scale(0.98);
  opacity: 0;
  transition: transform 200ms cubic-bezier(.2,.8,.25,1), opacity 200ms ease-out;
}

.folder-mode.is-animated .folder-card{
  transform: translateY(0) scale(1);
  opacity: 1;
}

.folder-card::after{
  content:"";
  position: absolute;
  right: -18px;
  top: 34%;
  width: 42px;
  height: 48px;
  border-radius: 18px;
  background: rgba(255,255,255,0.68);
}

.folder-card .folder-title{
  font-size: 20px;
  line-height: 1.2;
  font-weight: 700;
  color: #111827;
  text-wrap: balance;
}

.folder-card .folder-count{
  position: absolute;
  left: 16px;
  bottom: 14px;
  border: 1px solid rgba(17, 24, 39, 0.14);
  border-radius: 999px;
  background: rgba(255,255,255,0.75);
  font-size: 12px;
  font-weight: 700;
  color: #374151;
  padding: 4px 10px;
}

.folder-card.type-task{ background: #fef2f2; }
.folder-card.type-question{ background: #dbeafe; }
.folder-card.type-thread{ background: #fee2e2; }
.folder-card.type-note{ background: #dcfce7; }

.folder-feed-head{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap: 10px;
  padding: 4px 0 2px 0;
}

.folder-back{
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 10px;
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: #111827;
}

.folder-feed-title{
  margin-top: 16px;
  margin-bottom: 24px;
  font-size: 28px;
  line-height: 1.1;
  color: #111827;
  font-weight: 700;
  text-align: left;
}

/* empty state */
.empty-state{
  padding: 18px 0;
}
.empty-text{
  font-size: 14px;
  color: #6b7280;
}
.empty-hint{
  margin-top: 6px;
  font-size: 12px;
  color: #9ca3af;
}

/* day separator */
.day-sep{
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 12px;
  padding: 18px 0 10px 0;
}
.day-sep-line{
  height: 1px;
  background: #e5e7eb;
  flex: 1;
}
.day-sep-label{
  font-size: 13px;
  color: #9ca3af;
  font-weight: 500;
  white-space: nowrap;
}

/* note row (feed item) */
.note-row{
  display:grid;
  grid-template-columns: 64px 1fr auto;
  align-items:start;
  gap: 0px;
  padding: 10px 0;
  position: relative;
  transition: background-color 160ms ease-out;
}
.note-row > .note-time{
  grid-column: 1;
}
.note-row > .note-body{
  grid-column: 2;
  min-width: 0;
}
.note-row > .note-del{
  grid-column: 3;
  justify-self: end;
  align-self: start;
}

.multi-check-col{
  position: absolute;
  left: 8px;
  top: 11px;
  display:flex;
  align-items:center;
  justify-content:flex-start;
}

.multi-check{
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 1px solid #d1d5db;
  color: transparent;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
  transition: opacity 170ms ease-out, transform 170ms ease-out, background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out;
}

body.is-multi-select .multi-check{
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

.note-time,
.note-body,
.note-del{
  transition: transform 180ms ease-out, opacity 150ms ease-out;
}

body.is-multi-select .note-time,
body.is-multi-select .note-body,
body.is-multi-select .note-del{
  transform: translateX(34px);
}

.note-row.note-selected{
  background: rgba(239, 68, 68, 0.08);
  border-radius: 12px;
}

.note-row.note-selected .multi-check{
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
}

/* time on left */
.note-time{
  font-size: 12px;
  color: #9ca3af;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 24px;
}

/* body */
.note-body{
  min-width: 0;
}
.note-text{
  font-size: 14px;
  line-height: 28px;
  color: #111827;
  white-space: pre-wrap;
  word-break: break-word;
  text-wrap: pretty;
}

/* thread stack */
.thread-stack{
  position: relative;
  padding-bottom: 16px;
  min-height: 42px;
  width: min(300px, 100%);
}

.thread-stack .thread-card{
  position: relative;
  display: block;
  width: 100%;
  min-height: 42px;
  border: 1px solid #d9dde3;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.thread-stack .thread-card:first-child{
  cursor: pointer;
  padding: 8px 76px 8px 12px;
  z-index: 3;
}

.thread-stack .thread-card:nth-child(2),
.thread-stack .thread-card:nth-child(3){
  position: absolute;
  left: 8px;
  right: 8px;
  top: 0;
  pointer-events: none;
}

.thread-stack .thread-card:nth-child(2){
  transform: translateY(6px);
  z-index: 2;
}

.thread-stack .thread-card:nth-child(3){
  left: 16px;
  right: 16px;
  transform: translateY(12px);
  z-index: 1;
}

.thread-preview{
  font-size: 13px;
  line-height: 1.35;
  font-weight: 600;
  color: #6b7280;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.thread-count-pill{
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  color: #6b7280;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.note-row.thread-drop-target .thread-stack .thread-card:first-child{
  border-color: rgba(239, 68, 68, 0.8);
  box-shadow: 0 10px 24px rgba(239, 68, 68, 0.2);
}
.note-row.thread-drop-target .thread-count-pill{
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

.note-row.thread-drop-accept .thread-stack .thread-card:first-child{
  box-shadow: 0 14px 30px rgba(239, 68, 68, 0.26);
  transform: translateY(-1px);
}

.note-row.thread-merging{
  animation: threadMergeOut 200ms cubic-bezier(.2,.8,.25,1) forwards;
  pointer-events: none;
}

@keyframes threadMergeOut{
  from { opacity: 1; transform: scale(1) translateY(0); }
  to { opacity: 0; transform: scale(0.88) translateY(-16px); }
}

.note-row.is-thread-note.note-enter .thread-stack .thread-card:first-child{
  opacity: 0;
  transform: translateY(10px) scale(0.97);
}

.note-row.is-thread-note.note-enter.note-enter-active .thread-stack .thread-card:first-child{
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: opacity 200ms ease-out, transform 200ms cubic-bezier(.2,.8,.25,1);
}

.note-row.is-thread-note.note-enter .thread-stack .thread-card:nth-child(2),
.note-row.is-thread-note.note-enter .thread-stack .thread-card:nth-child(3){
  opacity: 0;
}

.note-row.is-thread-note.note-enter.note-enter-active .thread-stack .thread-card:nth-child(2){
  opacity: 1;
  transition: opacity 200ms ease-out 60ms;
}

.note-row.is-thread-note.note-enter.note-enter-active .thread-stack .thread-card:nth-child(3){
  opacity: 1;
  transition: opacity 200ms ease-out 100ms;
}

.note-row.is-thread-note{
  padding-bottom: 24px;
}

/* delete button base */
.note-del{
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #fff;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease-out, transform 150ms ease-out;
}

.note-row:hover .note-del{
  opacity: 1;
  pointer-events: auto;
}
body.is-multi-select .note-del{
  opacity: 0 !important;
  pointer-events: none !important;
}

.note-del:active{
  transform: scale(0.98);
}

.note-del-ico{
  position: relative;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  color: #9ca3af;
}

/* icon overlay for white part */
.note-del-ico .ico-base{
  display:block;
}
.note-del-ico .ico-mask{
  display:block;
  position:absolute;
  inset: 0;
  opacity: 0;
  /* we clip it during hold */
  clip-path: inset(0 100% 0 0);
}

/* hold fill */
.note-del::before{
  content:"";
  position:absolute;
  inset: 0;
  background: #ef4444;
  transform: scaleX(0);
  transform-origin: left;
  opacity: 0;
}

/* during hold */
.note-del.is-holding::before{
  opacity: 1;
  animation: holdFill var(--hold-ms) linear forwards;
}
.note-del.is-holding .ico-mask{
  opacity: 1;
  animation: holdClip var(--hold-ms) linear forwards;
}
.note-del.is-holding .note-del-ico{
  /* keep base gray, masked part becomes white */
}

/* cancel fallback */
.note-del.is-cancel::before{
  opacity: 0;
  transform: scaleX(0);
  animation: none;
}
.note-del.is-cancel .ico-mask{
  opacity: 0;
  clip-path: inset(0 100% 0 0);
  animation: none;
}

/* bottom action bar for multi-select */
.multi-action-bar{
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: var(--composer-offset);
  pointer-events: none;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 190ms ease-out, transform 190ms ease-out;
  z-index: var(--z-bar);
}

.multi-action-bar.is-visible{
  pointer-events: auto;
  opacity: 1;
  transform: translateY(0);
}

.multi-action-inner{
  border: 1px solid #111111;
  background: rgba(17, 17, 17, 0.97);
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  border-radius: 14px;
  padding: 10px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
}

.multi-action-count{
  font-size: 13px;
  color: #d1d5db;
  font-weight: 600;
  white-space: nowrap;
}

.multi-action-buttons{
  display:flex;
  align-items:center;
  gap: 8px;
}

.multi-action-btn{
  border-radius: 10px;
  border: 1px solid #374151;
  background: #1f2937;
  color: #f9fafb;
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
  transition: transform 120ms ease-out, opacity 150ms ease-out, border-color 150ms ease-out;
}

.multi-action-btn:active:not(:disabled){
  transform: scale(0.98);
}

.multi-action-btn:disabled{
  opacity: 0.55;
  cursor: not-allowed;
}

.multi-action-btn.thread{
  background: #1f2937;
}

.multi-action-btn.danger{
  position: relative;
  overflow: hidden;
  border-color: #ef4444;
  color: #fca5a5;
  background: rgba(127, 29, 29, 0.16);
}

.multi-action-btn.danger::before{
  content:"";
  position:absolute;
  inset: 0;
  background: #ef4444;
  transform: scaleX(0);
  transform-origin: left;
  opacity: 0;
}

.multi-action-btn.danger .multi-del-label{
  position: relative;
  z-index: 1;
}

.multi-action-btn.danger.is-holding{
  color: #fff;
}

.multi-action-btn.danger.is-holding::before{
  opacity: 1;
  animation: holdFill var(--hold-ms) linear forwards;
}

.multi-action-btn.danger.is-cancel::before{
  opacity: 0;
  transform: scaleX(0);
  animation: none;
}

/* thread bottom sheet */
.thread-sheet{
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  pointer-events: none;
}

body.thread-sheet-open{
  overflow: hidden;
  overscroll-behavior: none;
}

.thread-sheet-overlay{
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(15, 23, 42, 0.5);
  opacity: 0;
  transition: opacity 220ms ease-out;
}

.thread-sheet-panel{
  position: absolute;
  left: 50%;
  top: max(10px, env(safe-area-inset-top, 10px));
  bottom: max(10px, env(safe-area-inset-bottom, 10px));
  width: min(672px, calc(100vw - 24px));
  height: auto;
  max-height: none;
  border-radius: 20px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 24px 60px -22px rgba(15, 23, 42, 0.38), 0 8px 24px -12px rgba(15, 23, 42, 0.2);
  padding: 8px 14px 14px 14px;
  opacity: 0;
  transform: translate(-50%, 24px) scale(0.985);
  transition: transform 320ms cubic-bezier(0.32, 0.72, 0, 1), opacity 240ms ease-out;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  will-change: transform, opacity;
}

.thread-sheet-panel.is-dragging{
  transition: none;
}

.thread-sheet.is-open{
  pointer-events: auto;
}

.thread-sheet.is-open .thread-sheet-overlay{
  opacity: 1;
}

.thread-sheet.is-open .thread-sheet-panel{
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.thread-sheet-handle{
  width: 44px;
  height: 4px;
  border-radius: 999px;
  background: #d1d5db;
  margin: 2px auto 10px auto;
  cursor: grab;
  touch-action: none;
}

.thread-sheet-panel.is-dragging .thread-sheet-handle{
  cursor: grabbing;
}

.thread-sheet-head{
  width: 100%;
  margin: 0;
  padding: 0 16px 12px 16px;
  position: relative;
}
.thread-sheet-head::after{
  content: "";
  position: absolute;
  left: -14px;
  right: -14px;
  bottom: 0;
  height: 1px;
  background: #f3f4f6;
}

.thread-sheet-head-main{
  min-width: 0;
  flex: 1 1 auto;
  width: min(624px, 100%);
  margin: 0 auto;
  padding-right: 112px;
}

.thread-sheet-head-actions{
  position: absolute;
  top: 0;
  right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.thread-share-trigger{
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #6b7280;
  height: 30px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: color 150ms ease-out, border-color 150ms ease-out, background-color 150ms ease-out, transform 150ms ease-out;
}
.thread-share-trigger:hover{
  color: #374151;
  background: #f9fafb;
}
.thread-share-trigger:active{
  transform: scale(0.97);
}
.thread-share-trigger.is-open{
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.06);
}
.thread-share-trigger:focus-visible{
  outline: 2px solid rgba(239, 68, 68, 0.35);
  outline-offset: 2px;
}

.thread-share-popover{
  position: absolute;
  right: 16px;
  top: 38px;
  width: min(250px, calc(100vw - 40px));
  padding: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 14px 30px -18px rgba(15, 23, 42, 0.45), 0 8px 16px -12px rgba(15, 23, 42, 0.25);
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  transform-origin: top right;
  pointer-events: none;
  transition: opacity 140ms ease-out, transform 180ms cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 2;
}
.thread-share-popover.is-open{
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.thread-share-popover-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 2px 8px 2px;
}

.thread-share-toggle-label{
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
}

.thread-share-toggle{
  border: 0;
  background: #d1d5db;
  height: 18px;
  width: 32px;
  padding: 0;
  border-radius: 999px;
  color: transparent;
  position: relative;
  cursor: pointer;
  transition: background-color 180ms ease-out, box-shadow 180ms ease-out, transform 150ms ease-out;
}
.thread-share-toggle::after{
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.25);
  transition: transform 180ms cubic-bezier(0.32, 0.72, 0, 1);
}
.thread-share-toggle:active{
  transform: scale(0.97);
}
.thread-share-toggle.is-on{
  background: linear-gradient(135deg, #f87171, #ef4444);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.12);
}
.thread-share-toggle.is-on::after{
  transform: translateX(14px);
}
.thread-share-toggle:focus-visible{
  outline: 2px solid rgba(239, 68, 68, 0.35);
  outline-offset: 2px;
}

.thread-share-popover-action{
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #6b7280;
  height: 30px;
  width: 100%;
  padding: 0 10px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: color 150ms ease-out, border-color 150ms ease-out, background-color 150ms ease-out, transform 150ms ease-out;
  margin-top: 6px;
}
.thread-share-popover-action:hover{
  color: #374151;
  background: #f9fafb;
}
.thread-share-popover-action:active{
  transform: scale(0.97);
}
.thread-share-popover-action.is-disabled{
  opacity: 0.5;
  cursor: not-allowed;
}

.thread-share-hint{
  display: block;
  margin-top: 8px;
  font-size: 11px;
  color: #9ca3af;
  line-height: 1.35;
}

body.public-thread .thread-sheet-head-main{
  padding-right: 0;
  padding-top: 8px;
}

@media (max-width: 640px){
  .thread-sheet-head-main{
    padding-right: 0;
  }
  .thread-sheet-head-actions{
    position: static;
    justify-content: flex-end;
    margin-top: 10px;
  }
  .thread-share-popover{
    right: 16px;
    top: 76px;
  }
}

.thread-sheet-title{
  font-size: 16px;
  font-weight: 700;
  color: #111827;
  cursor: pointer;
  border-radius: 6px;
  padding: 2px 6px;
  margin: -2px -6px;
  transition: background 150ms ease-out;
}
.thread-sheet-title:hover{
  background: rgba(0,0,0,0.04);
}
.thread-sheet-title-input{
  font-size: 16px;
  font-weight: 700;
  color: #111827;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 6px 12px;
  margin: -6px -12px;
  outline: none;
  width: calc(100% + 24px);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.10);
}
.thread-sheet-title-input:focus{
  border-color: #e5e7eb;
}

.thread-sheet-subtitle{
  margin-top: 0;
  font-size: 12px;
  color: #6b7280;
}

.thread-sheet-close{
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #9ca3af;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: static;
  transition: color 150ms ease-out, background-color 150ms ease-out, transform 150ms ease-out;
}
.thread-sheet-close:hover{
  color: #4b5563;
  background: rgba(17, 24, 39, 0.05);
}
.thread-sheet-close:active{
  transform: scale(0.96);
}
.thread-sheet-close:focus-visible{
  outline: 2px solid #d1d5db;
  outline-offset: 2px;
}

.thread-sheet-list{
  width: min(624px, 100%);
  margin: 0 auto;
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 4px 0 10px 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.thread-sheet-list .note-row{
  grid-template-columns: 64px 1fr auto;
  padding: 10px 0;
}

.thread-sheet-list .note-row .note-del{
  opacity: 0;
  pointer-events: none;
}

.thread-sheet-list .note-row:hover .note-del{
  opacity: 1;
  pointer-events: auto;
}

/* thread composer */
.thread-composer{
  width: 100%;
  margin: 0;
  padding: 10px 16px 0 16px;
  position: relative;
}
.thread-composer::before{
  content: "";
  position: absolute;
  left: -14px;
  right: -14px;
  top: 0;
  height: 1px;
  background: #e5e7eb;
}
.thread-composer-inner{
  min-height: 52px;
  width: min(624px, 100%);
  margin: 0 auto;
}

/* thread preview title in feed */
.thread-preview.has-title{
  font-weight: 700;
  color: #111827;
}

@keyframes holdFill{
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

@keyframes holdClip{
  from { clip-path: inset(0 100% 0 0); }
  to   { clip-path: inset(0 0 0 0); }
}

/* removing animation (opacity/transform only) */
.note-row.note-removing{
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 180ms ease-out, transform 180ms ease-out;
}

/* just-sent animation */
.note-row.note-enter{
  opacity: 0;
  transform: translateY(8px);
}
.note-row.note-enter.note-enter-active{
  opacity: 1;
  transform: translateY(0);
  transition: opacity 180ms ease-out, transform 180ms ease-out;
}

/* edit highlight (NO layout shift) */
.note-row.note-editing{
  background: rgba(250, 204, 21, 0.13);
  border-radius: 12px;
}

/* cancel button in edit mode (always visible) */
.note-del.note-cancel{
  opacity: 1 !important;
  pointer-events: auto !important;
  border-color: rgba(250, 204, 21, 0.35);
  background: rgba(250, 204, 21, 0.12);
  transform: none !important;
}
.note-del.note-cancel .note-del-ico{
  color: #9ca3af;
}

/* ===========================
   TASKS (checkbox + highlight)
   =========================== */

.task-line{
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* smaller checkbox */
.task-check{
  width: 20px;
  height: 20px;
  border-radius: 5px;

  border: 1px solid #e5e7eb;
  background: #ffffff;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  color: transparent; /* check hidden until completed */
  transition: transform 150ms ease-out, background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out;
}
.task-check:active{
  transform: scale(0.96);
}
.task-check-ico{
  display: block;
}

.note-row.task-completed .task-check{
  background: #ef4444;
  border-color: #ef4444;
  color: #ffffff;
}

/* task text */
.task-text{
  display: inline;
  white-space: pre-wrap;
  word-break: break-word;
  text-wrap: pretty;
}

/* lighter highlight pill */
.task-pill{
  padding: 2px 8px 4px 8px;
  border-radius: 5px;
  background: #fef2f2;
  color: #ef4444;
  font-weight: 600;
}

/* strike-through when completed */
.note-row.task-completed .task-text{
  color: #9ca3af;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: rgba(156, 163, 175, 0.7);
}

/* ===========================
   QUESTIONS (answer field)
   =========================== */

.answer-wrap{
  margin-top: 10px;
  width: 100%;
  display:flex;
  align-items:center;
  gap: 10px;
  position: relative;

  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 10px 44px 10px 12px;
}

.answer-label{
  font-size: 13px;
  color: #9ca3af;
  font-style: italic;
  flex: 0 0 auto;
  user-select: none;
}

.answer-input{
  border: 0;
  outline: none;
  background: transparent;
  padding: 0;
  margin: 0;

  font-size: 14px;
  line-height: 22px;
  color: #111827;
  min-width: 0;
  flex: 1 1 auto;
}

.answer-input::placeholder{
  color: #c0c4cc;
}

.answer-input[readonly]{
  cursor: default;
}

.answer-wrap.is-answer-editing{
  box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.04);
}

.answer-save{
  position:absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fff;
  display:flex;
  align-items:center;
  justify-content:center;

  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease-out, transform 150ms ease-out;
  color: #111827;
}

.answer-save.is-visible{
  opacity: 1;
  pointer-events: auto;
}

.answer-save:active{
  transform: translateY(-50%) scale(0.98);
}

/* subtle appear (newly created note with question) */
.answer-wrap.answer-enter{
  opacity: 0;
  transform: translateY(6px);
}
.answer-wrap.answer-enter.answer-enter-active{
  opacity: 1;
  transform: translateY(0);
  transition: opacity 180ms ease-out, transform 180ms ease-out;
}

@media (max-width: 640px){
  .topbar{
    padding: 12px 12px 10px 12px;
  }

  .topbar-right{
    gap: 8px;
  }

  .topbar-email{
    max-width: 140px;
    font-size: 12px;
  }

  .top-nav-btn{
    width: 28px;
    height: 28px;
  }

  .logout-icon-btn{
    width: 30px;
    height: 30px;
    border-radius: 8px;
  }

  .multi-action-inner{
    flex-wrap: wrap;
  }

  .multi-action-count{
    width: 100%;
  }

  .multi-action-buttons{
    width: 100%;
  }

  .multi-action-btn{
    flex: 1 1 auto;
  }
}

/* typography */
.folder-feed-title,
.thread-sheet-title,
.folder-card .folder-title {
  text-wrap: balance;
}

.empty-text,
.empty-hint {
  text-wrap: pretty;
}

/* changelog modal */
.changelog-modal{
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease-out;
  display: flex;
  align-items: center;
  justify-content: center;
}
.changelog-modal.is-open{
  pointer-events: auto;
  opacity: 1;
}
.changelog-modal-bg{
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.changelog-modal-panel{
  position: relative;
  background: #fff;
  border-radius: 20px;
  padding: 32px 28px 28px;
  max-width: 380px;
  width: calc(100% - 32px);
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  opacity: 0;
  transform: scale(0.92) translateY(12px);
  animation: changelogIn 350ms ease-out 80ms forwards;
}
@keyframes changelogIn{
  to{ opacity: 1; transform: scale(1) translateY(0); }
}
.changelog-close{
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #f3f4f6;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 150ms ease-out, color 150ms ease-out;
}
.changelog-close:hover{
  background: #e5e7eb;
  color: #111827;
}
.changelog-header{
  font-size: 22px;
  font-weight: 800;
  color: #111827;
  margin-bottom: 20px;
  text-wrap: balance;
}
.changelog-list{
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.changelog-list li{
  font-size: 14px;
  line-height: 1.5;
  color: #374151;
  padding-left: 20px;
  position: relative;
}
.changelog-list li::before{
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
}
.changelog-list li strong{
  color: #111827;
  font-weight: 700;
}

/* === Related note link === */
.related-link{
  display: block;
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.35;
  color: #9ca3af;
  text-decoration: none;
  cursor: pointer;
  transition: color 150ms ease-out;
}
.related-link:hover{
  color: #6b7280;
}
.related-link:active{
  color: #4b5563;
}
.note-row.task-completed .related-link{
  color: #d1d5db;
}

/* flash highlight for scroll-to related note */
.note-row.note-flash{
  animation: noteFlash 1.5s ease-out;
}
@keyframes noteFlash{
  0%{ background-color: rgba(239, 68, 68, 0.12); }
  100%{ background-color: transparent; }
}

/* === Drag reorder === */
.drag-ghost{
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
  transform: scale(1.02);
  will-change: top;
}
.drag-placeholder{
  border-radius: 12px;
  background: rgba(239, 68, 68, 0.06);
  border: 2px dashed rgba(239, 68, 68, 0.2);
  transition: height 150ms ease-out;
}
.note-moved{
  display: inline-block;
  margin-left: 4px;
  font-size: 13px;
  color: #9ca3af;
  cursor: pointer;
  vertical-align: middle;
  transition: color 150ms ease-out;
}
.note-moved:hover{
  color: #ef4444;
}
body.is-reordering{
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
body.is-reordering .note-del{
  opacity: 0 !important;
  pointer-events: none !important;
}

@media (prefers-reduced-motion: reduce){
  *,
  *::before,
  *::after{
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
