:root {
  color-scheme: light;
  --bg: #eef5ff;
  --panel: #ffffff;
  --panel-2: #f7faff;
  --panel-3: #eef4fc;
  --nav: #122744;
  --nav-2: #17365c;
  --line: #d8e3f1;
  --line-soft: rgba(57, 81, 118, 0.16);
  --text: #172335;
  --muted: #66788f;
  --quiet: #8ca0b5;
  --teal: #18c4b2;
  --teal-deep: #0f8f88;
  --blue: #4f8cff;
  --violet: #7c6df2;
  --coral: #ff786b;
  --amber: #d7a74b;
  --shadow: 0 18px 46px rgba(37, 61, 96, 0.14);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: linear-gradient(135deg, #f7fbff 0%, #edf5ff 52%, #f7f4ff 100%);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

body:not(.authenticated) .app-shell {
  display: none;
}

body.authenticated .login-screen {
  display: none;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 18%, rgba(24, 196, 178, 0.2), transparent 30%),
    radial-gradient(circle at 76% 72%, rgba(255, 120, 107, 0.18), transparent 28%),
    linear-gradient(135deg, #f7fbff 0%, #eef5ff 58%, #fff8f1 100%);
}

.login-card {
  display: grid;
  gap: 16px;
  width: min(430px, calc(100vw - 32px));
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.login-brand {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-bottom: 4px;
}

.login-brand h1 {
  margin: 4px 0 0;
  font-size: 26px;
  line-height: 1.15;
}

.login-card label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.login-card input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

.login-card input:focus {
  border-color: rgba(24, 196, 178, 0.72);
  box-shadow: 0 0 0 3px rgba(24, 196, 178, 0.13);
}

.login-status {
  min-height: 22px;
  color: var(--muted);
  font-size: 14px;
}

.login-status[data-type="error"] {
  color: #a83a33;
}

.login-button {
  width: 100%;
  margin-left: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 212px 252px minmax(520px, 1fr);
  height: 100vh;
  min-height: 720px;
}

.app-shell > * {
  min-height: 0;
  overflow: hidden;
}

.primary-nav,
.history-panel {
  min-width: 0;
  border-right: 1px solid var(--line-soft);
}

.primary-nav {
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  background:
    radial-gradient(circle at 34% 28%, rgba(24, 196, 178, 0.26), transparent 30%),
    radial-gradient(circle at 72% 58%, rgba(124, 109, 242, 0.26), transparent 36%),
    linear-gradient(180deg, #17365c 0%, #122744 58%, #18304b 100%);
  color: #eef8ff;
}

.brand {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 24px;
}

.brand-logo {
  width: 64px;
  height: 48px;
  border: 1px solid rgba(231, 198, 126, 0.45);
  border-radius: 8px;
  object-fit: cover;
  object-position: center;
  background: #0d1117;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.16);
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  color: #ffffff;
  font-size: 16px;
}

.brand span {
  color: rgba(232, 244, 255, 0.72);
  font-size: 12px;
}

.nav-section {
  display: grid;
  gap: 8px;
}

.nav-section.compact {
  margin-top: 8px;
}

.nav-group-title {
  margin: 28px 8px 8px;
  color: rgba(232, 244, 255, 0.58);
  font-size: 12px;
}

.nav-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: rgba(238, 248, 255, 0.82);
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.12);
}

.nav-item.active {
  color: #ffffff;
  box-shadow: inset 3px 0 0 var(--teal);
}

.nav-agent-block {
  display: grid;
  gap: 6px;
}

.nav-chevron {
  color: rgba(238, 248, 255, 0.62);
  font-size: 22px;
  line-height: 1;
  transition: transform 0.18s ease;
}

.nav-agent-block.open .nav-chevron {
  transform: rotate(90deg);
}

.nav-subfeatures {
  display: grid;
  gap: 6px;
  margin-left: 20px;
  padding: 2px 0 4px 14px;
  border-left: 1px solid rgba(238, 248, 255, 0.18);
}

.nav-subfeatures[hidden] {
  display: none;
}

.nav-subfeature {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: rgba(238, 248, 255, 0.7);
  text-align: left;
}

.nav-subfeature:hover,
.nav-subfeature.active {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.nav-subfeature.active {
  box-shadow: inset 3px 0 0 var(--amber);
}

.nav-current {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 14px;
  box-shadow: inset 3px 0 0 var(--teal);
}

.nav-footnote {
  margin-top: auto;
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.09);
  color: rgba(235, 247, 255, 0.78);
  font-size: 13px;
}

.icon-dot,
.icon-square,
.icon-frame,
.icon-crop,
.icon-clock,
.icon-folder,
.icon-gear,
.icon-close,
.upload-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  position: relative;
}

.icon-dot::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(24, 196, 178, 0.2);
}

