/* 元件：對話框、選單、提示、通知、卡片、上傳、留言、版本、預覽、發布包 */

/* 對話框：手機從底部滑出 */
.modal-back { position: fixed; inset: 0; z-index: 200; background: rgba(15, 12, 8, .45); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.modal-back.out { opacity: 0; transition: opacity .18s; }
.modal {
  background: var(--surface); width: 100%; max-height: calc(100dvh - var(--safe-t) - 24px); display: flex; flex-direction: column;
  border-radius: 18px 18px 0 0; box-shadow: var(--shadow-2); animation: up .2s ease-out; padding-bottom: var(--safe-b);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 6px 20px; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 8px 20px 16px; overflow-y: auto; overscroll-behavior: contain; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.modal-foot .btn { flex: 1; }
@media (min-width: 768px) {
  .modal-back { align-items: center; }
  .modal { width: min(520px, calc(100vw - 48px)); border-radius: 18px; padding-bottom: 0; }
  .modal.wide { width: min(1100px, calc(100vw - 48px)); }
  .modal-foot .btn { flex: none; min-width: 96px; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: .4; } }

/* 選單 */
.menu-back { position: fixed; inset: 0; z-index: 210; background: rgba(15, 12, 8, .35); display: flex; align-items: flex-end; }
.menu { width: 100%; background: var(--surface); border-radius: 18px 18px 0 0; padding: 8px 8px calc(8px + var(--safe-b)); max-height: 70dvh; overflow-y: auto; animation: up .18s ease-out; }
.menu.pop { position: fixed; width: auto; min-width: 220px; max-width: 320px; border-radius: 12px; border: 1px solid var(--line); box-shadow: var(--shadow-2); padding: 6px; animation: fade .1s; }
.menu-back:has(.menu.pop) { background: transparent; }
.menu-title { font-size: 12.5px; font-weight: 700; color: var(--muted); padding: 8px 12px 6px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 0 14px; border: 0; background: none; border-radius: 10px; text-align: left; cursor: pointer; font-weight: 550; }
.menu.pop .menu-item { min-height: 40px; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); }
.menu-item.active { color: var(--accent-ink); }
.menu-item.danger { color: var(--danger); }
.menu-item .ic:last-child { margin-left: auto; }

/* 提示 */
.toasts { position: fixed; z-index: 300; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + var(--safe-b) + 12px); display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 12px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow-2); font-weight: 550; font-size: 14.5px; animation: up .18s; transition: opacity .3s; }
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: #1C3B2E; color: #DFF6EA; }
.toast.out { opacity: 0; }
.toast-act { background: none; border: 0; color: inherit; font-weight: 800; text-decoration: underline; cursor: pointer; }
body.has-actionbar .toasts { bottom: calc(76px + var(--safe-b)); }
@media (min-width: 768px) { .toasts { bottom: 24px; } body.has-actionbar .toasts { bottom: 24px; } }

