/* ── Shared composer modal ──────────────────────────────────────────
   One calm writing space for every web form. The page stays visible
   behind it; long writing scrolls inside the sheet, never the page.
   Mobile: bottom sheet. Desktop: centered card. Theme-aware via vars. */

.cmp-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  padding: 0;
}
.cmp-modal-overlay.open { display: flex; }

@media (min-width: 720px) {
  .cmp-modal-overlay {
    align-items: center;
    padding: 24px;
  }
}

.cmp-modal-sheet {
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface, #fff);
  color: var(--text, #111);
  border: 1px solid var(--border, #e5e5e5);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -12px 48px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  animation: cmp-sheet-up 0.22s ease-out;
}
@media (min-width: 720px) {
  .cmp-modal-sheet {
    border-bottom: 1px solid var(--border, #e5e5e5);
    border-radius: 20px;
  }
}
@keyframes cmp-sheet-up {
  from { transform: translateY(24px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.cmp-modal-grab {
  display: flex;
  justify-content: center;
  padding: 10px 0 2px;
  flex-shrink: 0;
}
.cmp-modal-grab span {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--border, #e5e5e5);
}

.cmp-modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 18px 12px;
  border-bottom: 1px solid var(--border, #e5e5e5);
  flex-shrink: 0;
}
.cmp-modal-face {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-muted, #f4f4f5);
  border: 1px solid var(--border, #e5e5e5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  overflow: hidden;
  flex-shrink: 0;
}
.cmp-modal-face img { width: 100%; height: 100%; object-fit: cover; }
.cmp-modal-titles { flex: 1; min-width: 0; }
.cmp-modal-title {
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.cmp-modal-sub { font-size: 12px; color: var(--muted, #71717a); font-weight: 600; margin-top: 2px; }
.cmp-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--border, #e5e5e5);
  background: transparent;
  color: var(--muted, #71717a);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.cmp-modal-close:hover { color: var(--text, #111); border-color: var(--muted, #71717a); }

/* Scrollable writing area — the page behind never moves. */
.cmp-modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  min-height: 0;
}

/* Long text stays pleasant: grows to ~1/3 of the viewport, then scrolls. */
.cmp-modal-body textarea {
  width: 100%;
  min-height: 120px;
  max-height: 38vh;
  max-height: 38dvh;
  resize: none;
  overflow-y: auto;
  padding: 12px 14px;
  border: 1px solid var(--border, #e5e5e5);
  border-radius: 12px;
  font: inherit;
  font-size: 15px;
  line-height: 1.6;
  background: var(--bg, #fff);
  color: var(--text, #111);
  box-sizing: border-box;
}
.cmp-modal-body textarea:focus {
  outline: none;
  border-color: var(--premium-accent, #a3794a);
}
.cmp-modal-body input[type="text"],
.cmp-modal-body input[type="url"],
.cmp-modal-body select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border, #e5e5e5);
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  background: var(--bg, #fff);
  color: var(--text, #111);
  box-sizing: border-box;
}
.cmp-modal-body input:focus,
.cmp-modal-body select:focus {
  outline: none;
  border-color: var(--premium-accent, #a3794a);
}
.cmp-modal-label {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: var(--text, #111);
  margin-bottom: 6px;
}
.cmp-modal-label span { font-weight: 600; color: var(--muted, #71717a); }
.cmp-modal-hint { font-size: 12px; color: var(--muted, #71717a); line-height: 1.55; margin: 0; }
.cmp-modal-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
}

/* Sticky footer — Post is always in reach, even in a long draft. */
.cmp-modal-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border, #e5e5e5);
  background: var(--surface, #fff);
  flex-shrink: 0;
}
.cmp-modal-note { font-size: 11.5px; color: var(--muted, #71717a); font-weight: 600; }
.cmp-modal-spacer { flex: 1; }
.cmp-modal-btn {
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  border: 1px solid var(--border, #e5e5e5);
  background: transparent;
  color: var(--text, #111);
}
.cmp-modal-btn-primary {
  background: #141412;
  color: #ffffff;
  border-color: #141412;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.cmp-modal-btn-primary:hover:not(:disabled) {
  background: #232320;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
}
.cmp-modal-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* Small trigger that lives on the page — content stays visible. */
.cmp-trigger {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 18px;
  border: 1px solid var(--border, #e5e5e5);
  border-radius: 16px;
  background: var(--surface, #fff);
  color: var(--muted, #71717a);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  margin-bottom: 16px;
}
.cmp-trigger:hover {
  border-color: var(--premium-accent, #a3794a);
  box-shadow: 0 4px 16px rgba(163, 121, 74, 0.1);
  color: var(--text, #111);
  transform: translateY(-1px);
}
.cmp-trigger .cmp-trigger-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-muted, #f4f4f5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  overflow: hidden;
  flex-shrink: 0;
}
.cmp-trigger .cmp-trigger-avatar img { width: 100%; height: 100%; object-fit: cover; }