.icon-square::before,
.icon-frame::before,
.icon-folder::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 2px solid currentColor;
  border-radius: 4px;
}

.icon-frame::after {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  top: 8px;
  border-top: 2px solid currentColor;
}

.icon-crop::before,
.icon-crop::after {
  content: "";
  position: absolute;
  border-color: currentColor;
  border-style: solid;
}

.icon-crop::before {
  left: 4px;
  top: 2px;
  width: 8px;
  height: 12px;
  border-width: 0 0 2px 2px;
}

.icon-crop::after {
  right: 4px;
  bottom: 2px;
  width: 8px;
  height: 12px;
  border-width: 2px 2px 0 0;
}

.icon-clock::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.icon-clock::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 5px;
  width: 5px;
  height: 5px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.icon-gear::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 2px solid currentColor;
  border-radius: 50%;
  box-shadow: 0 -6px 0 -4px currentColor, 0 6px 0 -4px currentColor, 6px 0 0 -4px currentColor, -6px 0 0 -4px currentColor;
}

.icon-close::before,
.icon-close::after {
  content: "";
  position: absolute;
  left: 3px;
  right: 3px;
  top: 8px;
  border-top: 2px solid currentColor;
}

.icon-close::before {
  transform: rotate(45deg);
}

.icon-close::after {
  transform: rotate(-45deg);
}

.history-panel {
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  background: rgba(247, 250, 255, 0.94);
  backdrop-filter: blur(18px);
}

.history-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef4fc;
}

.tab-button {
  min-height: 32px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.tab-button.active {
  background: #ffffff;
  color: #14243a;
  box-shadow: 0 6px 16px rgba(60, 84, 120, 0.12);
}

.history-actions,
.topbar,
.composer-controls,
.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-actions {
  margin: 18px 4px 12px;
}

.history-action-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-actions strong {
  color: var(--text);
}

.history-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  gap: 6px;
  align-items: stretch;
}

.history-item {
  display: grid;
  gap: 5px;
  width: 100%;
  min-height: 58px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  text-align: left;
}

.history-row.active .history-item {
  border-color: rgba(24, 196, 178, 0.36);
  background: linear-gradient(135deg, rgba(24, 196, 178, 0.14), rgba(124, 109, 242, 0.1));
}

.history-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.history-item span {
  color: var(--quiet);
  font-size: 12px;
}

.history-delete {
  display: grid;
  place-items: center;
  align-self: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--quiet);
}

.history-delete:hover {
  border-color: rgba(255, 120, 107, 0.42);
  color: #b94a42;
}

.history-delete .icon-close {
  width: 16px;
  height: 16px;
}

.history-empty {
  padding: 14px 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.agent-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(244, 249, 255, 0.76)),
    #f6faff;
}

.topbar {
  min-height: 82px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.64);
}

