:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #15191f;
  --muted: #69717d;
  --line: #d9dee6;
  --brand: #1677ff;
  --brand-text: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  width: min(960px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

h1, h2, p {
  margin: 0;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 16px;
  margin-bottom: 12px;
}

.top p,
.panel p {
  color: var(--muted);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.tab,
.button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.tab.active,
.button {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--brand-text);
}

.button.ghost {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  background: var(--panel);
  color: var(--text);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.messages {
  min-height: 48vh;
  max-height: 58vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.message,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.message.user {
  margin-left: 12%;
  border-color: #9bc2ff;
}

.message.assistant {
  margin-right: 12%;
}

.ask,
.panel {
  display: grid;
  gap: 10px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

textarea {
  resize: vertical;
}

#difyFrame {
  width: 100%;
  height: 66vh;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: none;
  padding: 12px;
  border-radius: 8px;
  background: #15191f;
  color: #fff;
}

.toast.show {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101318;
    --panel: #181d24;
    --text: #f2f5f8;
    --muted: #9aa4b2;
    --line: #2a323d;
    --brand: #3b8cff;
  }
}