/* 通知 */
.notif-pop { position: fixed; z-index: 220; width: 380px; max-height: 70vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-2); padding: 6px; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif { display: flex; gap: 10px; width: 100%; padding: 10px; border: 0; background: none; border-radius: 10px; text-align: left; cursor: pointer; min-height: var(--tap); }
.notif:hover { background: var(--surface-2); }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: none; }
.notif.unread .notif-dot { background: var(--accent); }
.notif-text { display: flex; flex-direction: column; min-width: 0; }
.notif-title { font-weight: 650; }
.notif.unread .notif-title { color: var(--ink); }
.notif-body { color: var(--ink-2); font-size: 13.5px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.notif-time { color: var(--muted); font-size: 12px; }
.notif-page { padding: 6px; }
.push-btn { margin: 6px 0; }
.push-settings:empty { display: none; }

/* 卡片 */
.ws-card { padding: 16px; display: flex; flex-direction: column; gap: 14px; transition: border-color .15s, transform .1s; }
.ws-card:hover, .project-card:hover { border-color: var(--line-strong); }
.ws-card-top { display: flex; gap: 12px; align-items: center; }
.ws-card-foot { display: flex; justify-content: space-between; }
.project-card { padding: 16px; display: flex; flex-direction: column; gap: 8px; min-height: 150px; }
.project-card.archived { opacity: .65; }
.project-card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.project-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; }
.project-card-foot { margin-top: auto; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.card-more { margin: -6px -6px 0 0; }

.item-card { display: flex; flex-direction: column; overflow: hidden; border-radius: 12px; cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.item-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); }
.item-card.dragging { opacity: .4; }
.thumb { aspect-ratio: 16 / 10; background: var(--surface-3); position: relative; overflow: hidden; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.thumb-play { position: absolute; right: 8px; bottom: 8px; background: rgba(0, 0, 0, .55); color: #fff; border-radius: 6px; padding: 4px; line-height: 0; }
.item-card-body { padding: 10px 12px 8px; display: flex; flex-direction: column; gap: 6px; }
.item-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kind-label { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--muted); font-weight: 600; }
.item-card h4 { font-size: 14.5px; font-weight: 650; line-height: 1.4; }
.item-card-foot { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); min-height: 28px; }
.stat { display: inline-flex; align-items: center; gap: 3px; }
.card-status-btn { margin-left: auto; margin-right: -6px; }