.topbar h1,
.workspace-head h2,
.dialog-head h2 {
  margin: 3px 0 0;
  color: var(--text);
  font-size: 22px;
  line-height: 1.15;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.user-chip {
  max-width: 156px;
  overflow: hidden;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7fbff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-button,
.ghost-button,
.accent-button,
.pill-button,
.send-button {
  min-height: 38px;
  border-radius: 8px;
  padding: 0 14px;
  color: var(--text);
  white-space: nowrap;
}

.tool-button {
  display: grid;
  place-items: center;
  width: 38px;
  padding: 0;
  border: 1px solid var(--line);
  background: #ffffff;
}

.ghost-button {
  border: 1px solid var(--line);
  background: #ffffff;
}

.ghost-button.subtle {
  color: var(--muted);
  background: #f8fbff;
}

.accent-button {
  border: 1px solid rgba(79, 140, 255, 0.28);
  background: linear-gradient(135deg, #4f8cff, #7c6df2);
  color: #ffffff;
  box-shadow: 0 12px 26px rgba(79, 140, 255, 0.18);
}

.accent-button.wide {
  width: 100%;
  margin-top: 12px;
}

.composer-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.upload-icon::before,
.upload-icon::after {
  content: "";
  position: absolute;
}

.upload-icon::before {
  left: 3px;
  right: 3px;
  bottom: 3px;
  height: 10px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.upload-icon::after {
  left: 8px;
  top: 2px;
  width: 0;
  height: 12px;
  border-left: 2px solid currentColor;
  box-shadow: -4px 3px 0 -1px currentColor, 4px 3px 0 -1px currentColor;
}

.thumb-list {
  display: flex;
  grid-auto-flow: column;
  grid-auto-columns: 112px;
  gap: 10px;
  overflow-x: auto;
  align-items: center;
  min-width: 0;
}

.thumb {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  grid-template-rows: 76px 30px;
  width: 110px;
  height: 106px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e8eef7;
}

.thumb img {
  width: 100%;
  height: 76px;
  object-fit: cover;
}

.thumb.empty {
  display: grid;
  place-items: center;
  width: 110px;
  height: 76px;
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  background: rgba(20, 36, 58, 0.78);
  color: #ffffff;
  line-height: 1;
}

.thumb-role {
  width: 100%;
  min-width: 0;
  height: 30px;
  padding: 0 7px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: #ffffff;
  color: var(--text);
  font-size: 12px;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.field-hint {
  color: #718399;
  font-size: 12px;
  line-height: 1.45;
}

.server-config-notice {
  padding: 10px 12px;
  border: 1px solid rgba(24, 196, 178, 0.32);
  border-radius: 8px;
  background: #f0fffc;
  color: #0d716c;
  font-size: 13px;
  line-height: 1.45;
}

.api-status {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
}

.api-status.muted {
  border: 1px solid #dbe4ef;
  background: #f7f9fc;
  color: #607086;
}

.api-status.success {
  border: 1px solid rgba(24, 196, 178, 0.32);
  background: #f0fffc;
  color: #0d716c;
}

.api-status.warning {
  border: 1px solid rgba(221, 151, 35, 0.35);
  background: #fff8e8;
  color: #8a5b0b;
}

.api-status.error {
  border: 1px solid rgba(220, 67, 67, 0.35);
  background: #fff1f1;
  color: #9a2525;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  resize: none;
  padding: 12px;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(24, 196, 178, 0.75);
  box-shadow: 0 0 0 3px rgba(24, 196, 178, 0.14);
}

.chat-stream {
  display: grid;
  align-content: start;
  gap: 16px;
  overflow: auto;
  padding: 22px 24px 28px;
}

.message {
  display: grid;
  gap: 10px;
  max-width: 980px;
}

.message.user {
  justify-self: end;
  width: min(720px, 100%);
}

.bubble {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 10px 24px rgba(37, 61, 96, 0.08);
}

.message.user .bubble {
  background: rgba(24, 196, 178, 0.12);
  border-color: rgba(24, 196, 178, 0.3);
}

.message-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.message-title strong {
  color: #1d2f48;
}

.bubble p {
  margin: 0;
  line-height: 1.65;
  white-space: pre-line;
}

.thinking-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f7ff;
  box-shadow: 0 10px 24px rgba(37, 61, 96, 0.08);
  overflow: hidden;
}

.thinking-card summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 0 14px;
  color: #4d5f77;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.thinking-card summary::-webkit-details-marker {
  display: none;
}

.thinking-card summary::after {
  content: "›";
  color: #8ca0b5;
  font-size: 24px;
  transition: transform 0.18s ease;
}

.thinking-card[open] summary::after {
  transform: rotate(90deg);
}

.thinking-content {
  padding: 0 14px 14px;
  color: #52657c;
  line-height: 1.65;
  white-space: pre-line;
}

.analysis-card {
  display: grid;
  gap: 10px;
}

.analysis-badge {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f7faff;
  color: #41546e;
}

.analysis-badge span {
  font-weight: 800;
}

.analysis-badge small {
  color: var(--muted);
}

.analysis-card.success .analysis-badge {
  background: rgba(228, 255, 251, 0.86);
  color: #0d716c;
}

.analysis-card.error .analysis-badge {
  background: rgba(255, 240, 237, 0.88);
  color: #9b302b;
}

.analysis-card.loading .analysis-badge {
  background: rgba(236, 243, 255, 0.94);
  color: #315d9a;
}

.analysis-card.local .analysis-badge {
  background: rgba(255, 248, 230, 0.92);
  color: #81611b;
}

.chat-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 236px);
  justify-content: start;
  gap: 12px;
  margin-top: 14px;
}

.chat-result-card {
  width: 236px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.chat-result-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #eef4fc;
}

.previewable-image {
  cursor: zoom-in;
}

.previewable-image:focus-visible {
  outline: 3px solid rgba(24, 196, 178, 0.42);
  outline-offset: -3px;
}

.chat-result-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
}

