/* Photo-chat tools: composer chips, edit window panel, tool landing. */

.chat-action-bar { display: flex; flex-direction: column; gap: 8px; padding-bottom: 10px; }
.chat-action-bar[hidden] { display: none; }
/* All chips are visible at once: no sideways scrolling without a touchpad. */
.chat-action-chips, .chat-action-options { display: flex; flex-wrap: wrap; gap: 6px; }

.chat-action-chip, .chat-action-option {
  display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto;
  min-height: 32px; padding: 0 12px;
  border: 1px solid var(--border-color); border-radius: var(--radius-pill);
  background: var(--bg-card); color: var(--text-primary);
  font: 500 .8rem/1 var(--font-family); white-space: nowrap; cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.chat-action-chip svg { color: var(--primary); flex: none; }
.chat-action-chip:hover, .chat-action-option:hover { border-color: var(--primary); }
.chat-action-chip.is-selected, .chat-action-option.is-selected { background: var(--primary-glow); border-color: var(--primary); color: var(--primary); }
.chat-action-chip:focus-visible, .chat-action-option:focus-visible, .chat-editor-tool:focus-visible, .chat-tool-upload:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.chat-action-details { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chat-action-option { min-height: 28px; padding: 0 11px; font-size: .76rem; }
/* Send button with the price of the chosen tool: arrow + «15 ✦». */

/* Edit window (shared ImageViewer) */
.chat-editor-panel { display: flex; flex-direction: column; gap: 16px; padding: 4px 2px 8px; }
.chat-editor-tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.chat-editor-tool {
  display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 10px;
  border: 1px solid var(--border-color); border-radius: 12px;
  background: var(--bg-card); color: var(--text-primary);
  font: 500 .8rem/1.2 var(--font-family); text-align: left; cursor: pointer;
}
.chat-editor-tool svg { color: var(--primary); flex: none; }
.chat-editor-tool span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-editor-tool.is-active { border-color: var(--primary); background: var(--primary-glow); color: var(--primary); }
.chat-editor-form .chat-action-options { flex-wrap: wrap; overflow: visible; }
.chat-editor-brush {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 14px;
  border: 1px dashed var(--primary); border-radius: var(--radius-pill);
  background: transparent; color: var(--primary); font: 600 .84rem/1.2 var(--font-family); cursor: pointer;
}
.chat-editor-brush.is-active { border-style: solid; background: var(--primary-glow); }
.chat-editor-link { align-self: flex-start; padding: 0; border: 0; background: none; color: var(--text-secondary); font: 500 .78rem/1.2 var(--font-family); text-decoration: underline; cursor: pointer; }
.image-viewer-overlay.chat-brush-canvas { height: auto; padding: 0; border-radius: 0; background: transparent; display: block; cursor: crosshair; touch-action: none; z-index: 3; }
.image-viewer-overlay.chat-brush-canvas::after { content: none; }
.chat-image-editor .image-viewer-stage { background-color: #080808; }

/* Transparent results: checkerboard behind the picture */
.generated-image-output.has-alpha,
.chat-image-editor .image-viewer-image-button img,
.chat-image-editor .image-viewer-thumb img {
  background-color: #fff;
  background-image: linear-gradient(45deg, #e6e6e6 25%, transparent 25%), linear-gradient(-45deg, #e6e6e6 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e6e6e6 75%), linear-gradient(-45deg, transparent 75%, #e6e6e6 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.chat-image-editor .image-viewer-image-button img { background-image: none; background-color: transparent; }
.chat-image-editor .image-viewer-stage.is-transparent .image-viewer-image-button img {
  background-color: #fff;
  background-image: linear-gradient(45deg, #e6e6e6 25%, transparent 25%), linear-gradient(-45deg, #e6e6e6 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e6e6e6 75%), linear-gradient(-45deg, transparent 75%, #e6e6e6 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  object-fit: contain;
}

/* Tool landing (/remove-background, ...) */
.chat-tool-landing { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; max-width: 560px; margin: 8px auto 4px; }
.chat-tool-upload {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 18px 20px;
  border: 1.5px dashed var(--primary); border-radius: var(--radius-lg);
  background: var(--primary-glow); color: var(--text-primary); text-align: left; cursor: pointer;
  transition: transform var(--transition-fast), background var(--transition-fast);
}
.chat-tool-upload:hover { transform: translateY(-1px); }
.chat-tool-upload-icon { display: grid; place-items: center; width: 52px; height: 52px; flex: none; border-radius: 16px; background: var(--bg-panel); color: var(--primary); }
.chat-tool-upload-copy { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.chat-tool-upload-copy strong { font-size: 1rem; }
.chat-tool-upload-copy small { color: var(--text-secondary); font-size: .8rem; }
.chat-tool-hint { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--text-secondary); font-size: .8rem; }
.chat-tool-others { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 12px; color: var(--text-secondary); font-size: .8rem; }
.chat-tool-others a { color: var(--primary); text-decoration: none; }
.chat-tool-others a:hover { text-decoration: underline; }

/* "Editing this picture" badge on an auto-attached result */
.attachment-edit-badge { position: absolute; left: 0; right: 0; bottom: 0; padding: 2px 0; background: rgba(0,0,0,.55); color: #fff; font: 600 .6rem/1.2 var(--font-family); text-align: center; }

@media (max-width: 768px) {
  .chat-tool-upload { padding: 14px 16px; }
  .chat-tool-upload-icon { width: 44px; height: 44px; }
}

/* Brush bar over the picture (phones: the sheet is closed while drawing) */
.image-viewer-overlay.chat-brush-bar { top: 10px; left: 50%; transform: translateX(-50%); z-index: 4; height: auto; gap: 8px; padding: 6px 6px 6px 14px; border-radius: var(--radius-pill); cursor: default; white-space: nowrap; }
.image-viewer-overlay.chat-brush-bar::after { content: none; }
.chat-brush-bar button { min-height: 32px; padding: 0 12px; border: 0; border-radius: var(--radius-pill); background: rgba(255,255,255,.14); color: #fff; font: 600 .78rem/1 var(--font-family); cursor: pointer; }
.chat-brush-bar button[data-brush-bar="done"] { background: var(--primary); }
.image-viewer-modal.is-docked .chat-brush-bar { display: none; }

/* Brush size: slider with a live dot and number */
.chat-brush-hint { margin: 0; color: var(--text-secondary); font: 400 .8rem/1.35 var(--font-family); }
.chat-brush-size { display: flex; align-items: center; gap: 10px; }
.chat-brush-size input[type="range"] { flex: 1; min-width: 0; accent-color: var(--primary); cursor: pointer; }
.chat-brush-size-label { color: var(--text-secondary); font-size: .8rem; }
.chat-brush-size-dot { display: grid; place-items: center; width: 30px; height: 30px; flex: none; }
.chat-brush-size-dot i { display: block; border-radius: 50%; background: rgba(255, 0, 80, .55); }
.chat-brush-size output { min-width: 20px; color: var(--text-primary); font: 600 .82rem/1 var(--font-family); text-align: right; }
.chat-brush-size-bar { gap: 6px; }
.chat-brush-size-bar .chat-brush-size-label, .chat-brush-size-bar .chat-brush-size-dot { display: none; }
.chat-brush-size-bar input[type="range"] { width: 92px; flex: none; }
.chat-brush-size-bar output { color: #fff; }
.image-viewer-overlay.chat-brush-bar { padding-left: 12px; }
.chat-brush-cursor { position: absolute; z-index: 3; border: 1.5px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,.45); pointer-events: none; }
.chat-brush-cursor[hidden] { display: none; }
.image-viewer-overlay.chat-brush-canvas:hover { cursor: none; }

/* Where the edit applies: whole photo or a brushed area */
.chat-area-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; border: 1px solid var(--border-color); border-radius: var(--radius-pill); background: var(--bg-card); }
.chat-area-option { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 8px; white-space: nowrap; border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--text-secondary); font: 600 .8rem/1.2 var(--font-family); cursor: pointer; transition: background var(--transition-fast), color var(--transition-fast); }
.chat-area-option.is-active { background: var(--bg-panel); color: var(--primary); box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.chat-area-option:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.chat-brush-block { display: flex; flex-direction: column; gap: 8px; }

/* «Текст и инфографика»: card copy fields and the free helper. */
.chat-card-text { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.chat-card-fields { display: flex; flex-direction: column; gap: 6px; }
.chat-card-fields .studio-input { width: 100%; min-height: 38px; font-size: .85rem; }
.chat-card-label { margin: 4px 0 0; color: var(--text-secondary); font-size: .78rem; }
.chat-card-suggest {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 38px;
  border: 1px dashed var(--primary); border-radius: 12px; background: var(--primary-glow); color: var(--primary);
  font: 600 .82rem/1 var(--font-family); cursor: pointer;
}
.chat-card-suggest small { color: var(--text-secondary); font-weight: 500; }
.chat-card-suggest:disabled { opacity: .6; cursor: progress; }
.chat-card-suggest:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Card settings appear below the shared tools; pills open settings dialogs. */
.chat-editor-apply>button { width:100%; }
.chat-editor-apply>small { display:block; color:var(--text-secondary); font-size:10px; text-align:center; margin:6px 0 0; }
.chat-image-editor.is-card-design .chat-editor-form { display:flex; flex-direction:column; gap:0; }
.chat-card-settings { display:flex; flex-direction:column; gap:12px; margin-bottom:14px; }
.chat-card-wishes { display:flex; flex-direction:column; gap:6px; }
.chat-card-wishes .studio-textarea { width:100%; min-height:76px; resize:vertical; }
.chat-card-pills { display:flex; flex-wrap:wrap; gap:8px; }
.chat-card-pill { max-width:100%; }
.chat-card-pill svg { width:16px; height:16px; flex:none; }
.chat-card-pill span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:200px; }
.chat-card-pill[aria-expanded="true"] { border-color:var(--primary); color:var(--primary); background:var(--primary-glow); }
.chat-card-settings button:focus-visible, .chat-card-sheet button:focus-visible { outline:2px solid var(--primary); outline-offset:2px; }
.chat-card-hint { margin:0 0 12px; color:var(--text-secondary); font:400 12px/1.5 var(--font-family); }
.chat-card-settings .chat-card-hint { margin:0; }

/* Settings dialog: Studio's sheet look; on top of the edit window. */
.chat-card-sheet { z-index:1200; }
.chat-card-sheet>footer { display:flex; justify-content:flex-end; }
.chat-card-sheet>footer button { width:auto; min-width:120px; }
.chat-card-sheet svg { width:18px; height:18px; }
.chat-card-field { display:flex; flex-direction:column; gap:6px; width:100%; min-width:0; margin-bottom:10px; }
.chat-card-field>span { font-size:12px; font-weight:600; }
.chat-card-field small, .chat-card-label small { color:var(--text-secondary); font-weight:400; font-size:11px; }
.chat-card-field input,.chat-card-field select,.chat-card-field textarea { width:100%; min-width:0; }
.chat-card-field .studio-input { min-height:42px; padding:10px 12px; }
.chat-card-text { margin:0; gap:2px; }
.chat-card-sheet .studio-v2-setting-fields { display:flex; flex-direction:column; gap:10px; padding:0 0 14px; }
.chat-card-sheet .studio-v2-setting-fields .studio-textarea { width:100%; resize:vertical; }
.chat-card-text .chat-card-field { margin:0; }
.chat-card-text .chat-card-suggest { min-height:42px; border-style:solid; }
.chat-card-text .chat-action-options { flex-wrap:wrap; overflow:visible; }
.chat-card-label { font-weight:600; color:var(--text-primary); font-size:12px; }
.chat-card-benefit { display:flex; gap:8px; align-items:center; }
.chat-card-benefit>span { display:grid; place-items:center; width:22px; height:22px; flex:none; border-radius:7px; background:var(--primary-glow); color:var(--primary); font-size:11px; font-weight:700; }
.chat-card-benefit input { min-width:0; flex:1; padding:10px; }
.chat-card-visual-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:9px; margin:12px 0 4px; }
.chat-card-visual { position:relative; display:flex; flex-direction:column; padding:4px; min-width:0; border:1.5px solid var(--border-color); border-radius:12px; background:var(--bg-card); color:var(--text-primary); text-align:left; cursor:pointer; }
.chat-card-visual-image { display:grid; place-items:center; width:100%; aspect-ratio:4/3; border-radius:9px; overflow:hidden; background:var(--primary-glow); color:var(--primary); }
.chat-card-visual-image img { width:100%; height:100%; object-fit:cover; }
.chat-card-visual-image>svg { width:30px; height:30px; }
.chat-card-visual strong { padding:8px 5px 5px; font-size:12px; line-height:1.35; font-weight:600; }
.chat-card-visual[aria-pressed="true"] { border-color:var(--primary); background:var(--primary-glow); }
.chat-card-visual[aria-pressed="true"]::after { content:'✓'; position:absolute; top:9px; right:9px; display:grid; place-items:center; width:21px; height:21px; border-radius:50%; background:var(--primary); color:#fff; font-size:12px; }
.chat-card-design-choices { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; margin:0 0 12px; }
.chat-card-design-choices>button { display:flex; align-items:center; flex-direction:column; gap:6px; padding:12px 6px; border:1px solid var(--border-color); border-radius:12px; background:var(--bg-card); color:var(--text-primary); cursor:pointer; }
.chat-card-design-choices svg { width:22px; height:22px; color:var(--primary); }
.chat-card-design-choices strong { font-size:12px; }
.chat-card-design-choices small { font-size:10px; color:var(--text-secondary); }
.chat-card-design-choices [aria-pressed="true"] { border-color:var(--primary); background:var(--primary-glow); }
.chat-card-reference { display:grid; grid-template-columns:48px minmax(0,1fr) 36px; align-items:center; gap:10px; margin:0 0 12px; padding:10px; border:1px solid var(--border-color); border-radius:12px; }
.chat-card-reference>img { width:48px; height:64px; object-fit:cover; border-radius:7px; }
.chat-card-reference>div { display:flex; flex-direction:column; gap:5px; min-width:0; }
.chat-card-reference strong { font-size:12px; }
.chat-card-reference small { font-size:10px; color:var(--text-secondary); }
.chat-card-reference .image-viewer-icon { width:36px; height:36px; }
.chat-card-reference-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; }
.chat-card-reference-grid .chat-card-visual-image { aspect-ratio:3/4; }
.chat-card-reference-grid .chat-card-visual { animation:chat-reference-appear .22s ease-out; }
.chat-card-library-more { display:block; width:100%; min-height:42px; margin-top:12px; border:1px solid var(--border-color); border-radius:12px; background:var(--bg-card); color:var(--text-secondary); font:500 .8rem/1.3 var(--font-family); cursor:pointer; }
@keyframes chat-reference-appear { from { opacity:0; transform:translateY(5px); } to { opacity:1; transform:translateY(0); } }
@media (prefers-reduced-motion:reduce) { .chat-card-reference-grid .chat-card-visual { animation:none; } }
.chat-card-formats { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.chat-card-format { display:flex; flex-direction:column; gap:4px; padding:12px; border:1px solid var(--border-color); border-radius:12px; background:var(--bg-card); color:var(--text-primary); text-align:left; cursor:pointer; }
.chat-card-format strong { font-size:14px; }
.chat-card-format small { font-size:11px; color:var(--text-secondary); }
.chat-card-format[aria-pressed="true"] { border-color:var(--primary); background:var(--primary-glow); color:var(--primary); }
@media (max-width:640px) {
  .chat-card-visual-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .chat-card-reference-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .chat-card-design-choices>button { padding:10px 4px; }
  .chat-card-sheet input, .chat-card-sheet select, .chat-card-sheet textarea, .chat-card-wishes textarea { font-size:16px!important; }
  .chat-card-pill span { max-width:150px; }
}

/* «Инструменты» next to «Формат»: a menu of tools and the chosen one as a chip with ×. */
.chat-tools { display: inline-flex; align-items: center; gap: 8px; }
.chat-tools[hidden], .chat-tool-chip-slot:empty { display: none; }
.chat-tools-trigger svg, .chat-tool-chip svg { flex: none; }
.chat-tools-popup { width: 270px; gap: 2px; padding: 8px; }
.chat-tools-popup .format-popup-title { margin: 4px 6px 6px; }
.chat-tool-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 0 10px; border: 0; border-radius: 10px; background: transparent; color: var(--text-primary); font: inherit; font-size: .86rem; text-align: left; cursor: pointer; }
.chat-tool-item svg { color: var(--primary); flex: none; }
.chat-tool-item small { margin-left: auto; color: var(--text-secondary); font-size: .76rem; }
.chat-tool-item:hover { background: var(--bg-hover, rgba(127, 127, 127, .1)); }
.chat-tool-item.is-selected { background: var(--primary-glow); color: var(--primary); }
.chat-tool-item:focus-visible, .chat-tool-chip-clear:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.chat-tool-chip { background: var(--primary-glow); border-color: var(--primary); color: var(--primary); padding-right: 5px; cursor: default; }
.chat-tool-chip-clear { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin-left: 2px; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
.chat-tool-chip-clear:hover { background: rgba(127, 127, 127, .18); }
@media (max-width: 600px) {
  .chat-tools-popup { width: 100%; }
  .chat-tools-trigger span { display: none; }
  .chat-tools-trigger { width: 34px; padding: 0; }
}

/* Marketplace card typed in the image generator: offer the card generator. */
.chat-card-hint { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: 0 2px 10px; font-size: .82rem; color: var(--text-secondary); }
.chat-card-hint[hidden] { display: none; }
.chat-card-hint button { border: 0; background: none; padding: 0; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; }
.chat-card-hint button:hover { text-decoration: underline; }
/* A quiet suggestion inside the composer, shared with Studio. */
.text-chat-handoff { position: relative; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; min-width: 0; margin: 0 0 10px; padding: 10px 42px 10px 12px; border: 1px solid color-mix(in srgb, var(--primary) 18%, transparent); border-radius: 10px; background: color-mix(in srgb, var(--primary) 6%, var(--bg-input)); color: var(--text-primary); text-align: left; }
.text-chat-handoff[hidden], .text-chat-handoff-photo[hidden] { display: none; }
.text-chat-handoff-intro { flex: 1 0 auto; font-size: 13px; font-weight: 600; line-height: 1.4; }
.text-chat-handoff-close { position: absolute; top: 7px; right: 7px; display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--text-secondary); cursor: pointer; }
.text-chat-handoff-close:hover { background: var(--primary-glow); color: var(--text-primary); }
.text-chat-handoff-close:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.text-chat-handoff-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 8px 12px; }
.text-chat-handoff-photo { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 32px; font-size: 12px; color: var(--text-secondary); cursor: pointer; }
.text-chat-handoff-photo input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.text-chat-handoff-toggle { position: relative; flex: none; width: 30px; height: 18px; border-radius: 99px; background: var(--text-muted); transition: background .15s; }
.text-chat-handoff-toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: transform .15s; }
.text-chat-handoff-photo input:checked + .text-chat-handoff-toggle { background: var(--primary); }
.text-chat-handoff-photo input:checked + .text-chat-handoff-toggle::after { transform: translateX(12px); }
.text-chat-handoff-photo input:focus-visible + .text-chat-handoff-toggle { outline: 2px solid var(--primary); outline-offset: 3px; }
.text-chat-handoff-open { margin-left: auto; min-height: 32px; padding: 6px 10px; border: 0; border-radius: 8px; background: var(--primary); color: #fff; font: 600 12px/1.4 var(--font-family); cursor: pointer; transition: background .15s; }
.text-chat-handoff-open:hover { background: var(--primary-hover); }
.text-chat-handoff-open:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
@media (max-width: 600px) {
  .text-chat-handoff { padding: 10px 12px; }
  .text-chat-handoff-intro { flex-basis: 100%; padding-right: 26px; box-sizing: border-box; }
  .text-chat-handoff-actions { width: 100%; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .text-chat-handoff-toggle, .text-chat-handoff-toggle::after, .text-chat-handoff-open { transition: none; }
}
