/* Task detail sheet (.td-) and rich text editor (.ed-). Tokens only. */

/* ---------- Sheet frame ---------- */
.sheet.td-sheet { width: min(760px, 100vw); outline: none; }
.td-root { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.td-head { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 12px 0 20px; border-bottom: 1px solid var(--line); flex: none; }
.td-crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; font-size: 13px; color: var(--text-2); }
.td-crumbs a, .td-crumbs button { color: var(--text-2); font-weight: 500; max-width: 220px; }
.td-crumbs a:hover, .td-crumbs button:hover { color: var(--text); text-decoration: underline; }
.td-crumbs .ico { color: var(--text-3); }
.td-head-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.td-head-actions .btn.is-on { color: var(--brand-text); }
.td-key { font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 600; }
.td-key .ico { opacity: 0; transition: opacity var(--dur); }
.td-key:hover .ico, .td-key:focus-visible .ico { opacity: 1; }
.td-nav { display: inline-flex; margin: 0 2px; padding: 0 2px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.td-google { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r-sm); }
.td-google.is-error { box-shadow: inset 0 0 0 1.5px var(--danger); background: var(--danger-soft); }
.td-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 28px 28px; scroll-behavior: smooth; }

.td-banner { display: flex; align-items: center; gap: 10px; padding: 9px 12px; margin-bottom: 14px; border-radius: var(--r-md); background: var(--surface-3); color: var(--text-2); font-size: 13px; }
.td-banner.is-warn { background: var(--warning-soft); color: var(--text); }
.td-banner.is-warn > .ico { color: var(--warning); }

/* Title */
.td-title-row { display: flex; align-items: flex-start; gap: 12px; }
.td-check-slot { padding-top: 7px; }
.td-check-slot .drop-check, .td-check-slot .drop-check svg { width: 22px; height: 22px; }
.td-title { flex: 1; min-width: 0; resize: none; overflow: hidden; border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; padding: 3px 8px; margin-left: -8px; font-size: 21px; line-height: 1.35; font-weight: 700; letter-spacing: -.015em; color: var(--text); transition: border-color var(--dur), background var(--dur); }
.td-title:hover:not([readonly]) { background: var(--surface-2); }
.td-title:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); background: var(--surface); }
.td-title.is-done { color: var(--text-2); }
.td-created { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 4px 0 18px 34px; }
.td-done-note { display: inline-flex; align-items: center; gap: 4px; color: var(--success); }

