/* Composer editor: title/body inputs, format toolbar, body-editor content rules, plan mode, table edit toolbar. Loads after shared-app-shell.css. */

.composer-main {
  position: relative;
  min-width: 0;
  max-width: 100%;
  padding: 0;
}

.title-input,
.body-input,
.body-editor {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  letter-spacing: 0;
}

.title-input {
  min-height: 76px;
  border-bottom: 1px solid var(--line);
  padding: 24px 28px 18px;
  font-size: 32px;
  font-weight: var(--font-weight-heading);
  line-height: 1.2;
}

.title-input::placeholder {
  color: #8a93a0;
}

.composer-formatbar {
  position: sticky;
  top: var(--topbar-height);
  z-index: 6;
  min-height: 48px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 252, 253, 0.96);
  backdrop-filter: blur(12px);
  padding: 8px 18px;
}

.composer-format-left,
.composer-format-right {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.composer-format-select {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: #5b6573;
  padding: 0 8px 0 10px;
  font-size: 12px;
  font-weight: 700;
}

.composer-format-select select {
  min-width: 62px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  padding: 5px 0;
  font-size: 13px;
  font-weight: 800;
}

.composer-align-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  padding: 2px;
}

.composer-format-chip {
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #52616c;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 820;
  letter-spacing: 0;
}

.composer-format-chip:hover,
.composer-format-chip:focus-visible,
.composer-format-chip.is-active {
  border-color: var(--line);
  background: #ffffff;
  color: var(--accent-dark);
  outline: none;
}

.composer-blockbar {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  padding: 10px 18px;
  scrollbar-width: thin;
}

.composer-block-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: #40515e;
  padding: 0 11px;
  font-size: 13px;
  font-weight: 760;
}

.composer-block-button .app-icon {
  --icon-size: 17px;
  opacity: 0.62;
}

.composer-block-button .tool-mark {
  min-width: 16px;
  font-size: 12px;
}

.composer-block-button:hover,
.composer-block-button:focus-visible {
  border-color: var(--line-strong);
  background: var(--soft);
  color: var(--accent-dark);
  outline: none;
}

.format-button {
  width: 30px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #5b6573;
  padding: 0;
}

.format-button:hover,
.format-button:focus-visible,
.format-button.is-active {
  background: var(--accent-soft);
  color: var(--accent-dark);
  outline: none;
}

.format-button:disabled,
.composer-format-select:has(select:disabled) {
  opacity: 0.42;
  pointer-events: none;
}

.format-align-icon {
  width: 15px;
  height: 12px;
  display: grid;
  gap: 2px;
}

.format-align-icon::before,
.format-align-icon::after,
.format-align-icon {
  background:
    linear-gradient(currentColor 0 0) 0 0 / var(--align-line-1, 100%) 2px no-repeat,
    linear-gradient(currentColor 0 0) var(--align-offset-2, 0) 5px / var(--align-line-2, 72%) 2px no-repeat,
    linear-gradient(currentColor 0 0) var(--align-offset-3, 0) 10px / var(--align-line-3, 100%) 2px no-repeat;
}

.format-align-icon.is-left {
  --align-offset-2: 0;
}

.format-align-icon.is-center {
  --align-line-1: 82%;
  --align-line-2: 60%;
  --align-line-3: 82%;
  --align-offset-2: 3px;
  --align-offset-3: 1.5px;
}

.format-align-icon.is-right {
  --align-line-2: 72%;
  --align-offset-2: 4px;
}

.compose-mode-tabs {
  display: flex;
  align-items: flex-end;
  gap: 26px;
  margin: 0;
  border-bottom: 1px solid var(--line);
}

.compose-mode-tab {
  position: relative;
  min-height: 34px;
  border: 0;
  border-bottom: 1.5px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 7px 0 8px;
  font-size: 14px;
  font-weight: 700;
}

.compose-mode-tab:hover,
.compose-mode-tab:focus-visible {
  color: var(--ink);
  outline: none;
}

