:root {
  color-scheme: light;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  background: #f2f5f3;
  color: #17201b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(153, 209, 175, 0.28), transparent 38rem),
    #f2f5f3;
}

.shell {
  width: min(920px, calc(100% - 28px));
  min-height: calc(100vh - 28px);
  margin: 14px auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(29, 62, 43, 0.1);
  border-radius: 24px;
  box-shadow: 0 18px 70px rgba(33, 64, 47, 0.1);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 30px;
  border-bottom: 1px solid #e6ece8;
}

.eyebrow {
  margin: 0 0 5px;
  color: #5b806a;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.14em;
}

h1 { margin: 0; font-size: clamp(24px, 4vw, 34px); }
.subtitle { margin: 6px 0 0; color: #6b756f; }

.status {
  flex: none;
  padding: 9px 13px;
  border-radius: 999px;
  background: #eef1ef;
  color: #536159;
  font-size: 13px;
}
.status.ready { background: #e1f4e8; color: #1f6a3d; }
.status.waiting { background: #fff3d8; color: #78540b; }
.status.error { background: #ffe6e5; color: #9a312d; }

.chat {
  min-height: 420px;
  max-height: calc(100vh - 310px);
  overflow-y: auto;
  padding: 30px;
}

.message { display: flex; flex-direction: column; margin-bottom: 18px; }
.message.user { align-items: flex-end; }
.message.assistant { align-items: flex-start; }

.bubble {
  max-width: min(78%, 680px);
  padding: 13px 16px;
  border-radius: 18px;
  line-height: 1.65;
  white-space: pre-wrap;
}
.assistant .bubble { background: #edf2ef; border-bottom-left-radius: 6px; }
.user .bubble { background: #1e6a43; color: white; border-bottom-right-radius: 6px; }
.message small { margin: 7px 5px 0; color: #7a8580; }

.composer {
  display: grid;
  gap: 12px;
  padding: 20px 24px 24px;
  border-top: 1px solid #e6ece8;
  background: #fbfcfb;
}

.token-field { display: grid; grid-template-columns: 80px 1fr; align-items: center; gap: 10px; color: #627068; font-size: 13px; }
input, textarea, button { font: inherit; }
.token-field input, textarea {
  width: 100%;
  border: 1px solid #d9e1dc;
  border-radius: 12px;
  background: white;
  outline: none;
}
.token-field input { padding: 9px 11px; }
textarea { padding: 13px 14px; resize: vertical; min-height: 84px; }
input:focus, textarea:focus { border-color: #4a9b6c; box-shadow: 0 0 0 3px rgba(74, 155, 108, 0.12); }

.actions { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.approval { display: flex; align-items: center; gap: 8px; color: #59665f; font-size: 13px; }
.approval input { width: 18px; height: 18px; accent-color: #1e6a43; }
button {
  border: 0;
  border-radius: 12px;
  padding: 11px 24px;
  background: #1e6a43;
  color: white;
  font-weight: 700;
  cursor: pointer;
}
button:hover { background: #185737; }
button:disabled { opacity: 0.55; cursor: wait; }

.browser-shell {
  width: min(1180px, calc(100% - 24px));
  margin: 12px auto;
  display: grid;
  gap: 12px;
}
.browser-toolbar, .typing-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: white;
  border: 1px solid #dfe7e2;
  border-radius: 16px;
}
.browser-toolbar input, .typing-bar input {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #d9e1dc;
  border-radius: 10px;
}
.browser-toolbar #token { width: 180px; }
.browser-toolbar #url, .typing-bar #text { flex: 1; }
.back-link { color: #1e6a43; text-decoration: none; white-space: nowrap; }
.secondary { background: #e8efeb; color: #244f37; }
.secondary:hover { background: #dce8e1; }
.privacy-note { margin: 0; padding: 0 8px; color: #5e6d64; font-size: 13px; }
.browser-stage {
  position: relative;
  min-height: 620px;
  display: grid;
  place-items: center;
  overflow: auto;
  background: #202522;
  border-radius: 18px;
}
.browser-stage img {
  width: min(100%, 1000px);
  height: auto;
  cursor: crosshair;
  user-select: none;
}
.browser-message { color: white; padding: 24px; text-align: center; }
.error-text { color: #ffb4b0; }

.desktop-shell { width: min(1320px, calc(100% - 20px)); margin: 10px auto; display: grid; gap: 10px; }
.desktop-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px; background: white; border: 1px solid #dfe7e2; border-radius: 16px; }
.desktop-controls input { min-width: 210px; flex: 1; padding: 10px 12px; border: 1px solid #d9e1dc; border-radius: 10px; }
.desktop-status { padding: 10px 12px; border-radius: 10px; background: #26312b; color: white; }
#desktopFrame { width: 100%; height: calc(100vh - 160px); min-height: 680px; border: 0; border-radius: 14px; background: #111; }

@media (max-width: 760px) {
  .browser-toolbar, .typing-bar { flex-wrap: wrap; }
  .browser-toolbar #token, .browser-toolbar #url, .typing-bar #text { width: 100%; flex-basis: 100%; }
  .browser-stage { min-height: 420px; }
}

@media (max-width: 640px) {
  .shell { width: 100%; min-height: 100vh; margin: 0; border-radius: 0; }
  .topbar { align-items: flex-start; padding: 20px; }
  .status { max-width: 130px; text-align: center; }
  .chat { padding: 20px; max-height: none; }
  .bubble { max-width: 92%; }
  .composer { padding: 16px; }
  .actions { align-items: flex-end; }
}
