:root {
  --gm-indigo: #4f46e5;
  --gm-blue: #2563eb;        /* primary now leans blue (no violet) */
  --gm-teal: #14b8a6;        /* secondary accent */
  --gm-teal-d: #0f9488;
  --gm-grad: linear-gradient(135deg, #4f46e5 0%, #2563eb 100%);
  --gm-grad-deep: linear-gradient(160deg, #312e81 0%, #3730a3 50%, #1d4ed8 100%);

  /* coloured surfaces — clearly cool, deliberately NOT white */
  --gm-bg: #dfe6f5;          /* page: distinct cool blue-grey */
  --gm-surface: #eef2fb;     /* cards: light but not white */
  --gm-surface-2: #e3e9f7;   /* nested blocks */
  --gm-input: #f3f6fc;
  --gm-border: #cdd6ee;
  --gm-text: #1e2138;
  --gm-muted: #64698c;
  --gm-radius: 16px;
  --gm-shadow: 0 14px 40px rgba(30, 58, 138, 0.16);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", Roboto, sans-serif;
  background: linear-gradient(170deg, #dfe6f5 0%, #d6e0f1 60%, #dde6f4 100%);
  background-attachment: fixed;
  color: var(--gm-text);
  min-height: 100vh;
}

/* ---------- top bar (shared) ---------- */
.gm-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 28px;
  background: var(--gm-grad-deep);
  color: #fff;
  box-shadow: 0 6px 24px rgba(67, 56, 202, 0.28);
  position: sticky;
  top: 0;
  z-index: 50;
}
.gm-brand { display: flex; align-items: center; gap: 11px; }
.gm-brand .gm-logo { height: 34px; width: auto; display: block; }
.gm-brand .name { font-size: 19px; font-weight: 800; letter-spacing: -0.2px; color: #fff; }
.gm-brand .name small { font-weight: 500; color: rgba(255,255,255,0.78); font-size: 13px; margin-left: 6px; }

.gm-topbar-right { display: flex; align-items: center; gap: 12px; }
.gm-lang {
  border: 1px solid rgba(255,255,255,0.45); background: rgba(255,255,255,0.12); color: #fff;
  border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.gm-lang:hover { background: rgba(255,255,255,0.24); }
.gm-user {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #2dd4bf, #14b8a6); color: #04302b; font-weight: 800;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.18);
}

/* ---------- landing ---------- */
.gm-hero {
  background: var(--gm-grad-deep);
  color: #fff;
  padding: 58px 24px 96px;
  text-align: center;
  position: relative;
}
.gm-hero::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 40px;
  background: radial-gradient(120% 100% at 50% 0%, transparent 60%, var(--gm-bg) 61%);
}
.gm-hero h1 { font-size: 42px; margin: 0 0 10px; font-weight: 800; letter-spacing: -1px; }
.gm-hero p { font-size: 18px; opacity: 0.92; margin: 0; font-weight: 300; }

.gm-landing-grid {
  max-width: 1040px;
  margin: -66px auto 40px;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 24px;
  align-items: start;
  position: relative;
  z-index: 1;
}
@media (max-width: 920px) { .gm-landing-grid { grid-template-columns: 1fr; } }

.gm-card {
  background: var(--gm-surface);
  border: 1px solid var(--gm-border);
  border-radius: var(--gm-radius);
  box-shadow: var(--gm-shadow);
  padding: 28px;
}
.gm-card h2 { margin: 0 0 18px; font-size: 20px; }

.gm-feature { display: flex; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--gm-border); }
.gm-feature:last-child { border-bottom: none; }
.gm-feature .ic {
  flex: 0 0 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, #dbeafe, #e0e7ff); color: var(--gm-indigo);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.gm-feature:nth-child(odd) .ic { background: linear-gradient(135deg, #cffafe, #d1fae5); color: var(--gm-teal-d); }
.gm-feature .ft strong { display: block; margin-bottom: 3px; font-size: 15px; }
.gm-feature .ft span { color: var(--gm-muted); font-size: 13.5px; line-height: 1.5; }

/* ---------- forms ---------- */
.gm-field { margin-bottom: 16px; }
.gm-field label { display: block; font-size: 13px; font-weight: 600; color: var(--gm-muted); margin-bottom: 6px; }
.gm-input, .gm-select, .gm-textarea {
  width: 100%; border: 1.5px solid var(--gm-border); border-radius: 10px;
  padding: 11px 13px; font-size: 14px; font-family: inherit; background: var(--gm-input);
  color: var(--gm-text); transition: border-color .2s, box-shadow .2s;
}
.gm-input:focus, .gm-select:focus, .gm-textarea:focus {
  outline: none; border-color: var(--gm-indigo); box-shadow: 0 0 0 3px rgba(99,102,241,0.18);
}
.gm-textarea { resize: vertical; }

.gm-btn {
  width: 100%; border: none; border-radius: 10px; padding: 12px 18px;
  background: var(--gm-grad); color: #fff; font-size: 15px; font-weight: 700; cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.gm-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(79,70,229,.34); }
.gm-btn:disabled { opacity: .6; cursor: default; transform: none; box-shadow: none; }
.gm-btn.secondary { background: linear-gradient(135deg, #2dd4bf, #14b8a6); }

.gm-row-between { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 16px; }
.gm-link { color: var(--gm-indigo); text-decoration: none; font-weight: 600; }
.gm-link:hover { text-decoration: underline; }

.gm-msg { display: none; padding: 11px 13px; border-radius: 10px; margin-bottom: 14px; font-size: 13.5px; }
.gm-msg.error { display: block; color: #b91c1c; background: #fee2e2; }
.gm-msg.ok { display: block; color: #0f766e; background: #ccfbf1; }

/* ---------- app shell ---------- */
/* minmax(0,1fr) (not 1fr) lets the content track shrink to the viewport instead of growing to
   fit a wide child (e.g. a long <pre> line) — without it the page overflows horizontally. */
.gm-app { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: calc(100vh - 60px); }
@media (max-width: 820px) { .gm-app { grid-template-columns: minmax(0, 1fr); } }

.gm-side {
  background: var(--gm-grad-deep);
  color: #fff;
  padding: 22px 20px;
}
.gm-side .gm-label { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: rgba(255,255,255,0.72); margin: 0 0 8px; }
.gm-side .gm-select {
  background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.3); color: #fff;
}
.gm-side .gm-select option { color: #1e2138; }
.gm-guide-meta { margin-top: 14px; font-size: 13px; color: rgba(255,255,255,0.78); line-height: 1.6; }

.gm-nav { margin-top: 24px; display: flex; flex-direction: column; gap: 4px; }
.gm-nav button {
  text-align: left; border: none; background: none; padding: 11px 13px; border-radius: 10px;
  font-size: 14px; font-weight: 600; color: rgba(255,255,255,0.85); cursor: pointer;
}
.gm-nav button:hover { background: rgba(255,255,255,0.12); color: #fff; }
.gm-nav button.active { background: rgba(255,255,255,0.20); color: #fff; }

/* Fill the whole content track (no max-width cap) so the main area uses ~full width with only
   the 30px padding as gutter. width:100% + min-width:0 keep it filling without overflow under
   the minmax(0,1fr) track above. */
.gm-content { padding: 30px; width: 100%; min-width: 0; }
.gm-panel-block { display: none; }
.gm-panel-block.active { display: block; }

.gm-h { font-size: 23px; font-weight: 800; margin: 0 0 4px; }
.gm-sub { color: var(--gm-muted); font-size: 14px; margin: 0 0 22px; }

/* cards inside content so it isn't a flat white field */
#panel-analyze, #panel-knowledge, #panel-cases { background: var(--gm-surface); border: 1px solid var(--gm-border); border-radius: var(--gm-radius); padding: 26px; box-shadow: var(--gm-shadow); }

/* ---------- cases panel ---------- */
.gm-case-create { display: flex; gap: 10px; margin-bottom: 14px; }
.gm-case-create .gm-input { flex: 1; }
.gm-case-create .gm-btn { width: auto; white-space: nowrap; padding: 11px 18px; }

.gm-case-list { display: flex; flex-direction: column; gap: 8px; }
.gm-case-item { display: flex; align-items: stretch; gap: 6px; background: var(--gm-surface-2);
  border: 1px solid var(--gm-border); border-radius: 10px; overflow: hidden; }
.gm-case-item.active { border-color: var(--gm-indigo); box-shadow: 0 0 0 2px rgba(99,102,241,0.18); }
.gm-case-open { flex: 1; text-align: left; border: none; background: none; cursor: pointer;
  padding: 11px 14px; display: flex; flex-direction: column; gap: 2px; }
.gm-case-name { font-weight: 700; font-size: 14.5px; color: var(--gm-text); }
.gm-case-meta { font-size: 12.5px; color: var(--gm-muted); }
.gm-case-open:hover .gm-case-name { color: var(--gm-indigo); }
.gm-case-del { border: none; background: none; color: var(--gm-muted); cursor: pointer;
  padding: 0 14px; font-size: 14px; }
.gm-case-del:hover { color: #b91c1c; background: #fee2e2; }

.gm-workspace { margin-top: 22px; border-top: 1px solid var(--gm-border); padding-top: 18px; }
.gm-h2 { font-size: 18px; font-weight: 800; margin: 0 0 14px; }
.gm-ws-section { margin-bottom: 22px; }
.gm-ws-h { font-size: 14px; font-weight: 700; color: var(--gm-muted); text-transform: uppercase;
  letter-spacing: .4px; margin: 0 0 10px; }

.gm-upload-row { display: flex; gap: 10px; align-items: center; }
.gm-file { flex: 1; font-size: 13px; }
.gm-upload-row .gm-btn { width: auto; white-space: nowrap; padding: 10px 16px; }

.gm-paste-row { display: flex; gap: 10px; align-items: flex-end; margin-top: 12px; }
.gm-paste-row .gm-textarea { flex: 1; }
.gm-paste-row .gm-btn { width: auto; white-space: nowrap; padding: 11px 16px; }

.gm-doc-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.gm-doc-item { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--gm-surface-2); border: 1px solid var(--gm-border); border-radius: 9px; padding: 9px 13px; }
.gm-doc-name { font-size: 14px; word-break: break-all; }
.gm-doc-actions { display: flex; gap: 12px; align-items: center; flex: 0 0 auto; }
.gm-doc-del { border: none; background: none; color: #b91c1c; cursor: pointer; font-size: 13px; font-weight: 600; }
.gm-doc-del:hover { text-decoration: underline; }
.gm-doc-empty { color: var(--gm-muted); font-size: 13.5px; list-style: none; }

.gm-chat { background: var(--gm-surface-2); border: 1px solid var(--gm-border); border-radius: 10px;
  padding: 14px; min-height: 160px; max-height: 420px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px; }
.gm-chat-empty { color: var(--gm-muted); font-size: 13.5px; margin: auto; }
.gm-bubble { max-width: 82%; padding: 9px 13px; border-radius: 12px; font-size: 14px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word; }
.gm-bubble.user { align-self: flex-end; background: var(--gm-grad); color: #fff; border-bottom-right-radius: 4px; }
.gm-bubble.ai { align-self: flex-start; background: #fff; border: 1px solid var(--gm-border);
  color: var(--gm-text); border-bottom-left-radius: 4px; }
.gm-chat-input { display: flex; gap: 10px; margin-top: 12px; align-items: flex-end; }
.gm-chat-input .gm-textarea { flex: 1; }
.gm-chat-input .gm-btn { width: auto; white-space: nowrap; padding: 11px 20px; }

.gm-analysis-history { margin-top: 6px; }
.gm-analysis-history .gm-result { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--gm-border); }
.gm-analysis-history .gm-result:first-child { border-top: none; }
.gm-result-ts { float: right; font-size: 12px; font-weight: 600; color: var(--gm-muted); }
.gm-result { margin-top: 22px; }
.gm-result-headline { font-size: 17px; font-weight: 800; color: var(--gm-teal-d); margin: 0 0 12px;
  background: #ccfbf1; padding: 12px 14px; border-radius: 10px; border-left: 4px solid var(--gm-teal); }
.gm-result details { margin: 8px 0; border: 1px solid var(--gm-border); border-radius: 10px; padding: 8px 12px; background: var(--gm-surface-2); }
.gm-result summary { cursor: pointer; font-weight: 600; color: var(--gm-muted); }
.gm-pre { white-space: pre-wrap; background: var(--gm-surface-2); border: 1px solid var(--gm-border); border-radius: 8px; padding: 12px; font-size: 13px; overflow-x: auto; }
.gm-review { white-space: pre-wrap; font-size: 14px; line-height: 1.6; }

.gm-hint { font-size: 12.5px; color: var(--gm-muted); margin-top: 6px; }
.gm-saved { color: #0f766e; font-weight: 600; font-size: 13px; margin-left: 10px; display: none; }
.gm-saved.show { display: inline; }

.gm-footer { text-align: center; color: var(--gm-muted); font-size: 13px; padding: 28px; }
