/* Scope all geometry changes to the active 灵图对话 hosts. */
.lingtu-chat-composer[hidden], .lingtu-chat-composer-head[hidden], .lingtu-chat-floating[hidden] { display: none !important; }
.lingtu-original-composer { display: none !important; }
.has-lingtu-composer .mode-switch > button:not([data-chat-expert]) { display: none !important; }
.lingtu-chat-composer {
    display: grid; grid-template-rows: auto auto minmax(56px, 1fr) auto;
    gap: 6px; min-height: 0; min-width: 0; height: 100%; color: var(--ink);
    font-size: var(--ui-surface-body-font); font-weight: var(--ui-body-weight);
}
.lingtu-chat-composer-head { grid-row: 1; }
.lingtu-chat-params { grid-row: 2; }
.lingtu-chat-input { grid-row: 3; }
.lingtu-chat-context { grid-row: 4; }
.lingtu-chat-composer-head { display: flex; align-items: center; gap: 10px; font-size: var(--ui-surface-body-font); }
.lingtu-chat-mode { display: flex; align-items: stretch; min-width: 0; }
.lingtu-chat-fixed-method {
    display: flex; align-items: center; padding: 0 16px; font-weight: var(--ui-body-weight);
    border: 1px solid var(--line); border-right: 0; border-radius: 6px 0 0 6px; background: var(--control-fill);
}
.lingtu-chat-composer-head [data-chat-expert] {
    height: var(--ui-regular-action-h, 28px); min-height: 0; padding: 0 4px;
    border-color: var(--accent); color: var(--accent); font-weight: var(--ui-label-weight);
    background: color-mix(in srgb, var(--accent) 12%, var(--control-fill));
}
.has-lingtu-composer > .lingtu-chat-composer > .lingtu-chat-context { display: none; }
.has-lingtu-composer > .lingtu-chat-composer {
    grid-template-rows: auto minmax(56px, 1fr); gap: 0; height: auto;
    margin-inline: calc(0px - var(--panel-inner-frame-bleed));
    margin-bottom: calc(0px - var(--panel-inner-frame-bleed));
}
.has-lingtu-composer > .lingtu-chat-composer > .lingtu-chat-params { grid-row: 1; }
.has-lingtu-composer > .lingtu-chat-composer > .lingtu-chat-input { grid-row: 2; }
.lingtu-chat-composer button, .lingtu-chat-composer-head button {
    border: 1px solid var(--line); border-radius: 7px; background: var(--control-fill);
    color: var(--ink); font: inherit; font-weight: var(--ui-label-weight); padding: 4px 10px; cursor: pointer;
}
.lingtu-chat-composer button:disabled { opacity: .6; cursor: wait; }
.lingtu-chat-context, .lingtu-chat-status { font-size: var(--ui-surface-caption-font); }
.lingtu-chat-context { overflow-wrap: anywhere; }
.lingtu-chat-status[hidden] { display: none !important; }
.lingtu-chat-composer-head > .lingtu-chat-status { flex: 1; margin-left: auto; }
.lingtu-chat-context { color: var(--muted); max-height: 3em; overflow: auto; }
.lingtu-chat-status:empty { display: none; }
.lingtu-chat-status.is-error { color: var(--danger); }
.lingtu-chat-params { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: var(--ui-field-gap, 6px); }
.lingtu-chat-params[hidden] { display: none; }
.lingtu-chat-params label {
    position: relative; display: grid; grid-template-columns: minmax(0, 1fr) var(--v21-card-value-w, 32px);
    grid-template-rows: var(--ui-caption-band-h, 18px) var(--ui-regular-action-h, 28px); gap: 0;
    min-width: 0; border: 1px solid var(--line); border-radius: calc(var(--ui-density, 1) * 8px);
    background: var(--control-muted); font-size: var(--ui-surface-label-font);
}
.lingtu-chat-param-caption {
    grid-column: 1 / -1; padding-inline: var(--ui-caption-text-pad, 4px); align-self: center;
    color: var(--muted); font-size: var(--ui-surface-caption-font); line-height: 1.15;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lingtu-chat-params select, .lingtu-chat-params input {
    grid-row: 2; grid-column: 1 / -1; width: 100%; min-width: 0; margin: 0;
    height: var(--ui-regular-action-h, 28px); min-height: 0; box-sizing: border-box; font: inherit;
    font-size: var(--ui-surface-body-font); font-weight: var(--ui-body-weight);
}
.lingtu-chat-params input[type="range"] { padding-right: calc(var(--v21-card-value-w, 32px) + 8px); }
.lingtu-chat-params output {
    grid-row: 2; grid-column: 2; z-index: 1; display: grid; place-items: center; pointer-events: none;
    border: 1px solid var(--line); border-radius: calc(var(--ui-density, 1) * 8px);
    background: var(--control-fill); font-size: var(--ui-surface-body-font); font-weight: var(--ui-label-weight);
}
.lingtu-chat-params output[hidden] { display: none; }
.lingtu-chat-input { position: relative; min-height: 56px; }
.lingtu-chat-input textarea {
    box-sizing: border-box; width: 100%; height: 100%; min-height: 56px; resize: none;
    padding: 8px 10px 38px; color: var(--ink); background: var(--control-fill); border: 1px solid var(--line);
    border-radius: 8px; font: inherit; display: block;
}
.lingtu-chat-input [data-chat-send] { position: absolute; right: 0; bottom: 0; }
.lingtu-chat-floating {
    position: fixed; z-index: 160; display: grid; grid-template-rows: minmax(90px, 1fr) minmax(min-content, 1fr);
    width: min(560px, 100vw); height: min(620px, 85vh); min-width: min(330px, 100vw); min-height: min-content;
    max-width: 100vw; max-height: 100vh; resize: both; overflow: hidden;
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel, #141916);
    box-shadow: 0 12px 42px #0005; box-sizing: border-box; transition: none;
}
.lingtu-chat-floating > .lingtu-chat-log {
    position: relative; inset: auto; width: 100%; height: 100%; max-height: none; border-radius: 0;
}
.lingtu-chat-floating > .lingtu-chat-composer {
    padding: 0; gap: 0; box-sizing: border-box; height: auto; min-height: min-content; overflow: visible;
}
.lingtu-chat-floating .lingtu-chat-composer-head { padding: 5px 8px; }
.lingtu-chat-floating .lingtu-chat-context {
    border-top: 1px solid var(--line); padding: 3px 18px 3px 8px;
    font-size: var(--ui-surface-caption-font); line-height: 1.3;
    max-height: none; overflow: visible;
}
.lingtu-chat-log-head > span { margin-right: auto; }
.lingtu-chat-log-head.is-draggable { cursor: move; touch-action: none; user-select: none; }
.lingtu-dock-target { outline: 2px dashed var(--accent, #82bbb3); outline-offset: -4px; }
.lingtu-chat-floating:has(.lingtu-chat-log.is-collapsed) { grid-template-rows: auto minmax(min-content, 1fr); }
.lingtu-chat-floating > .lingtu-chat-log.is-collapsed { height: 38px; }
:root .work-panel > .step[data-layout-section="upload"].has-docked-lingtu {
    display: grid !important; grid-template-rows: var(--ui-step-head-h) minmax(0, 1fr) minmax(0, 1fr) !important;
    row-gap: var(--step-gap); min-height: 0;
}
:root .work-panel > .step[data-layout-section="upload"].has-docked-lingtu.lingtu-log-collapsed {
    grid-template-rows: var(--ui-step-head-h) minmax(0, 1fr) 38px !important;
}
:root .work-panel > .step[data-layout-section="upload"].has-docked-lingtu > #dropzone {
    grid-row: 2; margin-bottom: 0 !important; overflow: hidden;
}
:root .work-panel > .step[data-layout-section="upload"].has-docked-lingtu > #lingtuChatLog {
    position: relative; inset: auto; grid-row: 3; min-height: 0; max-height: none;
    margin-inline: calc(0px - var(--panel-inner-frame-bleed)); margin-bottom: calc(0px - var(--panel-inner-frame-bleed));
}
:root .work-panel > .step[data-layout-section="mode"].has-lingtu-composer { grid-template-rows: auto minmax(0, 1fr) !important; }