.compose-mode-tab.is-active {
  border-bottom-color: var(--ink);
  color: var(--ink);
}

.composer-category-field {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  padding: 0 12px;
}

.composer-category-field .app-icon {
  --icon-size: 17px;
  opacity: 0.66;
}

.composer-category-field select {
  min-width: 140px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  padding: 7px 0;
  font-size: 13px;
  font-weight: 800;
}

.composer-category-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.body-input {
  resize: none;
  min-height: 64px;
  padding: 2px 0 10px;
  font-size: 19px;
  line-height: 1.45;
}

.body-store {
  display: none;
}

.body-editor {
  min-height: 440px;
  min-width: 0;
  max-width: 100%;
  padding: 26px 32px 104px;
  font-size: 16.5px;
  line-height: 1.7;
  caret-color: var(--accent);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.composer-context-panel:empty {
  display: none;
}

.composer-source-signal {
  display: grid;
  gap: 8px;
  margin: 6px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 10px 12px;
}

.composer-source-signal-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.composer-source-signal-header strong {
  color: var(--ink);
}

.composer-source-signal blockquote {
  margin: 0;
  border-left: 3px solid var(--accent);
  color: var(--ink);
  padding-left: 9px;
  font-size: 13.5px;
  font-weight: 800;
  line-height: 1.55;
}

.composer-source-signal-actions {
  display: flex;
  justify-content: flex-end;
}

.composer-source-signal-actions button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.composer-source-signal-actions button:hover,
.composer-source-signal-actions button:focus-visible {
  border-color: var(--line-strong);
  color: var(--ink);
  outline: none;
}

.composer-inline-settings {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid var(--line);
  background: #fbfcfd;
  padding: 10px 18px 0;
}

.body-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

.body-editor p {
  min-width: 0;
  margin: 0 0 6px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.body-editor ul,
.body-editor ol {
  margin: 6px 0;
  padding-left: 26px;
}

.body-editor ul { list-style: disc; }
.body-editor ol { list-style: decimal; }

.body-editor li {
  margin: 3px 0;
  padding-left: 4px;
}

.body-editor hr {
  margin: 22px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.body-editor a {
  color: var(--accent-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: color-mix(in srgb, var(--accent) 42%, transparent);
}

.body-editor a:hover {
  text-decoration-color: var(--accent);
}

.body-editor ::selection {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.body-editor .ticy-editor-heading,
.structured-content .ticy-editor-heading {
  margin: 28px 0 6px;
  color: var(--ink);
  font-weight: var(--font-weight-heading);
  line-height: 1.25;
  letter-spacing: -0.012em;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.body-editor .ticy-editor-heading:first-child,
.structured-content .ticy-editor-heading:first-child {
  margin-top: 0;
}

.body-editor .ticy-editor-heading-1,
.structured-content .ticy-editor-heading-1 {
  font-size: 30px;
}

.body-editor .ticy-editor-heading-2,
.structured-content .ticy-editor-heading-2 {
  font-size: 24px;
}

.body-editor .ticy-editor-heading-3,
.structured-content .ticy-editor-heading-3 {
  font-size: 20px;
}

.body-editor [data-align="left"],
.structured-content [data-align="left"] {
  text-align: left;
}

.body-editor [data-align="center"],
.structured-content [data-align="center"] {
  text-align: center;
}

.body-editor [data-align="right"],
.structured-content [data-align="right"] {
  text-align: right;
}

.body-editor .rt-inline-image-frame {
  position: relative;
  display: block;
  width: fit-content;
  max-width: 90%;
  margin: 12px auto;
  cursor: grab;
}

.body-editor .rt-inline-image-frame[data-align="left"],
.structured-content .rt-inline-image-frame[data-align="left"] {
  margin-left: 0;
  margin-right: auto;
}

.body-editor .rt-inline-image-frame[data-align="center"],
.structured-content .rt-inline-image-frame[data-align="center"] {
  margin-left: auto;
  margin-right: auto;
}

.body-editor .rt-inline-image-frame[data-align="right"],
.structured-content .rt-inline-image-frame[data-align="right"] {
  margin-left: auto;
  margin-right: 0;
}

.body-editor .rt-inline-image-frame img {
  display: block;
  max-width: 100% !important;
  height: auto !important;
  margin: 0;
  border-radius: 8px;
  object-fit: contain;
}

.body-editor .rt-inline-image-frame[data-width] img {
  width: 100%;
}

.body-editor .rt-inline-image-frame.is-selected,
.body-editor .rt-inline-image-frame.is-resizing {
  outline: 2px solid rgba(0, 122, 85, 0.35);
  outline-offset: 3px;
}

.body-editor .rt-inline-image-frame.is-dragging {
  cursor: grabbing;
  opacity: 0.72;
}

.body-editor .rt-inline-image-resize {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 16px;
  height: 16px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(15, 20, 25, 0.24);
  cursor: nwse-resize;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.body-editor .rt-inline-image-frame:hover .rt-inline-image-resize,
.body-editor .rt-inline-image-frame.is-selected .rt-inline-image-resize,
.body-editor .rt-inline-image-frame.is-resizing .rt-inline-image-resize {
  opacity: 1;
}

.body-editor img:not(.rt-inline-image) {
  display: block;
  max-width: 90% !important;
  height: auto !important;
  margin: 10px auto;
  object-fit: contain;
}

.body-editor blockquote,
.body-editor pre,
.body-editor details,
.body-editor .ticy-todo-editor,
.body-editor table {
  margin: 14px 0;
}

.body-editor blockquote {
  max-width: 100%;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: color-mix(in srgb, var(--accent) 5%, #ffffff);
  padding: 10px 16px;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.62;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.body-editor pre {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid #1f2933;
  border-radius: 8px;
  background: #0f1720;
  color: #e7eef5;
  padding: 14px 16px;
  font-size: 13.5px;
  line-height: 1.62;
  tab-size: 2;
}

.body-editor pre code {
  font-family: ui-monospace, "SFMono-Regular", "JetBrains Mono", "Cascadia Code", Consolas, "Courier New", monospace;
  font-size: inherit;
  white-space: pre;
}

.body-editor details {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.body-editor details summary {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  cursor: pointer;
  list-style: none;
  transition: background 0.12s ease;
}

.body-editor details summary::-webkit-details-marker {
  display: none;
}

.body-editor details summary::before {
  content: "";
  flex: 0 0 auto;
  width: 0;
  height: 0;
  margin-top: 7px;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 6px solid var(--muted);
  transition: transform 0.18s ease;
}

.body-editor details[open] summary::before {
  transform: rotate(90deg);
}

.body-editor details summary:hover {
  background: var(--soft);
}

.body-editor .ticy-details-body {
  min-width: 0;
  padding: 2px 12px 12px 26px;
  color: var(--ink);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.body-editor details[open] .ticy-details-body {
  animation: ticy-details-reveal 0.18s ease;
}

@keyframes ticy-details-reveal {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .body-editor details summary::before,
  .body-editor details[open] .ticy-details-body {
    transition: none;
    animation: none;
  }
}

.body-editor .ticy-todo-editor {
  max-width: 100%;
  list-style: none;
  padding: 2px 0;
  font-size: 15.5px;
  line-height: 1.55;
}

.body-editor .ticy-todo-item {
  margin: 0;
  padding: 2px 0;
}

.body-editor .ticy-todo-item label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  cursor: pointer;
}

.body-editor .ticy-todo-item input {
  width: 16px;
  height: 16px;
  margin: 3px 0 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.body-editor .ticy-todo-text {
  min-width: 0;
  outline: none;
  overflow-wrap: anywhere;
  word-break: break-word;
  transition: color 0.12s ease;
}

.body-editor .ticy-todo-item.is-checked .ticy-todo-text {
  color: var(--muted);
  text-decoration: line-through;
}

.body-editor table {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
  font-size: 14.5px;
  line-height: 1.5;
}

.body-editor th,
.body-editor td {
  min-width: 120px;
  border: 1px solid var(--line);
  padding: 9px 12px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
  transition: background 0.1s ease;
}

.body-editor th {
  background: var(--soft);
  font-weight: 600;
  color: var(--ink);
}

.body-editor table tr:hover td {
  background: color-mix(in srgb, var(--soft) 55%, transparent);
}

/* Table edit toolbar (floats over the active table; lives outside the editor) */
.table-toolbar {
  position: absolute;
  z-index: 25;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 6px 18px -8px rgba(15, 20, 25, 0.3);
}

.table-toolbar[hidden] {
  display: none;
}

.table-toolbar button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.table-toolbar button:hover {
  background: var(--soft);
}

.table-toolbar button[data-table-op="col-del"]:hover,
.table-toolbar button[data-table-op="row-del"]:hover {
  background: color-mix(in srgb, #c4314b 12%, transparent);
  color: #c4314b;
}

.table-toolbar-sep {
  width: 1px;
  height: 16px;
  background: var(--line);
  margin: 0 3px;
}

.body-editor.is-plan-mode {
  min-height: 150px;
  padding-top: 4px;
  font-size: 15px;
  line-height: 1.48;
}

.body-editor.is-plan-mode:empty::before {
  display: block;
  padding-top: 3px;
  font-size: 18px;
}

.body-editor.is-plan-mode .plan-line {
  min-height: 24px;
  border-radius: 6px;
  padding: 2px 5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.body-editor.is-plan-mode .plan-line:hover,
.body-editor.is-plan-mode .plan-line:focus-within {
  background: #edf3f7;
}

.plan-content {
  display: grid;
  gap: 2px;
}

.plan-line {
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.plan-level-0 {
  margin-top: 16px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.35;
}

.plan-level-0:first-child {
  margin-top: 0;
}

.plan-level-1 {
  margin-top: 8px;
  padding-left: 18px;
  color: #223847;
  font-size: 15.5px;
  font-weight: 800;
  line-height: 1.42;
}

.plan-level-2 {
  margin-top: 5px;
  padding-left: 34px;
  color: #31546a;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.48;
}

.plan-level-3 {
  position: relative;
  padding-left: 52px;
  color: #26323a;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.56;
}

.plan-level-3::before {
  content: "";
  position: absolute;
  top: 0.78em;
  left: 38px;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: #7890a0;
}

.plan-level-4 {
  position: relative;
  padding-left: 70px;
  color: #526676;
  font-size: 13.5px;
  line-height: 1.55;
}

.plan-level-4::before {
  content: "";
  position: absolute;
  top: 0.83em;
  left: 56px;
  width: 8px;
  height: 1px;
  background: #8ca0ad;
}

.plan-level-5 {
  padding-left: 88px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.52;
}

.title-input::placeholder,
.body-input::placeholder {
  color: var(--muted);
}

.slash-menu {
  position: absolute;
  z-index: 30;
  top: 78px;
  left: 0;
  width: min(340px, 100%);
  max-height: min(430px, calc(100vh - 150px));
  display: none;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 6px;
}

.slash-menu.is-open {
  display: grid;
  gap: 2px;
}

.slash-item {
  width: 100%;
  min-height: 54px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  padding: 7px 9px;
  text-align: left;
}

.slash-item:hover,
.slash-item.is-selected {
  background: var(--soft);
}

.slash-icon {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.slash-item strong,
.slash-item small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slash-item strong {
  font-size: 14px;
  line-height: 1.25;
}

.slash-item small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.slash-item kbd {
  color: var(--muted);
  font-size: 11px;
  font-family: inherit;
}

.reader-slash-menu {
  top: auto;
  left: 28px;
  right: 28px;
  width: auto;
  margin-top: -8px;
}

.attachment-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
}