.chat-result-meta strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-result-meta button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  background: rgba(24, 196, 178, 0.13);
  color: #0d716c;
}

.failed-result-card {
  border-color: rgba(229, 94, 78, 0.36);
  background: #fffafa;
}

.failed-result-preview {
  position: relative;
}

.failed-result-preview > span {
  position: absolute;
  top: 9px;
  left: 9px;
  padding: 5px 8px;
  border-radius: 5px;
  background: rgba(147, 43, 38, 0.9);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.failed-result-preview img {
  opacity: 0.72;
  filter: saturate(0.72);
}

.failure-result-meta {
  grid-template-columns: minmax(0, 1fr) auto;
}

.failure-result-meta p {
  grid-column: 1 / -1;
  margin: 0;
  color: #9b302b;
  font-size: 12px;
  line-height: 1.45;
}

.failure-result-meta button {
  background: rgba(229, 94, 78, 0.12);
  color: #9b302b;
}

.failure-result-meta button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(184px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.choice-button {
  min-height: 68px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  color: var(--text);
  text-align: left;
}

.choice-button:hover {
  border-color: rgba(79, 140, 255, 0.42);
  background: #ffffff;
}

.choice-button strong {
  display: block;
  margin-bottom: 3px;
  overflow-wrap: anywhere;
}

.choice-button small {
  display: block;
  color: var(--muted);
  line-height: 1.35;
}

.choice-button.selected {
  border-color: rgba(215, 167, 75, 0.66);
  background: rgba(255, 248, 230, 0.92);
}

.choice-button.multi.selected {
  border-color: rgba(24, 196, 178, 0.55);
  background: rgba(228, 255, 251, 0.92);
}

.missing-result {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 16px;
  background: #eef4fc;
  color: var(--muted);
  text-align: center;
}

body[data-mode="direct"] .toggle-label {
  display: none;
}

.mini-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.composer {
  display: grid;
  gap: 10px;
  padding: 14px 24px 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 -16px 34px rgba(37, 61, 96, 0.09);
}

.composer.drag-over .composer-box {
  border-color: rgba(24, 196, 178, 0.75);
  background: rgba(228, 255, 251, 0.86);
}

.composer-box {
  display: grid;
  grid-template-columns: auto minmax(90px, auto) minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
  min-height: 92px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.composer-upload {
  display: grid;
  position: relative;
  place-items: center;
  align-content: center;
  gap: 4px;
  width: 82px;
  min-height: 70px;
  border: 1px dashed rgba(15, 143, 136, 0.48);
  border-radius: 8px;
  background: rgba(24, 196, 178, 0.08);
  color: #0e746f;
  font-weight: 700;
  cursor: pointer;
}

.composer-box textarea {
  min-height: 70px;
  border: 0;
  background: transparent;
  padding: 8px;
  box-shadow: none;
}

.composer-box textarea:focus {
  border-color: transparent;
  box-shadow: none;
}

.structured-panel {
  overflow: hidden;
  border: 1px solid rgba(79, 140, 255, 0.2);
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fbff, #ffffff);
}

.structured-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 10px 12px;
}

.structured-head strong,
.structured-kicker {
  display: block;
}

.structured-head strong {
  margin-top: 2px;
  color: var(--text);
}

.structured-kicker {
  color: #4f6f96;
  font-size: 11px;
}

.structured-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
  padding: 12px;
  border-top: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.82);
}