/* Properties */
.td-props { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 20px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.td-prop { display: flex; align-items: center; gap: 8px; min-height: 36px; min-width: 0; }
.td-prop.is-wide { grid-column: 1 / -1; align-items: flex-start; }
.td-prop.is-wide .td-prop-label { padding-top: 7px; }
.td-prop-label { display: inline-flex; align-items: center; gap: 8px; width: 122px; flex: none; font-size: 13px; color: var(--text-2); }
.td-prop-label .ico { width: 15px; height: 15px; color: var(--text-3); }
.td-prop-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-prop-value { flex: 1; min-width: 0; display: flex; align-items: center; }
.td-pv { display: inline-flex; align-items: center; gap: 8px; min-height: 30px; max-width: 100%; padding: 3px 8px; margin-left: -8px; border-radius: var(--r-sm); font-size: 13.5px; color: var(--text); text-align: left; transition: background var(--dur); }
.td-pv:hover:not(:disabled) { background: var(--hover); }
.td-pv:disabled { cursor: default; opacity: 1; }
.td-pv .ico { color: var(--text-2); }
.td-pv .td-ok { color: var(--success); }
.td-pv.td-add { color: var(--text-3); margin-left: 0; }
.td-empty { color: var(--text-3); }
.td-subtle { font-size: 12px; color: var(--text-3); }
.td-tags { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.td-star.is-on { color: var(--warning); fill: var(--warning); }
.td-rems { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.td-rems .chip { padding-right: 3px; }
.td-x { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 4px; color: var(--text-3); }
.td-x:hover { background: var(--line); color: var(--text); }
.td-cf-input { width: 100%; max-width: 240px; height: 30px; padding: 0 8px; margin-left: -8px; border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; font-size: 13.5px; }
.td-cf-input:hover:not(:disabled) { background: var(--hover); }
.td-cf-input:focus { outline: none; background: var(--surface); border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.td-time { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.td-time-total { display: inline-flex; align-items: center; min-height: 30px; font-weight: 600; margin-right: 6px; font-size: 13.5px; }
.td-time-total .td-empty { font-weight: 400; }
.td-files-count:empty { display: none; }

/* Popover forms (reminder, time log, custom date) */
.td-pop-form { display: flex; flex-direction: column; gap: 12px; padding: 14px; width: 320px; max-width: calc(100vw - 24px); }
.td-pop-pad { padding: 10px; }
.td-preset { cursor: pointer; } .td-preset:hover { background: var(--brand-soft); color: var(--brand-text); }
.td-logs { gap: 6px; padding: 8px; border-radius: var(--r-sm); background: var(--surface-2); }

/* Sections */
.td-sec { padding: 20px 0 4px; }
.td-sec + .td-sec { border-top: 1px solid var(--line); margin-top: 16px; }
.td-sec-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 10px; min-height: 28px; }
.td-sec-head h3 { font-size: 14.5px; font-weight: 600; white-space: nowrap; }
.td-none { font-size: 13px; color: var(--text-3); padding: 4px 0; }

/* Subtasks */
.td-sub-progress { width: 110px; }
.td-sub { position: relative; display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 2px 8px 2px calc(var(--depth) * 24px); border-radius: var(--r-sm); }
.td-sub:hover { background: var(--surface-2); }
.td-sub.is-dragging { opacity: .35; }
.td-sub.is-drop-before::before, .td-sub.is-drop-after::after { content: ""; position: absolute; left: calc(var(--depth) * 24px); right: 0; height: 2px; border-radius: 2px; background: var(--brand); }
.td-sub.is-drop-before::before { top: -1px; } .td-sub.is-drop-after::after { bottom: -1px; }
.td-sub-ghost { position: fixed; top: -200px; left: -2000px; background: var(--surface); box-shadow: var(--shadow-drag); border-radius: var(--r-md); transform: rotate(1.5deg); }
.td-grip, .td-grip-space { width: 16px; flex: none; color: var(--text-3); cursor: grab; display: inline-grid; place-items: center; opacity: 0; }
.td-sub:hover .td-grip { opacity: 1; }
.td-sub-title { flex: 1; min-width: 0; text-align: left; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.td-sub-title:hover { color: var(--brand-text); }
.td-sub-meta { display: flex; align-items: center; gap: 6px; flex: none; }
.td-sub-add { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px 0 32px; margin-top: 2px; border-radius: var(--r-sm); color: var(--text-3); cursor: text; }
.td-sub-add:hover, .td-sub-add:focus-within { background: var(--surface-2); }
.td-sub-input { flex: 1; border: 0; background: transparent; height: 32px; font-size: 13.5px; outline: none; }

/* Attachments */
.td-files-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 10px; }
[data-part="files"].is-dropping { outline: 2px dashed var(--brand); outline-offset: 4px; border-radius: var(--r-md); background: var(--brand-soft); }
.td-file { position: relative; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); overflow: hidden; transition: box-shadow var(--dur), border-color var(--dur); }
.td-file:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); }
.td-file-thumb { position: relative; height: 92px; display: grid; place-items: center; background: var(--surface-2); border-bottom: 1px solid var(--line); overflow: hidden; }
.td-file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.td-pattern { position: absolute; inset: 0; background: linear-gradient(135deg, color-mix(in srgb, var(--c1) 82%, var(--surface)), color-mix(in srgb, var(--c2) 88%, var(--surface))); overflow: hidden; }
.td-pattern i { position: absolute; border-radius: 50%; background: color-mix(in srgb, var(--surface) 30%, transparent); }
.td-pattern i:nth-child(1) { width: 60%; aspect-ratio: 1; left: -12%; bottom: -30%; }
.td-pattern i:nth-child(2) { width: 34%; aspect-ratio: 1; right: 8%; top: 12%; background: color-mix(in srgb, var(--surface) 45%, transparent); }
.td-pattern i:nth-child(3) { width: 70%; height: 18%; left: 20%; top: 58%; border-radius: 8px; background: color-mix(in srgb, var(--c2) 60%, var(--text)); opacity: .25; }
.td-file-ico { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; color: var(--c); }
.td-file-ico .ico-lg { width: 30px; height: 30px; stroke-width: 1.6; }
.td-file-ico b { font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: color-mix(in srgb, var(--c) 14%, transparent); }
.td-file-ico.is-sm { width: 30px; height: 30px; border-radius: var(--r-sm); justify-content: center; background: color-mix(in srgb, var(--c) 12%, transparent); }
.td-drive-badge { position: absolute; left: 8px; bottom: 7px; display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px 0 5px; border-radius: var(--r-pill); background: var(--surface); box-shadow: var(--shadow-1); font-size: 11px; font-weight: 500; color: var(--text-2); }
.td-drive-logo { width: 14px; height: 13px; flex: none; }
.td-file-info { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 9px; min-width: 0; }
.td-file-name { font-size: 13px; font-weight: 500; }
.td-file-meta { display: flex; gap: 10px; font-size: 11.5px; color: var(--text-3); }
.td-file-del { position: absolute; top: 6px; right: 6px; background: var(--surface); box-shadow: var(--shadow-1); opacity: 0; transition: opacity var(--dur); }
.td-file:hover .td-file-del, .td-file-del:focus-visible { opacity: 1; }
.td-drive-list { display: flex; flex-direction: column; gap: 2px; max-height: 340px; overflow-y: auto; margin: 0 -6px; }
.td-drive-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--r-sm); cursor: pointer; font-size: 13.5px; }
.td-drive-item:hover { background: var(--hover); }
.td-drive-item.is-disabled { opacity: .6; cursor: default; }
.td-preview { display: grid; place-items: center; min-height: 300px; background: var(--surface-3); border-radius: var(--r-md); overflow: hidden; }
.td-preview-img { max-width: 100%; max-height: 62vh; object-fit: contain; }
.td-preview-pattern { position: relative; display: block; width: 100%; height: 52vh; }
.td-preview-pdf { width: 100%; height: 62vh; border: 0; background: var(--surface); }
.td-pdf-pages { display: flex; flex-direction: column; gap: 14px; padding: 18px; max-height: 62vh; overflow-y: auto; width: 100%; align-items: center; }
.td-pdf-page { width: min(440px, 100%); aspect-ratio: 1 / 1.3; background: #fff; color: #1d2a2f; border-radius: 4px; box-shadow: var(--shadow-2); padding: 28px 30px; display: flex; flex-direction: column; gap: 10px; }
.td-pdf-page b { font-size: 15px; margin-bottom: 6px; }
.td-pdf-page i { height: 7px; border-radius: 4px; background: #e3e9ec; }
.td-pdf-page i:nth-child(3n) { width: 72%; } .td-pdf-page i:nth-child(4n) { width: 88%; }
.td-pdf-page span { margin-top: auto; align-self: center; color: #85969c; }

/* Timeline */
.td-watchers { padding: 6px 0 12px; border-bottom: 1px dashed var(--line); margin-bottom: 10px; }
.td-tl-list { display: flex; flex-direction: column; gap: 2px; }
.td-act { display: flex; align-items: flex-start; gap: 10px; padding: 5px 0 5px 7px; font-size: 13px; color: var(--text-2); }
.td-act-ico { width: 20px; height: 20px; display: inline-grid; place-items: center; flex: none; margin-top: 1px; }
.td-act-ico.is-google { border-radius: 50%; background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
.td-act-ico.is-google .ico { width: 13px; height: 13px; }
.td-act-text b { color: var(--text); font-weight: 600; }
.td-time-ago { margin-left: 8px; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.td-cmt { display: flex; gap: 10px; padding: 12px 0; }
.td-cmt-main { flex: 1; min-width: 0; padding: 10px 12px; border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--line); }
.td-cmt-head { display: flex; align-items: center; gap: 4px; font-size: 13px; min-height: 24px; }
.td-cmt-head .td-time-ago { margin-left: 6px; }
.td-cmt-tools { margin-left: auto; display: flex; opacity: 0; transition: opacity var(--dur); }
.td-cmt:hover .td-cmt-tools, .td-cmt-tools:focus-within { opacity: 1; }
.td-cmt-body { margin-top: 2px; font-size: 13.5px; }
.td-cmt-body img { max-width: 100%; max-height: 260px; border-radius: var(--r-sm); }
.td-reacts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.td-react { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 8px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface); font-size: 12.5px; color: var(--text-2); }
.td-react:hover:not(:disabled) { border-color: var(--line-strong); }
.td-react.is-mine { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-text); }
.td-react-add { color: var(--text-3); gap: 0; }
.td-emoji { display: flex; gap: 2px; padding: 6px; }
.td-emoji button { width: 36px; height: 36px; border-radius: var(--r-sm); font-size: 19px; transition: transform 120ms var(--ease), background var(--dur); }
.td-emoji button:hover, .td-emoji button:focus-visible { background: var(--hover); transform: scale(1.15); }

/* Composer */
.td-composer { flex: none; display: flex; align-items: flex-start; gap: 10px; padding: 12px 20px 14px; border-top: 1px solid var(--line); background: var(--surface); }
.td-composer-ed { flex: 1; min-width: 0; }
.td-composer-off { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-3); padding: 4px 0; }

/* Recurrence builder */
.td-rr-days { display: flex; flex-wrap: wrap; gap: 6px; }
.td-rr-days button { width: 42px; height: 34px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); font-size: 13px; font-weight: 500; color: var(--text-2); }
.td-rr-days button:hover { background: var(--hover); }
.td-rr-days button.is-on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.td-rr-summary { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r-md); background: var(--brand-soft); color: var(--text); }
.td-rr-summary > .ico { color: var(--brand-text); margin-top: 2px; }