/* 上傳 */
.upload-panel { display: flex; flex-direction: column; gap: 12px; }
.dropzone { border: 2px dashed var(--line-strong); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; background: var(--surface); transition: border-color .15s, background .15s; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-ic { color: var(--accent); }
.drop-text { display: flex; flex-direction: column; }
.up-files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.up-files li { display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 12px; background: var(--surface-2); border-radius: 8px; }
.up-files li .ellipsis { flex: 1; }
.upload-panel.busy .dropzone { opacity: .5; pointer-events: none; }

/* 留言 */
.comments { display: flex; flex-direction: column; gap: 12px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; }
.composer { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.composer textarea { border: 0; min-height: 52px; padding: 6px; box-shadow: none !important; resize: none; background: transparent; }
.composer-box { position: relative; }
.composer-foot { display: flex; align-items: center; gap: 8px; justify-content: space-between; flex-wrap: wrap; }
.anchor-slot { flex: 1; min-width: 0; }
.anchor-ctl { display: flex; flex-wrap: wrap; gap: 6px; }
.mention-pop { position: absolute; left: 0; bottom: 100%; margin-bottom: 4px; z-index: 50; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-2); padding: 4px; min-width: 240px; max-width: 100%; }
.mention { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 0 10px; border: 0; background: none; border-radius: 8px; cursor: pointer; text-align: left; }
.mention.on, .mention:hover { background: var(--surface-2); }
.mention .muted { margin-left: auto; overflow: hidden; text-overflow: ellipsis; }
.mention-tag { color: var(--accent-ink); font-weight: 650; }
.comment-list { display: flex; flex-direction: column; gap: 8px; }
.comment { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; transition: border-color .2s, box-shadow .2s; }
.comment.active { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.comment.resolved { opacity: .65; }
.comment-row { display: flex; gap: 10px; }
.comment-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.comment-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.comment-body { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
.comment-actions { display: flex; gap: 12px; }
.replies { margin: 8px 0 0 42px; display: flex; flex-direction: column; gap: 10px; }
.replies:empty { display: none; }
.reply-box { margin: 8px 0 0 42px; display: flex; flex-direction: column; gap: 6px; }
.anchor-chip { align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; border: 0; cursor: pointer; background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; font-size: 12.5px; padding: 3px 9px; border-radius: 999px; font-variant-numeric: tabular-nums; min-height: 26px; }

/* 版本 */
.version-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.version { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.version.viewing { border-color: var(--accent); }
.version.purged { opacity: .6; }
.version-main { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; width: 100%; padding: 10px 12px; border: 0; background: none; text-align: left; cursor: pointer; }
.version-main:hover { background: var(--surface-2); }
.v-n { font-weight: 750; }
.v-tags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.v-who, .v-note, .v-files { grid-column: 1 / -1; display: flex; align-items: center; gap: 6px; }
.v-note { color: var(--ink-2); white-space: pre-wrap; }
.v-actions { display: flex; gap: 12px; padding: 0 12px 6px; }

/* 預覽 */
.preview { display: flex; flex-direction: column; gap: 10px; }
.frame { position: relative; width: 100%; background: #0E0D0C; border-radius: 14px; overflow: hidden; display: flex; align-items: center; justify-content: center; margin: 0 auto; }
.frame[data-frame="9:16"] { aspect-ratio: 9 / 16; max-width: min(100%, calc(72dvh * 9 / 16)); }
.frame[data-frame="4:5"] { aspect-ratio: 4 / 5; max-width: min(100%, calc(72dvh * 4 / 5)); }
.frame[data-frame="1:1"] { aspect-ratio: 1; max-width: min(100%, 72dvh); }
.frame[data-frame=auto], .frame[data-frame=threads] { max-height: 75dvh; }
.frame .player, .frame .annot { width: 100%; height: 100%; }
.frame video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.frame[data-frame=auto] video { height: auto; max-height: 75dvh; }
.player { display: flex; flex-direction: column; position: relative; }
.frame .player { display: block; }
.marker-row { display: flex; align-items: center; gap: 10px; padding: 0 2px; }
.frame .marker-row { position: absolute; left: 10px; right: 10px; bottom: 52px; pointer-events: none; }
.markers { position: relative; flex: 1; height: 16px; border-radius: 8px; background: rgba(255, 255, 255, .12); }
.player:not(.audio) .player-time { color: #fff; text-shadow: 0 1px 2px #000; }
.marker { position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; border: 2px solid #fff; background: var(--accent); cursor: pointer; pointer-events: auto; padding: 0; box-shadow: 0 1px 3px rgba(0, 0, 0, .5); }
.marker::before { content: ""; position: absolute; inset: -14px; } /* 觸控範圍 */
.marker.resolved { background: #9E978C; }
.player.audio { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; gap: 10px; }
.player.audio audio { width: 100%; }
.player.audio .markers { background: var(--surface-3); }
.alt-files { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--ink-2); }

.annot { position: relative; user-select: none; -webkit-user-select: none; }
.annot-img { width: 100%; height: 100%; object-fit: contain; -webkit-touch-callout: none; }
.frame[data-frame=auto] .annot-img { height: auto; max-height: 75dvh; }
.annot-overlay { position: absolute; }
.annot.drawing .annot-overlay { cursor: crosshair; touch-action: none; outline: 2px dashed var(--accent); outline-offset: -2px; }
.box { position: absolute; border: 2.5px solid var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); border-radius: 4px; padding: 0; cursor: pointer; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); }
.box.resolved { border-color: #9E978C; background: transparent; border-style: dashed; }
.box.active { border-color: #fff; box-shadow: 0 0 0 3px var(--accent), 0 0 18px rgba(0, 0, 0, .5); }
.box.draft, .box.pending { border-style: dashed; pointer-events: none; }
.box.pending { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.box-n { position: absolute; top: -11px; left: -11px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; }

.carousel { display: flex; flex-direction: column; gap: 8px; }
.car-stage { position: relative; }
.car-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; border-radius: 14px; overscroll-behavior-x: contain; }
.car-track::-webkit-scrollbar { display: none; }
.car-slide { flex: 0 0 100%; scroll-snap-align: center; scroll-snap-stop: always; }
.car-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .9); color: #222; display: none; align-items: center; justify-content: center; cursor: pointer; box-shadow: var(--shadow-2); }
.car-nav.prev { left: 10px; } .car-nav.next { right: 10px; }
.car-count { position: absolute; top: 10px; right: 10px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 12.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.car-dots { display: flex; justify-content: center; gap: 2px; flex-wrap: wrap; }
.car-dot { width: 24px; height: 24px; border: 0; background: none; cursor: pointer; position: relative; padding: 0; }
.car-dot::after { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--line-strong); }
.car-dot.on::after { background: var(--accent); inset: 7px; }
@media (hover: hover) { .car-nav { display: flex; } }

.pdf-view { display: flex; flex-direction: column; gap: 10px; }
.pdf-frame { width: 100%; height: 75dvh; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.office-list { display: flex; flex-direction: column; gap: 10px; }
.office-card { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.office-ic { width: 52px; height: 52px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; }
.office-info { flex: 1; display: flex; flex-direction: column; min-width: 140px; }
.purged { padding: 40px 20px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; background: var(--surface-2); border-radius: 14px; }

/* 文字 */
.text-editor { display: flex; flex-direction: column; gap: 10px; }
.text-body { font-size: 16px; min-height: 160px; }
.text-actions { display: flex; flex-direction: column; gap: 8px; }
.text-actions .row { justify-content: flex-end; }
.threads-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; max-width: 560px; }
.threads-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.threads-text { white-space: pre-wrap; word-break: break-word; font-size: 15px; }

/* 比較 */
.compare { display: flex; flex-direction: column; gap: 14px; }
.compare-pickers { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.compare-cols { display: grid; grid-template-columns: 1fr; gap: 14px; }
.compare-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.compare-col .frame { max-height: 60dvh; }
@media (min-width: 768px) { .compare-cols { grid-template-columns: 1fr 1fr; } }
.diff-body { margin: 0; font-family: var(--mono); font-size: 13px; background: var(--surface-2); border-radius: 10px; padding: 10px; white-space: pre-wrap; word-break: break-word; max-height: 50dvh; overflow: auto; }
.d-add { background: color-mix(in srgb, var(--ok) 18%, transparent); }
.d-del { background: color-mix(in srgb, var(--danger) 16%, transparent); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--danger) 60%, transparent); }
.diff-legend span { padding: 0 6px; border-radius: 4px; }

/* 發布包 */
.publish-kit { border: 1.5px solid color-mix(in srgb, var(--ok) 45%, var(--line)); background: linear-gradient(180deg, color-mix(in srgb, var(--ok) 7%, var(--surface)), var(--surface)); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.kit-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--ok); }
.kit-head h3 { color: var(--ink); font-size: 16px; }
.kit-row { display: grid; grid-template-columns: 88px 1fr; gap: 10px; align-items: start; }
.kit-label { display: flex; align-items: center; gap: 6px; font-weight: 650; color: var(--ink-2); min-height: var(--tap); }
.kit-btns { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.kit-media { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kit-caption { white-space: pre-wrap; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; max-height: 7.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.kit-music { display: flex; align-items: center; gap: 6px; min-height: var(--tap); color: var(--ink-2); }
.kit-each { display: flex; flex-wrap: wrap; gap: 6px; }
.kit-done { grid-template-columns: 1fr; }
@media (max-width: 767px) { .kit-row { grid-template-columns: 1fr; gap: 4px; } .kit-label { min-height: 0; } }

/* 手機底部操作列（項目頁） */
.item-actionbar { display: none; }
@media (max-width: 767px) {
  body.has-actionbar .tabbar { display: none; }
  .item-actionbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px;
    position: fixed; z-index: 45; left: 0; right: 0; bottom: 0; padding: 8px calc(10px + var(--safe-r)) calc(8px + var(--safe-b)) calc(10px + var(--safe-l));
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line);
  }
  .ab-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 12.5px; font-weight: 650; color: var(--ink); cursor: pointer; padding: 0 4px; text-align: center; }
  .ab-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
  body.has-actionbar .main { padding-bottom: calc(84px + var(--safe-b)); }
}
