:root {
    --dp-primary: #635bff;
    --dp-primary-2: #8757f7;
    --dp-border: #dfe3f0;
    --dp-soft: #f5f6ff;
    --dp-text: #111827;
    --dp-muted: #667085;
}

* { box-sizing: border-box; }

body[data-page="detail-page"] {
    margin: 0;
    min-width: 1180px;
    color: var(--dp-text);
    background: #eef2ff;
    overflow: hidden;
}

.dp-app { min-height: 100vh; }

.dp-topbar {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 30px;
    background: #fff;
    border-bottom: 1px solid var(--dp-border);
}

.dp-topbar-left {
    display: inline-flex;
    align-items: center;
    gap: 14px;
}

.dp-back-link { border-radius: 999px; }

.dp-avatar {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, var(--dp-primary), var(--dp-primary-2));
    border-radius: 50%;
    font-weight: 800;
}

.dp-workspace {
    height: calc(100vh - 68px);
    display: grid;
    grid-template-columns: 300px minmax(470px, 600px) minmax(520px, 1fr);
    gap: 14px;
    padding: 14px;
}

.dp-task-panel,
.dp-chat-panel,
.dp-result-panel {
    min-height: 0;
    background: #fff;
    border: 1px solid var(--dp-border);
    border-radius: 8px;
    box-shadow: 0 8px 28px rgba(74, 85, 140, .08);
}

.dp-task-panel { display: flex; flex-direction: column; padding: 14px; }

