.agent-page {
  max-width: none;
}

.agent-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.agent-heading h1,
.agent-workspace h2,
.agent-heading p {
  letter-spacing: 0;
}

.agent-heading>div>p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.agent-service-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #176b62;
  font-size: 11px;
  font-weight: 750;
}

.agent-service-state svg {
  width: 16px;
}

.agent-heading-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.agent-save-warning {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #9a4b21;
  font-size: 11px;
  font-weight: 750;
}

.agent-save-warning svg { width: 16px; }

.agent-history-button {
  min-height: 36px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #aac9ce;
  border-radius: 5px;
  color: #174f61;
  background: #fff;
  font-size: 11px;
  font-weight: 760;
}

.agent-history-button:hover { border-color: #078b95; color: #06727c; }
.agent-history-button:disabled { cursor: not-allowed; opacity: .55; }
.agent-history-button svg { width: 15px; }

.agent-history-dialog {
  width: min(760px, calc(100% - 28px));
  max-height: min(720px, calc(100vh - 32px));
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background: #f8fbfb;
  box-shadow: 0 24px 80px rgba(2, 29, 43, .34);
}

.agent-history-dialog::backdrop { background: rgba(2, 22, 32, .62); }
.agent-history-shell { max-height: inherit; display: grid; grid-template-rows: auto auto minmax(160px, 1fr) auto; }
.agent-history-shell>header,.agent-history-shell>footer { padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fff; }
.agent-history-shell>header { border-bottom: 1px solid #dbe7e8; }
.agent-history-shell h2 { margin: 2px 0 0; color: #123d50; font-size: 21px; letter-spacing: 0; }
.agent-history-shell>header button { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 5px; color: #526b73; background: #edf4f4; }
.agent-history-shell>header svg { width: 17px; }
.agent-history-notice { margin: 12px 20px 0; padding: 10px 12px; display: flex; align-items: flex-start; gap: 8px; border: 1px solid #ecd3b5; border-radius: 6px; color: #82461f; background: #fff9f0; font-size: 11px; line-height: 1.55; }
.agent-history-notice svg { width: 15px; flex: 0 0 auto; }
.agent-history-list { min-height: 0; padding: 12px 20px; overflow: auto; }
.agent-history-item { min-width: 0; padding: 13px 0; display: grid; grid-template-columns: 34px minmax(0,1fr) 30px; gap: 10px; border-bottom: 1px solid #e1e9e9; }
.agent-history-type { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 6px; color: #fff; background: #087f8b; }
.agent-history-type.image { background: #c14f67; }
.agent-history-type.video { background: #7850a3; }
.agent-history-type svg { width: 16px; }
.agent-history-main { min-width: 0; }
.agent-history-main>div { display: flex; align-items: center; gap: 8px; }
.agent-history-main strong { color: #173e4e; font-size: 12px; }
.agent-history-main p { margin: 5px 0; overflow: hidden; color: #4f636b; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.agent-history-main small { color: #849196; font-size: 10px; }
.agent-history-main em { margin-top: 5px; display: block; color: #a23b3b; font-size: 10px; font-style: normal; overflow-wrap: anywhere; }
.agent-history-status { padding: 2px 6px; border-radius: 4px; color: #816416; background: #fff4c7; font-size: 9px; font-weight: 780; }
.agent-history-status.completed { color: #176b50; background: #e3f5ed; }
.agent-history-status.failed { color: #a23b3b; background: #fdeaea; }
.agent-history-actions { display:grid; align-content:start; gap:5px; }
.agent-history-actions>a,.agent-history-actions>button { width:30px; height:30px; padding:0; display:grid; place-items:center; border:0; border-radius:5px; color:#147185; background:#e5f2f4; }
.agent-history-actions>button { color:#a33d3d; background:#fbeaea; }
.agent-history-actions svg { width:14px; }
.agent-history-empty { margin: 28px 0; color: #77878c; text-align: center; font-size: 12px; }
.agent-history-empty.error { color: #a23b3b; }
.agent-history-shell>footer { border-top: 1px solid #dbe7e8; color: #75868c; font-size: 10px; }
.agent-history-shell>footer button { min-height: 32px; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid #bfd3d6; border-radius: 5px; color: #245968; background: #fff; font-size: 10px; font-weight: 750; }
.agent-history-shell>footer svg { width: 13px; }

.agent-mode-tabs {
  margin: 22px 0 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.agent-mode-tabs button {
  min-height: 50px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #c7d9dc;
  border-radius: 6px;
  color: #536970;
  background: rgba(255, 255, 255, .76);
  font-weight: 760;
}

.agent-mode-tabs button:hover,
.agent-mode-tabs button.active {
  border-color: #087f8b;
  color: #fff;
  background: linear-gradient(118deg, #0756a0, #008f9a);
  box-shadow: 0 10px 24px rgba(3, 70, 110, .2);
}

.agent-mode-tabs svg {
  width: 18px;
}

.agent-workspace {
  position: relative;
  min-width: 0;
  padding: 22px;
  border: 1px solid #bed5d9;
  border-radius: 7px;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 18px 44px rgba(4, 55, 91, .1);
  animation: agent-panel-in 220ms ease both;
}

.agent-workspace-head,
.agent-workspace-head>div,
.agent-command-bar,
.agent-progress-panel>div {
  display: flex;
  align-items: center;
}

.agent-workspace-head {
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid #dce7e8;
}

.agent-workspace-head>div {
  min-width: 0;
  gap: 12px;
}

.agent-workspace-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: #fff;
  background: linear-gradient(135deg, #0756a0, #08a8ae);
}

.agent-workspace-icon.image {
  background: linear-gradient(135deg, #b33f5d, #ee7152);
}

.agent-workspace-icon.video {
  background: linear-gradient(135deg, #7043a4, #d15381);
}

.agent-workspace-icon svg {
  width: 20px;
}

.agent-workspace h2 {
  margin: 0;
  color: #11394f;
  font-size: 19px;
}

.agent-workspace-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.agent-workspace-head label {
  min-width: min(310px, 40%);
  color: #60747a;
  font-size: 10px;
  font-weight: 750;
}

.agent-workspace select,
.agent-field textarea {
  width: 100%;
  border: 1px solid #c5d6d9;
  border-radius: 6px;
  color: #153247;
  background: #fff;
  outline: 0;
}

.agent-input-shell { min-width: 0; position: relative; display: grid; }
.agent-input-shell textarea { width: 100%; }
.agent-input-login {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 5px;
  border: 1px solid #b8d1d5;
  border-radius: 6px;
  color: #174f61;
  background: rgba(244, 250, 251, .92);
  text-decoration: none;
  backdrop-filter: blur(2px);
}
.agent-input-login:hover { border-color: #078b95; color: #06727c; background: rgba(237, 249, 249, .96); }
.agent-input-login>svg { width: 24px; height: 24px; padding: 5px; border-radius: 5px; color: #fff; background: var(--brand-action); }
.agent-input-login strong { font-size: 12px; }
.agent-input-login span { color: #708187; font-size: 9px; font-weight: 550; }
.agent-input-login[hidden] { display: none; }

.agent-workspace select {
  height: 38px;
  margin-top: 5px;
  padding: 0 10px;
  font-size: 12px;
}

.agent-workspace select:focus,
.agent-field textarea:focus {
  border-color: #078b95;
  box-shadow: 0 0 0 3px rgba(8, 168, 174, .12);
}

.agent-text-columns,
.agent-image-layout,
.agent-video-layout {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.agent-text-options {
  margin-top: 18px;
  display: flex;
  align-items: flex-end;
  gap: 14px;
}

.agent-composer-dock {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #bed5d9;
}

.agent-chat-context {
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid #c5d9dc;
  border-radius: 7px;
  background: #f8fbfb;
}

.agent-chat-context>header {
  min-height: 52px;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #d8e5e7;
  background: #fff;
}

.agent-chat-context>header>div {
  display: grid;
  gap: 2px;
}

.agent-chat-context>header span {
  color: #526c73;
  font-size: 11px;
  font-weight: 760;
}

.agent-chat-context>header strong {
  color: var(--muted);
  font-size: 10px;
}

.agent-chat-context>header button {
  min-height: 32px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #d4dfe1;
  border-radius: 5px;
  color: #60757b;
  background: #fff;
  font-size: 10px;
  font-weight: 750;
}

.agent-chat-context>header button:disabled {
  opacity: .45;
  cursor: default;
}

.agent-chat-context>header svg {
  width: 14px;
}

.agent-chat-history {
  height: auto;
  min-height: 220px;
  max-height: min(46vh, 420px);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overscroll-behavior: contain;
}

.agent-chat-empty {
  min-height: 188px;
  margin: auto;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  color: #73878c;
  text-align: center;
}

.agent-chat-empty svg {
  width: 30px;
  color: #188b95;
}

.agent-chat-empty strong {
  color: #385b64;
  font-size: 13px;
}

.agent-chat-empty span {
  font-size: 10px;
}

.agent-chat-message {
  width: min(82%, 760px);
  display: grid;
  gap: 5px;
}

.agent-chat-message.user {
  align-self: flex-end;
}

.agent-chat-message.assistant {
  align-self: flex-start;
}

.agent-chat-message>span {
  color: #71858a;
  font-size: 9px;
  font-weight: 800;
}

.agent-chat-message.user>span {
  text-align: right;
}

.agent-chat-message p {
  margin: 0;
  padding: 11px 13px;
  border: 1px solid #cadcdf;
  border-radius: 7px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #25434c;
  background: #fff;
  font-size: 12px;
  line-height: 1.65;
}

.agent-chat-message.user p {
  border-color: #0a7c89;
  color: #fff;
  background: linear-gradient(118deg, #0756a0, #008f9a);
}

.agent-chat-attachment {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 9px;
}

.agent-chat-attachment svg {
  width: 12px;
}

.agent-switch {
  min-height: 38px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #c5d6d9;
  border-radius: 6px;
  color: #536b72;
  background: #f6fbfb;
  font-size: 11px;
  font-weight: 750;
}

.agent-switch input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #078b95;
}

.agent-image-url {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 5px;
  color: #60747a;
  font-size: 10px;
  font-weight: 750;
}

.agent-image-url input {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid #c5d6d9;
  border-radius: 6px;
  color: #153247;
  background: #fff;
}

.agent-local-image-button {
  min-height: 38px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid #c5d6d9;
  border-radius: 6px;
  color: #456f78;
  background: #f6fbfb;
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
}

.agent-local-image-button:hover {
  border-color: #078b95;
  background: #eefafa;
}

.agent-local-image-button svg {
  width: 16px;
}

.agent-local-image-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.agent-local-image-preview {
  min-height: 58px;
  margin-top: 10px;
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #c5d9dc;
  border-radius: 6px;
  background: #f8fbfb;
}

.agent-local-image-preview img {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  object-fit: cover;
  border-radius: 4px;
}

.agent-local-image-preview>span {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 3px;
}

.agent-local-image-preview strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #365861;
  font-size: 11px;
}

.agent-local-image-preview small {
  color: var(--muted);
  font-size: 9px;
}

.agent-local-image-preview button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  color: #6c7d82;
  background: transparent;
}

.agent-local-image-preview button svg {
  width: 15px;
}

.agent-text-composer {
  margin-top: 12px;
}

.agent-text-composer textarea {
  min-height: 108px;
}

.agent-field {
  min-width: 0;
  display: grid;
  gap: 7px;
  color: #536b72;
  font-size: 11px;
  font-weight: 750;
}

.agent-field textarea {
  min-height: 190px;
  padding: 13px;
  resize: vertical;
  font: inherit;
  font-weight: 450;
  line-height: 1.65;
}

.agent-field.agent-text-composer textarea {
  min-height: 92px;
  max-height: 180px;
}

.agent-image-layout .agent-field textarea {
  min-height: 270px;
}

.agent-image-inputs {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.agent-media-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.agent-media-options label {
  min-width: 0;
  display: grid;
  gap: 4px;
  color: #60747a;
  font-size: 10px;
  font-weight: 750;
}

.agent-media-options select {
  margin-top: 0;
}

.agent-duration-control {
  min-height: 36px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  align-items: center;
  gap: 10px;
  padding: 4px 9px 4px 8px;
  border: 1px solid #c8d8dc;
  border-radius: 6px;
  background: #fff;
}

.agent-duration-track {
  --duration-thumb: 16px;
  position: relative;
  width: 100%;
  min-width: 0;
  height: 20px;
}

.agent-duration-track::before,
.agent-duration-fill {
  position: absolute;
  top: 50%;
  left: 0;
  height: 5px;
  border-radius: 999px;
  transform: translateY(-50%);
  content: "";
}

.agent-duration-track::before {
  right: 0;
  background: #d7e3e5;
}

.agent-duration-fill {
  width: var(--duration-progress, 0%);
  background: #087f8c;
  pointer-events: none;
}

.agent-duration-track input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  top: 0;
  left: calc(var(--duration-thumb) / -2);
  width: calc(100% + var(--duration-thumb));
  height: 20px;
  margin: 0;
  background: transparent;
  cursor: grab;
}

.agent-duration-track input[type="range"]:active {
  cursor: grabbing;
}

.agent-duration-track input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  background: transparent;
}

.agent-duration-track input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: var(--duration-thumb);
  height: var(--duration-thumb);
  margin-top: -5.5px;
  border: 2px solid #087f8c;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(18, 57, 64, .28);
}

.agent-duration-track input[type="range"]::-moz-range-track {
  height: 5px;
  background: transparent;
}

.agent-duration-track input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 2px solid #087f8c;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(18, 57, 64, .28);
}

.agent-duration-track input[type="range"]:focus-visible {
  outline: 2px solid rgba(8, 127, 140, .35);
  outline-offset: 2px;
}

.agent-duration-track input[type="range"]:disabled {
  cursor: not-allowed;
  opacity: .62;
}

.agent-duration-control output {
  color: #17363d;
  font-size: 10px;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.agent-reference-button {
  width: 100%;
}

.agent-output-frame {
  min-height: 270px;
  padding: 24px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 9px;
  border: 1px dashed #a9c6cb;
  border-radius: 7px;
  color: #648087;
  background: linear-gradient(135deg, #f6fbfc, #f9f7fb);
  text-align: center;
}

.agent-output-frame svg {
  width: 35px;
  height: 35px;
  color: #178793;
}

.agent-output-frame span {
  font-size: 11px;
}

.agent-output-frame.has-media {
  position: relative;
  padding: 10px;
  border-style: solid;
  background: #eef4f5;
}

.agent-output-frame img,
.agent-output-frame video {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: block;
  object-fit: contain;
  border-radius: 5px;
  background: #102027;
}

.agent-output-action {
  position: absolute;
  right: 16px;
  bottom: 16px;
  min-height: 34px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 5px;
  color: #fff;
  background: rgba(5, 43, 61, .88);
  font-size: 10px;
  font-weight: 750;
}

.agent-output-action svg {
  width: 14px;
  height: 14px;
  color: currentColor;
}

.agent-image-result,
.agent-video-inputs,
.agent-video-result {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.agent-video-inputs .agent-field textarea {
  min-height: 140px;
}

.agent-upload-zone {
  min-height: 110px;
  padding: 16px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
  border: 1px dashed #98bdc3;
  border-radius: 7px;
  color: #456f78;
  background: #f6fbfb;
  cursor: pointer;
  text-align: center;
}

.agent-upload-zone:hover {
  border-color: #078b95;
  background: #eefafa;
}

.agent-upload-zone svg {
  width: 22px;
}

.agent-upload-zone span {
  color: var(--muted);
  font-size: 10px;
}

.agent-upload-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.agent-upload-zone[hidden],
.agent-upload-list[hidden],
#videoFormatControl[hidden] {
  display: none;
}

.agent-upload-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.agent-upload-list>span {
  max-width: 100%;
  min-height: 30px;
  padding: 0 4px 0 9px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #c6dadd;
  border-radius: 5px;
  background: #fff;
  font-size: 10px;
}

.agent-upload-list b {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-upload-list svg {
  width: 13px;
}

.agent-upload-list button {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border: 0;
  color: #718087;
  background: transparent;
}

.agent-progress-panel {
  padding: 14px;
  border: 1px solid #cadcdf;
  border-radius: 7px;
  background: #f8fbfb;
}

.agent-progress-panel>div {
  justify-content: space-between;
  color: #45656c;
  font-size: 11px;
}

.agent-progress-panel progress {
  width: 100%;
  height: 9px;
  margin: 11px 0 6px;
  accent-color: #078b95;
}

.agent-progress-panel small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.agent-progress-panel.is-active {
  border-color: #90c7cc;
  background: #f2fbfb;
}

.agent-progress-panel.is-error {
  border-color: #e4b3b3;
  background: #fff7f7;
}

.agent-progress-panel.is-error progress {
  accent-color: #c54545;
}

.agent-progress-panel.is-error strong,
.agent-progress-panel.is-error small {
  color: #a93636;
}

.video-output {
  min-height: 222px;
}

.agent-command-bar {
  min-height: 50px;
  margin-top: 16px;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid #dce7e8;
  padding-top: 16px;
}

.agent-command-bar>span {
  color: var(--muted);
  font-size: 11px;
}

.agent-command-bar button {
  min-height: 40px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  border-radius: 5px;
  color: #fff;
  background: var(--brand-action);
  box-shadow: 0 9px 20px rgba(3, 70, 110, .2);
  font-weight: 750;
}

.agent-command-bar button:hover {
  background: var(--brand-action-hover);
  transform: translateY(-1px);
}

.agent-command-bar svg {
  width: 16px;
}

@keyframes agent-panel-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (min-width: 900px) {
  .agent-page {
    height: 100%;
    padding-top: 18px;
    padding-bottom: 18px;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    overflow: hidden;
  }


  .agent-heading {
    min-height: 46px;
    padding-bottom: 12px;
    align-items: center;
  }

  .agent-heading .eyebrow,
  .agent-heading>div>p:last-child,
  .agent-workspace-head p {
    display: none;
  }

  .agent-heading h1 {
    font-size: 27px;
  }

  .agent-mode-tabs {
    margin: 10px 0;
  }

  .agent-mode-tabs button {
    min-height: 40px;
  }

  .agent-workspace {
    min-height: 0;
    padding: 16px;
    overflow: hidden;
  }

  .agent-workspace-head {
    min-height: 48px;
    padding-bottom: 10px;
  }

  .agent-workspace-icon {
    width: 36px;
    height: 36px;
  }

  .agent-workspace h2 {
    font-size: 17px;
  }

  .agent-workspace-head label {
    min-width: min(280px, 36%);
  }

  .agent-workspace select {
    height: 34px;
    margin-top: 3px;
  }

  .agent-workspace[data-agent-panel="TEXT"] {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, .85fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    column-gap: 16px;
  }

  .agent-workspace[data-agent-panel="TEXT"]>.agent-workspace-head {
    grid-column: 1 / -1;
  }

  .agent-workspace[data-agent-panel="TEXT"]>.agent-chat-context {
    min-height: 0;
    margin-top: 12px;
    grid-column: 1;
    grid-row: 2 / 4;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .agent-workspace[data-agent-panel="TEXT"] .agent-chat-history {
    min-height: 0;
    max-height: none;
  }

  .agent-workspace[data-agent-panel="TEXT"]>.agent-text-options {
    margin-top: 12px;
    grid-column: 2;
    grid-row: 2;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: end;
    gap: 8px;
  }

  .agent-workspace[data-agent-panel="TEXT"] .agent-image-url {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .agent-workspace[data-agent-panel="TEXT"] .agent-switch,
  .agent-workspace[data-agent-panel="TEXT"] .agent-local-image-button {
    min-height: 34px;
  }

  .agent-workspace[data-agent-panel="TEXT"]>.agent-composer-dock {
    min-height: 0;
    margin-top: 10px;
    padding-top: 10px;
    grid-column: 2;
    grid-row: 3;
    align-self: end;
  }

  .agent-text-composer {
    margin-top: 0;
  }

  .agent-field.agent-text-composer textarea {
    min-height: 76px;
    max-height: 132px;
  }

  .agent-workspace[data-agent-panel="TEXT"] .agent-command-bar {
    min-height: 44px;
    margin-top: 8px;
    padding-top: 8px;
  }

  .agent-workspace[data-agent-panel="IMAGE"],
  .agent-workspace[data-agent-panel="VIDEO"] {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .agent-image-layout,
  .agent-video-layout {
    min-height: 0;
    margin-top: 12px;
  }

  .agent-image-layout .agent-field,
  .agent-image-layout .agent-field textarea,
  .agent-image-layout .agent-output-frame {
    min-height: 0;
    height: 100%;
  }

  .agent-image-layout .agent-field textarea {
    resize: none;
  }

  .agent-image-inputs {
    min-height: 0;
    grid-template-rows: minmax(0, 1fr) auto auto auto;
    gap: 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .agent-image-inputs .agent-field {
    height: auto;
  }

  .agent-image-result {
    min-height: 0;
    grid-template-rows: auto minmax(150px, 1fr);
  }

  .agent-image-result .agent-output-frame {
    min-height: 150px;
  }

  .agent-video-layout {
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .agent-video-inputs .agent-field textarea {
    min-height: 92px;
  }

  .agent-upload-zone {
    min-height: 82px;
    padding: 10px;
  }

  .agent-video-result {
    grid-template-rows: auto minmax(150px, 1fr);
  }

  .video-output {
    min-height: 150px;
  }

  .agent-workspace[data-agent-panel="IMAGE"]>.agent-command-bar,
  .agent-workspace[data-agent-panel="VIDEO"]>.agent-command-bar {
    min-height: 44px;
    margin-top: 10px;
    padding-top: 10px;
  }
}

@media (min-width: 900px) and (max-height: 640px) {
  .agent-heading {
    min-height: 38px;
    padding-bottom: 8px;
  }

  .agent-heading h1 {
    font-size: 24px;
  }

  .agent-mode-tabs {
    margin: 6px 0;
  }

  .agent-mode-tabs button {
    min-height: 36px;
  }

  .agent-workspace-head {
    min-height: 42px;
    padding-bottom: 8px;
  }

  .agent-video-inputs,
  .agent-video-result {
    gap: 8px;
  }

  .agent-video-inputs .agent-field textarea {
    min-height: 64px;
    padding: 9px 11px;
  }

  .agent-upload-zone {
    min-height: 58px;
    padding: 6px;
  }

  .agent-upload-zone span {
    display: none;
  }

  .agent-progress-panel {
    padding: 9px;
  }

  .agent-progress-panel progress {
    margin: 6px 0 3px;
  }

  .agent-video-result {
    grid-template-rows: auto minmax(105px, 1fr);
  }

  .video-output {
    min-height: 105px;
    padding: 14px;
  }
}

@media (max-width: 760px) {
  .agent-heading,
  .agent-workspace-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .agent-heading-tools { width: 100%; justify-content: flex-start; }
  .agent-save-warning { width: 100%; }
  .agent-history-item { grid-template-columns: 32px minmax(0,1fr); }
  .agent-history-actions { grid-column: 2; display:flex; }

  .agent-mode-tabs {
    margin: 14px 0 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  .agent-mode-tabs button {
    min-width: 0;
    min-height: 52px;
    padding: 6px 5px;
    justify-content: center;
    gap: 5px;
    font-size: 11px;
    line-height: 1.25;
    text-align: center;
  }

  .agent-mode-tabs button span {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .agent-mode-tabs svg {
    width: 16px;
    flex: 0 0 auto;
  }

  .agent-workspace {
    padding: 16px;
  }

  .agent-composer-dock {
    margin-top: 16px;
    padding-top: 12px;
  }

  .agent-workspace-head label {
    width: 100%;
    min-width: 0;
  }

  .agent-text-columns,
  .agent-image-layout,
  .agent-video-layout {
    grid-template-columns: 1fr;
  }

  .agent-text-options {
    align-items: stretch;
    flex-direction: column;
  }

  .agent-media-options {
    grid-template-columns: 1fr;
  }

  .agent-image-url {
    width: 100%;
  }

  .agent-local-image-button {
    width: 100%;
  }

  .agent-chat-history {
    min-height: 200px;
    max-height: 320px;
    padding: 12px;
  }

  .agent-chat-empty {
    min-height: 176px;
  }

  .agent-chat-message {
    width: 92%;
  }

  .agent-field textarea,
  .agent-image-layout .agent-field textarea {
    min-height: 160px;
  }

  .agent-field.agent-text-composer textarea {
    min-height: 84px;
    max-height: 150px;
  }
}

@media (orientation: portrait) and (max-width: 899px) {
  .agent-page {
    padding-top: 12px;
  }

  .agent-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(128px, 44%);
    align-items: start;
    gap: 10px;
  }

  .agent-heading>div>p:last-child,
  .agent-service-state,
  .agent-workspace-head p {
    display: none;
  }

  .agent-heading-tools {
    width: auto;
    display: grid;
    justify-items: end;
    gap: 6px;
  }

  .agent-save-warning {
    width: auto;
    justify-content: flex-end;
    color: #85502c;
    font-size: 9px;
    line-height: 1.35;
    text-align: right;
  }

  .agent-save-warning svg {
    width: 14px;
    flex: 0 0 auto;
  }

  .agent-history-button {
    min-height: 30px;
    padding: 0 9px;
  }

  .agent-mode-tabs {
    margin: 8px 0;
  }

  .agent-mode-tabs button {
    min-height: 44px;
  }

  .agent-workspace[data-agent-panel="TEXT"] {
    display: flex;
    flex-direction: column;
  }

  .agent-workspace[data-agent-panel="TEXT"]>.agent-workspace-head { order: 0; }

  .agent-workspace[data-agent-panel="TEXT"]>.agent-composer-dock {
    position: sticky;
    z-index: 4;
    bottom: 0;
    order: 3;
    margin-top: 10px;
    padding-top: 10px;
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 -10px 20px rgba(16, 58, 72, .06);
  }

  .agent-workspace[data-agent-panel="TEXT"]>.agent-text-options {
    order: 2;
    margin-top: 10px;
  }

  .agent-workspace[data-agent-panel="TEXT"]>.agent-chat-context {
    order: 1;
    margin-top: 10px;
  }

  .agent-field.agent-text-composer textarea {
    min-height: 68px;
    max-height: 112px;
  }

  .agent-chat-history {
    min-height: 150px;
    max-height: 250px;
  }

  .agent-chat-empty {
    min-height: 126px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .agent-workspace { animation: none; }
}