.structured-fields[hidden] {
  display: none;
}

.structured-fields input,
.structured-fields select,
.structured-fields textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
}

.structured-fields input,
.structured-fields select {
  min-height: 36px;
  padding: 0 10px;
}

.structured-fields textarea {
  min-height: 58px;
  padding: 9px 10px;
  resize: vertical;
}

.structured-wide {
  grid-column: 1 / -1;
}

.structured-copy-hint {
  margin: 0;
  padding: 9px 10px;
  border-radius: 7px;
  background: #f3f7fc;
  color: #52657c;
  font-size: 12px;
  line-height: 1.5;
}

.composer-controls {
  flex-wrap: wrap;
  justify-content: flex-start;
}

.pill-button,
.pill-select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
}

.pill-button.active {
  border-color: rgba(24, 196, 178, 0.42);
  background: rgba(24, 196, 178, 0.12);
}

.pill-select {
  width: auto;
  max-width: 180px;
  padding: 0 10px;
}

.toggle-label {
  display: flex;
  grid-template-columns: none;
  gap: 7px;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
}

.toggle-label input {
  width: 16px;
  height: 16px;
}

.send-button {
  margin-left: auto;
  min-width: 116px;
  background: linear-gradient(135deg, #ff786b, #f1bd55);
  color: #23150f;
  font-weight: 800;
}

.brief-stack,
.prompt-stack {
  display: grid;
  gap: 10px;
}

.brief-item,
.prompt-card,
.status-card,
.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(37, 61, 96, 0.07);
}

.brief-item {
  padding: 12px;
}

.brief-item strong,
.prompt-card strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
}

.brief-item p,
.prompt-card p {
  margin: 0;
  color: #52657c;
  line-height: 1.55;
  white-space: pre-line;
}

.prompt-card {
  padding: 12px;
}

.status-card {
  padding: 12px;
}

.status-card strong {
  display: block;
  margin-bottom: 6px;
}

.status-card p {
  margin: 0;
  color: #52657c;
  line-height: 1.55;
}

.stop-batch-button {
  min-height: 34px;
  margin-top: 10px;
  padding: 0 13px;
  border: 1px solid rgba(155, 48, 43, 0.26);
  border-radius: 6px;
  background: #ffffff;
  color: #9b302b;
  font-weight: 800;
}

.stop-batch-button:hover {
  background: #fff1ef;
}

.status-card.loading {
  border-color: rgba(79, 140, 255, 0.32);
  background: #f4f8ff;
}

.status-card.success {
  border-color: rgba(24, 196, 178, 0.34);
  background: #f0fffc;
}

.status-card.error {
  border-color: rgba(255, 120, 107, 0.42);
  background: #fff5f3;
}

.status-card.warning {
  border-color: rgba(215, 167, 75, 0.5);
  background: #fff9e9;
}

.status-card.skipped {
  border-color: rgba(82, 101, 124, 0.26);
  background: #f6f8fb;
}

.quality-badge {
  margin: 9px 10px 0;
  padding: 5px 8px;
  border-radius: 6px;
  background: #f3f6fa;
  color: #52657c;
  font-size: 12px;
  font-weight: 800;
}

.quality-badge.passed {
  background: rgba(24, 196, 178, 0.12);
  color: #0d716c;
}

.quality-badge.failed {
  background: rgba(255, 120, 107, 0.13);
  color: #a84034;
}

