/* 发推文 / 编辑推文 /community/post-editor (htmltibiu416/community/editor.html): X-style composer.
 * Column of 600px; the tool bar sticks to the bottom of the screen on phones so it rides above the keyboard. */

/* Beats components.css body[data-tibiu-skin].tb-page:not(...) (0,3,1). */
body[data-tibiu-skin][data-tibiu-page].ce-body.tb-page { background: var(--tb-surface) !important; }
.ce { display: flex; flex-direction: column; max-width: 600px; min-height: calc(100dvh - 120px); margin: 0 auto; }
.ce [hidden] { display: none !important; }
.ce-submit { min-width: 64px; }

/* ---------- Text ---------- */
.ce-compose { flex: 1 1 auto; padding: 12px var(--tb-gutter) 16px; }
.ce-editor .ProseMirror {
  min-height: 132px;
  outline: none;
  color: var(--tb-ink);
  font-size: 18px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  caret-color: var(--tb-primary);
}
.ce-editor .ProseMirror p { margin: 0; }
.ce-editor .ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  height: 0;
  color: var(--tb-muted);
  pointer-events: none;
}
.ce-editor .ProseMirror[contenteditable="false"] { opacity: .5; }
.ce-node { color: var(--tb-primary); }
.ce-node--quote { font-weight: 600; }
.ce-node.ProseMirror-selectednode { border-radius: 4px; background: var(--tb-primary-soft, rgb(33 150 243 / 12%)); }
.ce-error { margin: 8px 0 0; color: var(--tb-danger); font-size: 14px; }

/* ---------- Images ---------- */
.ce-media { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 14px; }
.ce-media[data-count="1"] { grid-template-columns: minmax(0, 1fr); }
.ce-media__item { position: relative; aspect-ratio: 1; overflow: hidden; border-radius: 14px; background: var(--tb-fill); }
.ce-media[data-count="1"] .ce-media__item { aspect-ratio: 4 / 3; }
.ce-media__item img { width: 100%; height: 100%; object-fit: cover; }
.ce-media__item.is-uploading img { opacity: .55; }
.ce-media__item.is-failed img { opacity: .35; filter: grayscale(1); }
.ce-media__progress { position: absolute; right: 10px; bottom: 10px; left: 10px; height: 4px; overflow: hidden; border-radius: 2px; background: rgb(255 255 255 / 60%); }
.ce-media__progress::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--ce-progress, 0%);
  border-radius: inherit;
  background: var(--tb-primary);
  transition: width .2s ease;
}
.ce-media__remove {
  --tb-icon: 16px;
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(15 20 25 / 72%);
  color: #fff;
  cursor: pointer;
}
.ce-media__remove::after { content: ""; position: absolute; inset: -6px; }
.ce-media__retry {
  position: absolute;
  inset: 50% auto auto 50%;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 16px;
  background: rgb(15 20 25 / 78%);
  color: #fff;
  font: inherit;
  font-size: 13px;
  transform: translate(-50%, -50%);
  cursor: pointer;
}
.ce-media__retry ti-icon { --ti-icon-size: 16px !important; width: 16px; height: 16px; }

/* ---------- Tool bar ---------- */
.ce-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px calc(var(--tb-gutter) - 8px) calc(6px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--tb-divider);
  background: var(--tb-surface);
}
.ce-tools { display: flex; align-items: center; gap: 2px; min-width: 0; }
.ce-tool { --tb-icon: 22px; width: 40px; height: 40px; color: var(--tb-primary); }
.ce-tool:disabled { opacity: .4; }
.ce-tool[aria-pressed="true"] { background: var(--tb-press); }
.ce-tool--hash { font-size: 21px; font-weight: 600; line-height: 1; }
@media (hover: hover) { .ce-tool:not(:disabled):hover { background: var(--tb-primary-soft, rgb(33 150 243 / 10%)); } }

