:root {
  --bg: #f2efe8;
  --ink: #171511;
  --muted: #5f584f;
  --line: #d9d2c6;
  --card: #fffcf7;
  --accent: #0d5c4a;
  --accent-2: #c45c26;
  --danger: #8a2f1d;
  --ok: #1f6b4a;
  --shadow: 0 14px 40px rgba(23, 21, 17, 0.07);
  --radius: 16px;
  --font: "Segoe UI", "IBM Plex Sans", "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 8% -8%, #d7ebe3 0%, transparent 55%),
    radial-gradient(700px 380px at 100% 0%, #f3e1d4 0%, transparent 45%),
    linear-gradient(180deg, #efebe3, var(--bg));
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video { max-width: 100%; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .85rem 1.1rem; position: sticky; top: 0; z-index: 20;
  background: rgba(255,252,247,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex; align-items: center; gap: .45rem;
  font-weight: 780; letter-spacing: .01em; color: var(--ink); font-size: 1.05rem;
  text-decoration: none;
}
.brand:hover { text-decoration: none; opacity: .92; }
.brand span { color: var(--accent); }
.brand-logo {
  height: 42px; width: auto; max-width: min(240px, 52vw);
  display: block; object-fit: contain;
}
.brand-icon { display: none; height: 36px; width: 36px; border-radius: 9px; object-fit: cover; }
.brand-mark-text { display: none; }
@media (max-width: 520px) {
  .brand-logo { display: none; }
  .brand-icon { display: block; }
  .brand-mark-text { display: inline; font-weight: 780; }
}
.nav { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; font-size: .92rem; }
.nav a.active { color: var(--ink); font-weight: 700; }

.wrap { width: min(1120px, calc(100% - 1.5rem)); margin: 0 auto; padding: 1.1rem 0 2.5rem; }
.wrap-wide { width: min(1280px, calc(100% - 1.2rem)); margin: 0 auto; padding: 1rem 0 2rem; }

.hero {
  padding: 2.2rem 0 1.4rem;
  display: grid; gap: 1.2rem;
}
.hero h1 {
  font-size: clamp(1.8rem, 5vw, 2.7rem);
  line-height: 1.08; margin: 0; letter-spacing: -.02em; max-width: 14ch;
}
.hero .lead { color: var(--muted); font-size: 1.05rem; margin: 0; max-width: 34ch; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; box-shadow: var(--shadow);
}
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; margin-top: 1.2rem; }
.steps .card h3 { margin: 0 0 .25rem; font-size: 1rem; }
.steps .card p { margin: 0; color: var(--muted); font-size: .9rem; }

.stack { display: grid; gap: .65rem; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.mono { font-family: var(--mono); }

label { display: grid; gap: .28rem; font-size: .84rem; color: var(--muted); }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: .65rem .75rem; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
.file-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.file-row label.file {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .45rem .7rem; border: 1px dashed var(--line); border-radius: 999px;
  background: #fff; cursor: pointer; color: var(--ink); font-size: .86rem;
}
.file-row input[type=file] { display: none; }

.btn, button, input[type=submit] {
  appearance: none; border: 0; background: var(--accent); color: #fff;
  border-radius: 999px; padding: .62rem 1.05rem; font-weight: 700; cursor: pointer;
  font: inherit; display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
}
.btn.secondary, button.secondary { background: #2b2823; }
.btn.ghost, button.ghost {
  background: transparent; color: var(--accent); border: 1px solid var(--line);
}
.btn.warn { background: var(--accent-2); }
.btn.block { width: 100%; }

.flash { list-style: none; padding: 0; margin: 0 0 1rem; }
.flash li { padding: .6rem .8rem; border-radius: 12px; background: #e7f3ef; margin-bottom: .35rem; }
.flash li.error, .flash li.误差 { background: #f8e6e1; color: var(--danger); }

.tag {
  display: inline-block; padding: .15rem .5rem; border-radius: 999px;
  background: #e7efeb; font-size: .75rem; font-weight: 700;
}
.tag.warn { background: #f6e4d8; color: var(--accent-2); }
.tag.ok { background: #dff0e7; color: var(--ok); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .7rem; }
.stat { text-align: left; }
.stat .n { font-size: 1.6rem; font-weight: 780; line-height: 1; }
.stat .l { color: var(--muted); font-size: .8rem; margin-top: .25rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .55rem .4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.tabs { display: flex; gap: .35rem; flex-wrap: wrap; margin: .8rem 0; }
.tabs a {
  padding: .4rem .75rem; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); background: #fff;
}
.tabs a.active { background: var(--ink); color: #fff; border-color: var(--ink); text-decoration: none; }

/* Messenger */
.messenger {
  display: grid; grid-template-columns: 320px 1fr; gap: 0;
  min-height: 70vh; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; background: var(--card); box-shadow: var(--shadow);
}
.conv-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 70vh; }
.conv-list .search { padding: .75rem; border-bottom: 1px solid var(--line); }
.conv-item {
  display: block; padding: .75rem .85rem; border-bottom: 1px solid var(--line);
  color: inherit; text-decoration: none;
}
.conv-item:hover, .conv-item.active { background: #f3f7f5; text-decoration: none; }
.conv-item .top { display: flex; justify-content: space-between; gap: .5rem; padding: 0; border: 0; background: transparent; position: static; }
.conv-item .preview { color: var(--muted); font-size: .84rem; margin-top: .2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  min-width: 1.2rem; height: 1.2rem; border-radius: 999px; background: var(--accent-2);
  color: #fff; font-size: .72rem; display: inline-flex; align-items: center; justify-content: center;
  padding: 0 .3rem; font-weight: 700;
}
.thread { display: flex; flex-direction: column; min-height: 70vh; }
.thread-head { padding: .85rem 1rem; border-bottom: 1px solid var(--line); }
.thread-body { flex: 1; padding: 1rem; overflow-y: auto; display: grid; gap: .65rem; align-content: start; background: #f7f4ee; }
.bubble {
  max-width: min(520px, 92%); padding: .7rem .85rem; border-radius: 16px;
  background: #fff; border: 1px solid var(--line); justify-self: start;
}
.bubble.out { justify-self: end; background: #e7f1ee; border-color: #cfe0da; }
.bubble .meta { font-size: .75rem; color: var(--muted); margin-top: .35rem; }
.attach { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.attach a {
  display: inline-block; padding: .35rem .55rem; border-radius: 10px;
  background: #fff; border: 1px solid var(--line); font-size: .82rem;
}
.thread-compose { padding: .75rem; border-top: 1px solid var(--line); background: var(--card); }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(23,21,17,.45); z-index: 40;
  display: none; align-items: flex-end; justify-content: center; padding: 1rem;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: min(520px, 100%); background: var(--card); border-radius: 18px;
  padding: 1rem; border: 1px solid var(--line); box-shadow: var(--shadow);
  max-height: 85vh; overflow: auto;
}

.grid-2 { display: grid; grid-template-columns: 1.4fr .8fr; gap: 1rem; }
.toolbar { display: flex; justify-content: space-between; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: .8rem; }

@media (max-width: 900px) {
  .steps { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .messenger { grid-template-columns: 1fr; min-height: auto; }
  .conv-list { min-height: auto; max-height: 40vh; overflow: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .thread { min-height: 55vh; }
  .grid-2 { grid-template-columns: 1fr; }
  .nav { font-size: .82rem; gap: .55rem; }
}
