:root {
  --bg: #f2eee9;
  --card: #ffffff;
  --text: #2f2a27;
  --muted: #71675f;
  --accent: #a48d7d;
  --accent-strong: #8d725f;
  --accent-soft: #ece2d9;
  --line: #dfd5cc;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255,255,255,0.95), rgba(255,255,255,0) 35%),
    linear-gradient(180deg, #f7f2ec 0%, var(--bg) 100%);
  color: var(--text);
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 26px 24px 40px; }
.wrap, .card, .hero-card, .status-grid, .status-metric, .items-gallery, .gallery-card {
  min-width: 0;
}
.row { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.row-left { justify-content: flex-start; }
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}
.brand-block { min-width: 170px; }
.brand-kicker { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.brand-title { font-size: 28px; font-weight: 800; line-height: 1; margin-top: 2px; }
.nav { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #4a4039;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 14px;
  backdrop-filter: blur(8px);
}
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tab:hover { background: #f2e8df; }
.tab.active:hover { background: var(--accent-strong); }
.topbar-btn { min-width: 96px; justify-self: end; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 14px 40px rgba(109, 88, 72, 0.08);
}
.card h1, .card h2 { margin-top: 0; }
.login-body { min-height: 100vh; display: grid; place-items: center; }
.login-box { width: min(420px, 92vw); background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 24px; box-shadow: 0 14px 40px rgba(109, 88, 72, 0.08); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.span-2, .span-full { grid-column: 1 / -1; }
label { display: block; font-size: 14px; margin-bottom: 8px; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 13px;
  margin-top: 4px;
  font-size: 14px;
  background: rgba(255,255,255,0.92);
}
textarea { resize: vertical; }
button {
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
}
button:hover { background: var(--accent-strong); }
button.ghost { background: #e8e0da; color: #493f39; }
button.danger { background: #b44a3d; color: #fff; }
button.danger:hover { background: #9f3d31; }
button:disabled { opacity: 0.6; cursor: default; }
.muted { color: var(--muted); }
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  background: #f8f5f2;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  margin-top: 10px;
  max-width: 100%;
}
.hero-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  background:
    radial-gradient(circle at right top, rgba(164,141,125,0.12), rgba(164,141,125,0) 36%),
    linear-gradient(180deg, rgba(255,255,255,0.92), rgba(255,255,255,0.82));
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  margin-bottom: 14px;
}
.hero-kicker, .section-kicker {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}
.hero-copy { max-width: 680px; margin-bottom: 0; }
.hero-badge {
  background: var(--accent-soft);
  color: #5f4e42;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 800;
  white-space: nowrap;
}
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.settings-card { margin-bottom: 0; }
.section-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2 { margin: 2px 0 0; }
.save-scope { background: #efe6de; color: #5c4c41; }
.save-scope:hover { background: #e3d5c9; }
.settings-footer { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.hero-status { grid-template-columns: minmax(0, 1fr) auto; gap: 18px 22px; align-items: start; }
.status-side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.status-badge { min-width: 170px; text-align: center; }
.status-badge.idle { background: #eee5dc; color: #6a5a4d; }
.status-badge.running { background: #a48d7d; color: #fff; }
.status-badge.done { background: #5f8b63; color: #fff; }
.status-badge.error { background: #b56457; color: #fff; }
.status-note {
  min-width: 220px;
  max-width: 320px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.82);
  border: 1px solid var(--line);
  color: #4e433c;
  font-size: 14px;
  line-height: 1.45;
  text-align: right;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.status-progress { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.status-progress-bar { position: relative; width: 100%; height: 16px; border-radius: 999px; background: rgba(164, 141, 125, 0.16); overflow: hidden; }
.status-progress-fill { width: 0; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #b39b8b 0%, #8d725f 100%); transition: width 0.35s ease; }
.status-progress-text { font-weight: 700; color: #574a41; white-space: nowrap; }
.status-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.status-metric { min-height: 112px; min-width: 0; padding: 16px; border-radius: 18px; background: rgba(255,255,255,0.86); border: 1px solid var(--line); overflow: hidden; }
.status-metric-value { margin-top: 8px; font-size: 28px; font-weight: 800; line-height: 1.08; color: #443b35; }
.metric-event { font-size: 16px; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; word-break: break-word; }
#execution-status-title,
#execution-status-meta,
#execution-progress-text,
#execution-live-note,
#metric-last-event {
  overflow-wrap: anywhere;
  word-break: break-word;
}
#execution-status-meta {
  max-width: 100%;
}
#run-state {
  margin-top: 14px;
  max-height: 240px;
  overflow: auto;
  max-width: 100%;
  min-width: 0;
  font-size: 13px;
  line-height: 1.45;
}
.prompt-editor-wrap {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: rgba(255,255,255,0.78);
}
.prompt-editor-head {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: 10px;
  align-items: end;
}
.prompt-editor-meta {
  font-size: 13px;
  line-height: 1.4;
}
#prompt-editor {
  margin-top: 6px;
  min-height: 260px;
  font-family: Menlo, Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.35;
}
.prompt-trace-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.prompt-trace-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: rgba(255,255,255,0.78);
  min-width: 0;
}
#trace-gpt,
#trace-krea-sent {
  margin-top: 8px;
  max-height: 260px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.4;
}
#msg { margin-top: 14px; border-radius: 16px; min-height: 58px; }
.items-gallery { display: grid; gap: 16px; margin-top: 14px; }
.history-list { display: grid; gap: 10px; }
.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.82);
}
.history-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(164, 141, 125, 0.35) inset;
}
.history-main { min-width: 0; }
.history-title {
  font-weight: 800;
  font-size: 15px;
  color: #453b34;
  overflow-wrap: anywhere;
}
.history-meta {
  margin-top: 4px;
  font-size: 13px;
  color: #6e625a;
  overflow-wrap: anywhere;
}
.history-side {
  display: flex;
  align-items: center;
  gap: 8px;
}
.history-badge {
  border-radius: 999px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: #efe6de;
  color: #5a4a3e;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.history-open {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
}
.gallery-card { border: 1px solid var(--line); border-radius: 20px; padding: 16px; background: rgba(255,255,255,0.82); }
.gallery-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; margin-bottom: 12px; min-width: 0; }
.gallery-head h3 { margin: 4px 0 0; font-size: 22px; line-height: 1.15; }
.gallery-description { margin-bottom: 12px; padding: 12px 14px; border-radius: 16px; background: #f8f4ef; border: 1px solid var(--line); }
.gallery-description p { margin: 6px 0 0; color: #4e433c; line-height: 1.5; }
.gallery-meta { white-space: normal; overflow-wrap: anywhere; border-radius: 999px; padding: 8px 12px; background: #efe6de; color: #5a4a3e; font-weight: 700; }
.gallery-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.gallery-section-title { margin: 12px 0 10px; font-size: 14px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: #6a5a4d; }
.raw-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.gallery-shot { display: block; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: #f2ebe4; }
.gallery-shot img { display: block; width: 100%; height: 100%; object-fit: cover; aspect-ratio: 2 / 3; }
.checkbox-label { display: flex; gap: 10px; align-items: center; }
.checkbox-label input { width: auto; margin: 0; }
.publish-grid { align-items: center; }
.inline-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}
.inline-actions button {
  width: auto;
}
.msg { margin-top: 8px; min-height: 20px; color: #8f2a2a; }
#msg {
  max-width: 100%;
  max-height: 220px;
  overflow: auto;
  font-size: 13px;
  line-height: 1.45;
}
.hidden-renderer-frame {
  position: absolute;
  width: 1px;
  height: 1px;
  border: 0;
  opacity: 0;
  pointer-events: none;
  left: -9999px;
  top: -9999px;
}
@media (max-width: 960px) {
  .settings-grid, .status-grid, .grid2, .gallery-grid, .raw-grid, .topbar, .hero-status, .prompt-trace-grid, .prompt-editor-head { grid-template-columns: 1fr; }
  .topbar { gap: 12px; }
  .status-side { align-items: flex-start; }
  .status-note { text-align: left; max-width: none; }
  .history-item { grid-template-columns: 1fr; }
  .history-side { justify-content: flex-start; }
}