/* X-style ring: fills as the text grows, shows the remaining count in the last 20 characters. */
.ce-count {
  --ce-p: 0%;
  display: grid;
  flex: none;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-right: 8px;
  border-radius: 50%;
  background: conic-gradient(var(--tb-primary) var(--ce-p), var(--tb-divider) 0);
  color: var(--tb-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  -webkit-mask: radial-gradient(circle, transparent 9px, #000 9.5px);
  mask: radial-gradient(circle, transparent 9px, #000 9.5px);
}
.ce-count.is-warn, .ce-count.is-over { width: 32px; height: 32px; -webkit-mask: none; mask: none; background: none; position: relative; }
.ce-count.is-warn::before, .ce-count.is-over::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(var(--ce-ring, #f5a623) var(--ce-p), var(--tb-divider) 0);
  -webkit-mask: radial-gradient(circle, transparent 12px, #000 12.5px);
  mask: radial-gradient(circle, transparent 12px, #000 12.5px);
}
.ce-count.is-over { --ce-ring: var(--tb-danger); color: var(--tb-danger); }

/* ---------- Emoji ---------- */
.ce-emoji { border-top: 1px solid var(--tb-divider); background: var(--tb-surface); }
.ce-emoji__tabs { display: flex; gap: 4px; overflow-x: auto; padding: 8px var(--tb-gutter) 0; scrollbar-width: none; }
.ce-emoji__tabs::-webkit-scrollbar { display: none; }
.ce-emoji__tab {
  flex: none;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--tb-divider);
  border-radius: 15px;
  background: var(--tb-surface);
  color: var(--tb-ink-2);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.ce-emoji__tab.is-active { border-color: var(--tb-ink); color: var(--tb-ink); font-weight: 600; }
.ce-emoji__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 4px; max-height: 236px; overflow-y: auto; padding: 8px calc(var(--tb-gutter) - 4px) 12px; }
.ce-emoji__item { display: grid; place-items: center; aspect-ratio: 1; padding: 4px; border: 0; border-radius: 10px; background: none; cursor: pointer; }
.ce-emoji__item img { width: 100%; height: 100%; object-fit: contain; }
@media (hover: hover) { .ce-emoji__item:hover { background: var(--tb-press); } }
.ce-emoji__empty { margin: 0; padding: 24px; color: var(--tb-muted); text-align: center; }

/* ---------- Inline @ / # suggestions ---------- */
.ce-suggest {
  position: absolute;
  z-index: 1500;
  width: 280px;
  max-height: 300px;
  overflow-y: auto;
  padding: 6px 0;
  border-radius: 12px;
  background: var(--tb-surface);
  box-shadow: 0 0 0 1px rgb(0 0 0 / 6%), 0 10px 32px rgb(0 0 0 / 14%);
}
.ce-suggest__item, .ce-pick__row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 14px;
  border: 0;
  background: none;
  color: var(--tb-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.ce-suggest__item.is-active { background: var(--tb-press); }
@media (hover: hover) { .ce-suggest__item:hover, .ce-pick__row:hover { background: var(--tb-press); } }
.ce-suggest__item > .tb-avatar, .ce-pick__row > .tb-avatar { --tb-avatar: 36px; flex: none; }
.ce-suggest__body, .ce-pick__body { display: grid; flex: 1 1 auto; min-width: 0; line-height: 1.3; }
.ce-suggest__body strong, .ce-pick__body strong { overflow: hidden; font-size: 15px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.ce-suggest__body small, .ce-pick__body small { overflow: hidden; color: var(--tb-muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.ce-suggest__hash, .ce-pick__hash {
  display: grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--tb-fill);
  color: var(--tb-ink-2);
  font-size: 17px;
  font-weight: 600;
}

/* ---------- Search sheet (提到谁 / 添加话题 / 引用作品) ---------- */
.ce-pick-layer > .ce-pick { display: flex; flex-direction: column; height: min(78dvh, 640px); max-height: none; overflow: hidden; padding-bottom: 0; }
.ce-pick__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 8px 4px var(--tb-gutter); }
.ce-pick__head strong { font-size: 17px; font-weight: 700; }
.ce-pick__search { margin: 6px var(--tb-gutter) 8px; }
.ce-pick__list { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: env(safe-area-inset-bottom, 0px); transition: opacity .15s ease; }
.ce-pick__list.is-loading { opacity: .5; }
.ce-pick__row { padding: 10px var(--tb-gutter); }
.ce-pick__cover { flex: none; width: 40px; height: 54px; overflow: hidden; border-radius: 6px; background: var(--tb-fill); }
.ce-pick__cover img { width: 100%; height: 100%; object-fit: cover; }
.ce-pick__empty { margin: 0; padding: 40px var(--tb-gutter); color: var(--tb-muted); font-size: 14px; text-align: center; }
@media (min-width: 761px) {
  .tbs-sheet-layer.ce-pick-layer > .ce-pick { width: 440px; height: min(70vh, 600px); max-height: none; padding: 0; }
}

@media (min-width: 761px) {
  .ce { min-height: 0; margin-top: 8px; border: 1px solid var(--tb-divider); border-radius: 16px; overflow: hidden; }
  .ce-bar { position: static; }
  .ce-editor .ProseMirror { min-height: 180px; font-size: 20px; }
}