.dp-new-task {
    height: 46px;
    border: 0;
    color: #fff;
    background: linear-gradient(100deg, #48b7ef, var(--dp-primary-2));
    border-radius: 7px;
    font-size: 15px;
    font-weight: 700;
}

.dp-task-list { flex: 1; min-height: 0; overflow-y: auto; margin: 14px -4px 10px; padding: 0 4px; }

.dp-task-item {
    width: 100%;
    display: grid;
    grid-template-columns: 60px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 11px;
    margin-bottom: 8px;
    border: 1px solid transparent;
    background: #fff;
    border-radius: 7px;
    text-align: left;
}

.dp-task-item:hover { background: #f7f8ff; }
.dp-task-item.is-active { border-color: #9694ff; background: #f1f1ff; }

.dp-task-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border: 1px solid var(--dp-border);
    border-radius: 7px;
    background: #f4f6fb;
}

.dp-task-copy { min-width: 0; }
.dp-task-name { overflow: hidden; color: #202638; font-size: 14px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.dp-task-meta { margin-top: 5px; color: var(--dp-muted); font-size: 12px; }
.dp-task-state { display: inline-block; margin-top: 6px; padding: 2px 7px; color: #6b7280; background: #f3f4f6; border-radius: 999px; font-size: 11px; }
.dp-task-state.confirmed, .dp-task-state.completed { color: #159447; background: #eafaf0; }
.dp-task-state.generating { color: #5b55e7; background: #eeedff; }
.dp-task-delete { border: 0; color: #98a2b3; background: transparent; }
.dp-task-filter { padding-top: 10px; border-top: 1px solid #edf0f7; }
.dp-search { height: 38px; display: flex; align-items: center; gap: 7px; padding: 0 10px; border: 1px solid var(--dp-border); border-radius: 6px; }
.dp-search input { width: 100%; border: 0; outline: 0; }

.dp-chat-panel { display: flex; flex-direction: column; overflow: hidden; }
.dp-chat-head, .dp-result-head { min-height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--dp-border); }
.dp-chat-title { font-weight: 800; }
.dp-chat-subtitle, .dp-result-head p { margin: 5px 0 0; color: var(--dp-muted); font-size: 12px; }
.dp-icon-btn { width: 38px; height: 38px; border: 1px solid var(--dp-border); color: var(--dp-primary); background: #fff; border-radius: 7px; }
.dp-chat-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; }
.dp-source-card { padding: 16px; border: 1px solid #dcdfff; background: #fafaff; border-radius: 8px; }
.dp-source-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; font-weight: 800; }
.dp-analysis-btn { height: 32px; padding: 0 10px; border: 1px solid #a7a5ff; color: var(--dp-primary); background: #fff; border-radius: 6px; }
.dp-field { display: block; margin-top: 13px; }
.dp-field > span, .dp-form-grid label span { display: block; margin-bottom: 7px; color: #344054; font-size: 13px; font-weight: 650; }
.dp-field b { color: #ef4444; }
.dp-field input, .dp-field textarea, .dp-form-grid input, .dp-form-grid select {
    width: 100%;
    border: 1px solid #d8dcef;
    outline: none;
    background: #fff;
    border-radius: 6px;
    color: var(--dp-text);
}
.dp-field input, .dp-form-grid input, .dp-form-grid select { height: 40px; padding: 0 11px; }
.dp-field textarea { padding: 10px 11px; resize: vertical; }
.dp-field input:focus, .dp-field textarea:focus, .dp-form-grid input:focus, .dp-form-grid select:focus { border-color: var(--dp-primary); box-shadow: 0 0 0 3px rgba(99,91,255,.1); }
.dp-upload-box { height: 112px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border: 1px dashed #a9adff; color: #5d63a3; background: #fff; border-radius: 7px; cursor: pointer; transition: border-color .2s ease, background-color .2s ease, box-shadow .2s ease; }
.dp-upload-box:hover,
.dp-upload-box.is-dragover { border-color: var(--dp-primary); background: #eef2ff; box-shadow: inset 0 0 0 1px rgba(99, 91, 255, .12); }
.dp-upload-box.is-dragover { border-style: solid; }
.dp-upload-box.is-uploading { cursor: wait; opacity: .72; }
.dp-upload-box i { font-size: 25px; color: var(--dp-primary); }
.dp-upload-box small { color: #8b92a7; }
.dp-upload-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.dp-upload-item { position: relative; width: 64px; height: 64px; }
.dp-upload-item img { width: 100%; height: 100%; object-fit: cover; border: 1px solid #d7dbea; border-radius: 6px; }
.dp-upload-item:first-child::after { content: "主"; position: absolute; left: 3px; bottom: 3px; padding: 1px 5px; color: #fff; background: rgba(17,24,39,.72); border-radius: 4px; font-size: 10px; }
.dp-upload-remove { position: absolute; top: -5px; right: -5px; width: 19px; height: 19px; display: grid; place-items: center; border: 0; color: #fff; background: #ef4444; border-radius: 50%; font-size: 11px; }
.dp-detail-reference-box { height: 92px; }
.dp-detail-reference-preview { position: relative; width: 108px; height: 138px; margin-top: 9px; }
.dp-detail-reference-preview img { width: 100%; height: 100%; object-fit: contain; border: 1px solid #d7dbea; border-radius: 6px; background: #f8f9fc; }
.dp-detail-reference-preview .dp-upload-remove { top: -6px; right: -6px; }
.dp-reference-advice { margin-top: 10px; padding: 11px; border: 1px solid #cfd4ff; background: #f5f6ff; border-radius: 7px; color: #313751; font-size: 12px; line-height: 1.55; }
.dp-reference-advice-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dp-reference-advice-head strong { color: #202638; font-size: 13px; }
.dp-reference-advice-meta { margin-top: 6px; color: #565e78; }
.dp-reference-advice-modules { margin: 7px 0 0; padding-left: 18px; }
.dp-reference-advice-modules li + li { margin-top: 3px; }
.dp-reference-apply { flex: 0 0 auto; height: 30px; padding: 0 10px; border: 1px solid #817cff; color: #554ff0; background: #fff; border-radius: 6px; font-weight: 700; }
.dp-reference-apply:hover { background: #ececff; }
.dp-brand-gene { margin-top: 15px; padding: 13px; border: 1px solid #e0e3f1; background: #fff; border-radius: 7px; }
.dp-brand-gene-head { display: flex; align-items: center; gap: 10px; }
.dp-brand-gene-head i { color: var(--dp-primary); font-size: 20px; }
.dp-brand-gene-head small { display: block; margin-top: 3px; color: var(--dp-muted); font-size: 11px; }
.dp-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 13px; }
.dp-color-field > span { display: block; margin-bottom: 7px; color: #344054; font-size: 13px; font-weight: 650; }
.dp-color-entry {
    position: relative;
    width: 100%;
    height: 40px;
    display: flex;
    align-items: center;
    border: 1px solid #d8dcef;
    color: #30364a;
    background: #fff;
    border-radius: 6px;
}
.dp-color-entry:hover { border-color: #aaa7ff; background: #fafaff; }
.dp-color-picker-target {
    min-width: 0;
    height: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    border: 0;
    color: inherit;
    background: transparent;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.dp-color-swatch {
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(17,24,39,.08);
    color: #fff;
    background: var(--selected-color, #635bff);
    border-radius: 50%;
}
.dp-color-swatch.is-auto { border-color: #dcdcff; color: var(--dp-primary); background: #f0efff; }
.dp-color-copy {
    min-width: 0;
    height: 100%;
    flex: 1;
    display: flex;
    align-items: center;
}
.dp-color-copy strong { display: block; font-size: 13px; line-height: 1; }
.dp-color-clear {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    margin-right: 5px;
    display: grid;
    place-items: center;
    border: 0;
    color: #7d8497;
    background: #f2f3f7;
    border-radius: 50%;
}
.dp-color-clear:hover { color: #ef4444; background: #fff0f0; }
.dp-color-arrow { color: #a0a6b7; font-size: 12px; }
.dp-color-picker-target:focus-visible { outline: 2px solid var(--dp-primary); outline-offset: -2px; border-radius: 5px; }
body[data-page="detail-page"] .brand-color-modal-content { box-shadow: 0 24px 70px rgba(17, 24, 39, .3); }
body[data-page="detail-page"] .brand-color-modal-content .modal-close {
    display: grid;
    place-items: center;
    border: 0;
    background: transparent;
}
.dp-brand-notes { margin-top: 12px; }
.dp-start-btn {
    width: 100%;
    min-height: 58px;
    display: grid;
    grid-template-columns: 24px 1fr 18px;
    gap: 10px;
    align-items: center;
    margin-top: 14px;
    padding: 10px 14px;
    border: 0;
    color: #fff;
    background: linear-gradient(100deg, #4a9ff2, var(--dp-primary-2));
    border-radius: 7px;
    text-align: left;
}
.dp-start-btn:disabled { cursor: wait; opacity: .7; }
.dp-start-btn strong, .dp-start-btn small { display: block; }
.dp-start-btn strong { font-size: 15px; }
.dp-start-btn small { margin-top: 3px; color: rgba(255,255,255,.8); font-size: 11px; }
.dp-messages { padding: 18px 2px 4px; }
.dp-message { display: flex; gap: 9px; margin-bottom: 14px; }
.dp-message.is-user { flex-direction: row-reverse; }
.dp-message-avatar { width: 31px; min-width: 31px; max-width: 31px; height: 31px; min-height: 31px; max-height: 31px; aspect-ratio: 1 / 1; flex: 0 0 31px; align-self: flex-start; overflow: hidden; display: grid; place-items: center; color: #fff; background: var(--dp-primary); border-radius: 999px; font-size: 12px; font-weight: 800; line-height: 1; }
.dp-message-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: center 58%; border-radius: 999px; clip-path: circle(50% at 50% 50%); transform: scale(1.12); transform-origin: center center; }
.dp-message.is-user .dp-message-avatar { background: #111827; }
.dp-message-bubble { max-width: 82%; padding: 10px 12px; border: 1px solid #e1e4f0; background: #fff; border-radius: 7px; color: #30364a; font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.dp-message.is-user .dp-message-bubble { border-color: #dcd9ff; background: #efeeff; }
.dp-message-bubble > :first-child { margin-top: 0; }
.dp-message-bubble > :last-child { margin-bottom: 0; }
.dp-message-bubble p { margin: 0 0 8px; white-space: pre-wrap; }
.dp-message-bubble h2,
.dp-message-bubble h3,
.dp-message-bubble h4 {
    margin: 15px 0 7px;
    color: #202638;
    line-height: 1.4;
    letter-spacing: 0;
}
.dp-message-bubble h2 { font-size: 17px; }
.dp-message-bubble h3 { font-size: 15px; }
.dp-message-bubble h4 { font-size: 14px; }
.dp-message-bubble strong { color: #22283a; font-weight: 750; }
.dp-message-bubble ul,
.dp-message-bubble ol { margin: 5px 0 9px; padding-left: 21px; }
.dp-message-bubble li { margin: 3px 0; }
.dp-message-bubble hr { height: 1px; margin: 12px 0; border: 0; background: #e6e8f0; }
.dp-message-main { min-width: 0; max-width: 82%; }
.dp-message-main .dp-message-bubble { max-width: none; }
.dp-message-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
    padding: 9px 10px;
    border: 1px solid #dedcff;
    background: linear-gradient(90deg, #f8fbff, #f7f3ff);
    border-radius: 7px;
}
.dp-message-price { color: #6f7690; font-size: 12px; }
.dp-message-price strong { color: #4f46e5; font-size: 14px; }
.dp-message-confirm {
    min-height: 36px;
    padding: 0 14px;
    border: 0;
    color: #fff;
    background: linear-gradient(100deg, #4a9ff2, var(--dp-primary-2));
    border-radius: 6px;
    font-weight: 750;
    white-space: nowrap;
}
.dp-message-confirm:disabled { opacity: .6; cursor: wait; }
.dp-message.is-thinking .dp-message-bubble { display: flex; align-items: center; gap: 8px; color: #737b91; }
.dp-thinking-dots { display: inline-flex; gap: 3px; }
.dp-thinking-dots i { width: 5px; height: 5px; background: var(--dp-primary); border-radius: 50%; animation: dp-thinking 1s infinite ease-in-out; }
.dp-thinking-dots i:nth-child(2) { animation-delay: .14s; }
.dp-thinking-dots i:nth-child(3) { animation-delay: .28s; }
@keyframes dp-thinking {
    0%, 70%, 100% { transform: translateY(0); opacity: .35; }
    35% { transform: translateY(-3px); opacity: 1; }
}
.dp-chat-composer { padding: 12px 14px; border-top: 1px solid var(--dp-border); }
.dp-chat-composer textarea { width: 100%; min-height: 70px; padding: 10px 12px; border: 1px solid #d8dcef; outline: 0; resize: none; border-radius: 7px; }
.dp-chat-composer textarea:disabled { color: #98a2b3; background: #f5f6f8; cursor: not-allowed; }
.dp-composer-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.dp-composer-actions span { color: #8a91a6; font-size: 12px; }
.dp-composer-actions .dp-price-summary { max-width: 72%; color: #60677b; font-weight: 650; line-height: 1.55; }
.dp-composer-actions .dp-price-summary.is-insufficient { color: #dc2626; }
.dp-price-summary strong { color: var(--dp-primary); font-size: 14px; }
.dp-send-btn { height: 36px; padding: 0 15px; border: 0; color: #fff; background: var(--dp-primary); border-radius: 6px; font-weight: 700; }
.dp-send-btn:disabled { background: #c9ccda; cursor: not-allowed; }

.dp-result-panel { display: flex; flex-direction: column; overflow: hidden; }
.dp-result-head h2 { margin: 0; font-size: 18px; }
.dp-status { padding: 5px 10px; color: #5f6678; background: #eef0f6; border-radius: 999px; font-size: 12px; }
.dp-status.confirmed, .dp-status.completed { color: #168a45; background: #e9f9ef; }
.dp-status.generating { color: #5b55e7; background: #ecebff; }
.dp-result-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; background: #fbfcff; }
.dp-plan { padding: 16px; border: 1px solid #dadcff; background: #fff; border-radius: 8px; }
.dp-plan-summary { padding-bottom: 13px; border-bottom: 1px solid #edf0f7; line-height: 1.65; }
.dp-plan-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dp-plan-title-row > span { padding: 4px 8px; color: #5b55e7; background: #f0efff; border-radius: 5px; font-size: 12px; }
.dp-plan-root-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dp-plan-field { display: block; margin-top: 8px; }
.dp-plan-field span { display: block; margin-bottom: 4px; color: #667085; font-size: 11px; }
.dp-plan-field input, .dp-plan-field textarea, .dp-plan-field select,
.dp-module-editor input, .dp-module-editor textarea, .dp-module-editor select {
    width: 100%;
    padding: 7px 8px;
    border: 1px solid #dde1ee;
    outline: 0;
    background: #fff;
    border-radius: 5px;
    color: #30364a;
    font: inherit;
}
.dp-plan-field textarea, .dp-module-editor textarea { resize: vertical; }
.dp-plan-field input:focus, .dp-plan-field textarea:focus, .dp-plan-field select:focus,
.dp-module-editor input:focus, .dp-module-editor textarea:focus, .dp-module-editor select:focus { border-color: var(--dp-primary); }
.dp-module-list { display: grid; gap: 8px; margin-top: 14px; }
.dp-module-item { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 9px; align-items: start; padding: 10px; background: #f7f8fc; border-radius: 6px; }
.dp-module-index { width: 27px; height: 27px; display: grid; place-items: center; color: #fff; background: var(--dp-primary); border-radius: 5px; font-size: 12px; }
.dp-module-editor { display: grid; gap: 6px; }
.dp-module-editor-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 6px; }
.dp-module-transition-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.dp-module-ratio { color: #6d7385; font-size: 12px; }
.dp-plan-save-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid #edf0f7; }
.dp-plan-save-row > span { color: #7a8194; font-size: 11px; }
.dp-results-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.dp-result-card { overflow: hidden; border: 1px solid #dde1ed; background: #fff; border-radius: 7px; }
.dp-result-media { aspect-ratio: 3 / 2; position: relative; display: grid; place-items: center; background: #f2f4f8; }
.dp-result-media img { width: 100%; height: 100%; object-fit: cover; }
.dp-result-check {
    position: absolute;
    z-index: 2;
    top: 9px;
    right: 9px;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border: 2px solid rgba(255,255,255,.95);
    color: transparent;
    background: rgba(17,24,39,.42);
    border-radius: 50%;
    box-shadow: 0 4px 14px rgba(17,24,39,.2);
}
.dp-result-check.is-selected { color: #fff; background: var(--dp-primary); }
.dp-result-progress { width: 68%; height: 5px; overflow: hidden; background: #dfe2eb; border-radius: 99px; }
.dp-result-progress span { display: block; height: 100%; background: var(--dp-primary); transition: width .25s; }
.dp-result-card-copy { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px; }
.dp-result-card-copy > div:first-child { min-width: 0; }
.dp-result-card-copy strong { display: block; font-size: 13px; }
.dp-result-card-copy span { display: block; margin-top: 3px; color: var(--dp-muted); font-size: 12px; }
.dp-result-tools { display: flex; flex: 0 0 auto; gap: 5px; }
.dp-result-tools button {
    height: 30px;
    padding: 0 8px;
    border: 1px solid #d9ddec;
    color: #535b70;
    background: #fff;
    border-radius: 5px;
    font-size: 11px;
    white-space: nowrap;
}
.dp-result-tools button:hover:not(:disabled) { border-color: #aaa7ff; color: var(--dp-primary); background: #f8f7ff; }
.dp-result-tools button:disabled { opacity: .45; cursor: not-allowed; }

@media (max-width: 760px) {
    .dp-message-main { max-width: calc(100% - 40px); }
    .dp-message-action { align-items: stretch; flex-direction: column; }
    .dp-message-confirm { width: 100%; }
    .dp-module-transition-row { grid-template-columns: 1fr; }
}
.dp-merged { margin-top: 16px; overflow: hidden; border: 1px solid #d9dcef; background: #fff; border-radius: 7px; }
.dp-merged-head { display: flex; align-items: center; justify-content: space-between; padding: 11px 12px; border-bottom: 1px solid #e5e7ef; }
.dp-merged img { display: block; width: 100%; height: auto; background: #fff; }
.hidden { display: none !important; }

@media (max-width: 1450px) {
    .dp-workspace { grid-template-columns: 260px 500px minmax(480px, 1fr); }
}
