:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e1ea;
  --blue: #0969da;
  --green: #138a5e;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.app {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.chat {
  width: min(880px, 100%);
  min-height: min(820px, calc(100vh - 36px));
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
}

p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: #b42318;
  flex: 0 0 auto;
}

.dot.ok {
  background: var(--green);
}

.messages {
  padding: 16px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bubble {
  max-width: 92%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #f8fafc;
  font-size: 15px;
  line-height: 1.55;
}

.bubble.user {
  align-self: flex-end;
  background: #edf6ff;
  border-color: #badcff;
}

.bubble.system {
  align-self: flex-start;
}

.bubble.failed {
  border-color: #f2b8b5;
  background: #fff6f5;
}

.logs {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.gallery {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.result-image {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.caption {
  margin: 0 0 6px;
  font-weight: 650;
  color: #24364b;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: #fbfcfe;
}

input {
  width: 100%;
  height: 44px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0 12px;
  font-size: 16px;
  color: var(--ink);
  background: #fff;
}

input:focus {
  outline: 2px solid rgba(9, 105, 218, 0.2);
  border-color: var(--blue);
}

button {
  height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  font-size: 15px;
  font-weight: 650;
  color: #fff;
  background: var(--blue);
}

button:disabled {
  background: #98a2b3;
}

@media (max-width: 640px) {
  .app {
    padding: 0;
  }

  .chat {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .bubble {
    max-width: 100%;
  }
}
