:root {
  color-scheme: light;
  --ink: #202428;
  --muted: #66727d;
  --line: #dce3e8;
  --paper: #f6f3ed;
  --panel: #fffdf9;
  --field: #ffffff;
  --accent: #2f6652;
  --accent-strong: #214d3e;
  --blue: #385f8d;
  --red: #9b4b46;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.home-shell {
  width: min(1120px, calc(100% - 24px));
  margin: 0 auto;
  padding: 18px 0 42px;
}

.home-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

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

.kicker,
.muted-line {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.kicker {
  color: var(--accent);
  font-weight: 850;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2.1rem;
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.15rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid rgba(56, 95, 141, 0.24);
  border-radius: 999px;
  padding: 0 11px;
  background: rgba(56, 95, 141, 0.08);
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill[data-state="ok"] {
  border-color: rgba(47, 102, 82, 0.28);
  background: rgba(47, 102, 82, 0.1);
  color: var(--accent-strong);
}

.status-pill[data-state="error"] {
  border-color: rgba(155, 75, 70, 0.28);
  background: rgba(155, 75, 70, 0.1);
  color: var(--red);
}

.login-panel,
.chat-panel {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.login-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 300px) auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--ink);
}

input {
  min-height: 42px;
  padding: 0 10px;
}

textarea {
  resize: vertical;
  padding: 11px;
  line-height: 1.55;
}

.primary-button,
.ghost-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 13px;
  font-weight: 850;
  white-space: nowrap;
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.84rem;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.ghost-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(112px, auto));
  gap: 12px;
  margin-top: 16px;
}

.module-card,
.ai-card {
  display: grid;
  align-content: center;
  gap: 10px;
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
  text-decoration: none;
}

.module-card strong,
.ai-card strong {
  display: block;
  font-size: 1.1rem;
}

.module-card span:last-child,
.ai-card span:last-child {
  color: var(--muted);
  font-size: 0.88rem;
}

.grid-code {
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 850;
}

.module-card[aria-disabled="true"] {
  opacity: 0.72;
}

.ai-card {
  grid-column: 2 / 4;
  grid-row: 2 / 4;
  background: #eef5ef;
  border-color: rgba(47, 102, 82, 0.28);
}

.ai-card strong {
  font-size: 1.7rem;
}

.chat-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.chat-head,
.chat-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.chat-log {
  display: grid;
  gap: 10px;
}

.chat-bubble {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  line-height: 1.65;
}

.chat-bubble.assistant {
  background: #f7faf8;
  border-color: rgba(47, 102, 82, 0.18);
}

@media (max-width: 760px) {
  .home-header,
  .chat-head,
  .chat-actions {
    display: grid;
  }

  .login-panel {
    grid-template-columns: 1fr;
  }

  .module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto;
  }

  .ai-card {
    grid-column: 1 / 3;
    grid-row: auto;
  }

  h1 {
    font-size: 1.8rem;
  }
}