/* ---------- Rich text editor ---------- */
.ed { position: relative; border-radius: var(--r-md); }
.ed-content { position: relative; outline: none; min-height: 72px; padding: 8px 10px; margin: 0 -10px; border-radius: var(--r-md); transition: background var(--dur), box-shadow var(--dur); word-break: break-word; }
.ed-full .ed-content:hover:not([contenteditable="false"]) { background: var(--surface-2); }
.ed-full .ed-content:focus { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-strong); }
.ed-content.is-empty::before { content: attr(data-placeholder); position: absolute; left: 10px; top: 8px; right: 10px; color: var(--text-3); pointer-events: none; }
.ed-content img { max-width: 100%; border-radius: var(--r-sm); }
.ed-content table { width: 100%; }
.ed-content th { background: var(--surface-2); text-align: left; font-weight: 600; }
.prose ul.checklist { list-style: none; padding-left: 2px; }
.prose ul.checklist > li { position: relative; padding-left: 26px; margin: 2px 0; }
.prose ul.checklist > li::before { content: ""; position: absolute; left: 0; top: 4px; width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--line-strong); background: var(--surface); cursor: pointer; }
.prose ul.checklist > li[data-checked="true"] { color: var(--text-3); text-decoration: line-through; }
.prose ul.checklist > li[data-checked="true"]::before { background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 11px no-repeat; border-color: var(--brand); }
.ed-compact { border: 1px solid var(--line-strong); background: var(--surface); transition: border-color var(--dur), box-shadow var(--dur); }
.ed-compact.is-focused { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.ed-compact .ed-content { min-height: 40px; max-height: 200px; overflow-y: auto; margin: 0; padding: 9px 12px 4px; font-size: 13.5px; }
.ed-compact .ed-content.is-empty::before { left: 12px; top: 9px; }
.ed-bar { display: flex; align-items: center; gap: 0; padding: 2px 6px 6px; }
.ed-bar .btn-icon { color: var(--text-3); }
.ed-bar-end { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.ed-float { position: fixed; z-index: 95; display: flex; align-items: center; gap: 1px; padding: 3px; border-radius: var(--r-md); background: #1f2b30; box-shadow: var(--shadow-3); animation: menu-in 120ms var(--ease); }
.ed-float button { width: 30px; height: 28px; border-radius: 5px; display: grid; place-items: center; color: #c9d6da; }
.ed-float button:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.ed-float button.is-on { color: #7fd3f3; background: rgba(14, 162, 222, .22); }
.ed-link-input { width: 240px; height: 28px; border: 0; border-radius: 5px; padding: 0 8px; background: rgba(255, 255, 255, .1); color: #fff; outline: none; }
.ed-link-input::placeholder { color: #8fa2a8; }
.ed-menu { position: fixed; z-index: 95; width: 268px; max-height: 320px; overflow-y: auto; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-3); animation: menu-in 120ms var(--ease); }
.ed-menu-label { padding: 6px 8px 4px; font-size: 11.5px; font-weight: 500; color: var(--text-3); }
.ed-menu-item { width: 100%; display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 8px; border-radius: var(--r-sm); font-size: 13.5px; text-align: left; color: var(--text); }
.ed-menu-item.is-focused { background: var(--hover); }
.ed-menu-ico { width: 26px; height: 26px; border-radius: var(--r-sm); border: 1px solid var(--line); display: grid; place-items: center; color: var(--text-2); background: var(--surface); flex: none; }
.ed-menu-empty { padding: 10px; font-size: 13px; color: var(--text-3); }
.ed-ai-preview { padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--brand-soft-2); background: var(--brand-soft); max-height: 260px; overflow-y: auto; }
.ed-spin { animation: ed-spin 900ms linear infinite; }
@keyframes ed-spin { to { transform: rotate(360deg); } }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  .td-sheet .hide-mobile { display: none; }
  .td-head { padding: 0 6px 0 14px; }
  .td-crumbs a, .td-crumbs button { max-width: 120px; }
  .td-scroll { padding: 14px 16px 24px; }
  .td-props { grid-template-columns: 1fr; }
  .td-prop-label { width: 112px; }
  .td-created { margin-left: 34px; }
  .td-composer { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .td-composer > .avatar { display: none; }
  .td-sub-meta .t-key, .td-sub-meta .avatar-stack { display: none; }
  .td-cmt-tools, .td-file-del, .td-grip { opacity: 1; }
  .td-files-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .td-nav, .td-key .ico { display: none; }
  .td-title { font-size: 18px; }
}