.quality-issues {
  margin: 7px 10px 0;
  color: #7f433c;
  font-size: 12px;
  line-height: 1.45;
}

.result-card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.result-card-actions button[data-action="retry"] {
  background: rgba(255, 120, 107, 0.13);
  color: #a84034;
}

.result-grid {
  display: grid;
  gap: 12px;
}

.result-card {
  overflow: hidden;
}

.result-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #eef4fc;
}

.result-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
}

.result-meta strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-meta button {
  min-height: 30px;
  border-radius: 6px;
  background: rgba(24, 196, 178, 0.13);
  color: #0d716c;
}

.settings-dialog {
  width: min(520px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  box-shadow: var(--shadow);
}

.settings-dialog::backdrop {
  background: rgba(15, 28, 46, 0.35);
}

.settings-dialog form {
  display: grid;
  gap: 14px;
}

.dialog-actions {
  justify-content: flex-end;
}

.image-preview-dialog {
  width: min(1120px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  box-shadow: var(--shadow);
}

.image-preview-dialog::backdrop {
  background: rgba(15, 28, 46, 0.56);
}

.image-preview-dialog form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: calc(100vh - 28px);
}

.preview-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.preview-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.preview-body {
  display: grid;
  place-items: center;
  min-height: 320px;
  max-height: calc(100vh - 104px);
  overflow: auto;
  padding: 16px;
  background:
    linear-gradient(45deg, rgba(216, 227, 241, 0.36) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(216, 227, 241, 0.36) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(216, 227, 241, 0.36) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(216, 227, 241, 0.36) 75%),
    #f7faff;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.preview-body img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 140px);
  object-fit: contain;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(37, 61, 96, 0.2);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 10;
  transform: translateX(-50%);
  max-width: min(480px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid rgba(24, 196, 178, 0.32);
  border-radius: 8px;
  background: #ffffff;
  color: #153341;
  box-shadow: var(--shadow);
}

@media (max-width: 1360px) {
  .app-shell {
    grid-template-columns: 190px 226px minmax(420px, 1fr);
  }

  .brand {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .brand-logo {
    width: 58px;
  }
}

@media (max-width: 1120px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 188px minmax(0, 1fr);
    min-height: 0;
  }

  .history-panel {
    display: none;
  }

  .agent-panel {
    min-height: 100vh;
  }

  .chat-result-grid {
    grid-template-columns: repeat(auto-fill, 220px);
  }

  .chat-result-card {
    width: 220px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .primary-nav {
    position: sticky;
    top: 0;
    z-index: 4;
    display: block;
    overflow: hidden;
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  }

  .brand {
    grid-template-columns: 66px minmax(0, 1fr);
    margin-bottom: 12px;
  }

  .brand-logo {
    width: 66px;
    height: 50px;
  }

  .nav-section {
    grid-template-columns: 1fr;
    overflow-x: auto;
  }

  .nav-subfeatures {
    margin-left: 16px;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .nav-group-title,
  .nav-section.compact,
  .nav-footnote {
    display: none;
  }

  .agent-panel {
    min-height: auto;
  }

  .topbar,
  .chat-stream,
  .composer {
    padding-left: 14px;
    padding-right: 14px;
  }

  .topbar {
    display: grid;
  }

  .composer-box {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .composer-upload {
    width: 100%;
    min-height: 52px;
    grid-template-columns: auto auto;
    justify-content: center;
  }

  .composer-box textarea {
    min-height: 92px;
  }

  .thumb-list {
    min-height: 106px;
  }

  .thumb {
    width: 104px;
    height: 106px;
  }

  .structured-fields {
    grid-template-columns: 1fr;
  }

  .structured-wide {
    grid-column: auto;
  }

  .structured-head {
    align-items: flex-start;
  }

  .choice-grid {
    grid-template-columns: 1fr;
  }

  .chat-result-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .chat-result-card {
    width: 100%;
  }

  .composer-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pill-select {
    width: 100%;
    max-width: none;
  }

  .send-button {
    grid-column: 1 / -1;
    width: 100%;
    margin-left: 0;
  }
}
