:root {
  --ink: #1c2430;
  --muted: #5b6573;
  --paper: #f3efe6;
  --panel: rgba(255, 252, 246, 0.92);
  --line: #d5cbb8;
  --accent: #0f6a5a;
  --accent-2: #c45c26;
  --danger: #9b2c2c;
  --shadow: 0 18px 50px rgba(28, 36, 48, 0.12);
  --font-display: "ZCOOL XiaoWei", "Noto Serif SC", serif;
  --font-body: "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #d9e7e2 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #f0d9c8 0%, transparent 50%),
    linear-gradient(160deg, #efe8da, #e4ebe7 45%, #ebe4d6);
}

button,
input,
textarea,
select {
  font: inherit;
}

.hidden {
  display: none !important;
}

.disconnect {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #7a2e2e;
  color: #fff;
  text-align: center;
  padding: 0.55rem 1rem;
}

.join-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  position: relative;
  overflow: hidden;
}

.join-bg {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(15, 106, 90, 0.18), transparent 40%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 40 40'%3E%3Cg fill='%230f6a5a' fill-opacity='0.05'%3E%3Cpath d='M0 40L40 0H20L0 20M40 40V20L20 40'/%3E%3C/g%3E%3C/svg%3E");
  animation: drift 18s linear infinite;
}

@keyframes drift {
  from {
    background-position: 0 0, 0 0;
  }
  to {
    background-position: 0 0, 160px 80px;
  }
}

.join-panel {
  position: relative;
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 2rem 1.5rem 1.5rem;
  backdrop-filter: blur(8px);
  animation: rise 0.55s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.brand {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 6vw, 3.2rem);
  margin: 0 0 0.35rem;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.join-panel h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 500;
}

.lead {
  color: var(--muted);
  margin: 0.4rem 0 1.2rem;
  line-height: 1.5;
}

label {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  font-size: 0.92rem;
}

input,
textarea,
select {
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 0.65rem 0.75rem;
  border-radius: 2px;
}

button {
  border: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.7rem 1rem;
  cursor: pointer;
  border-radius: 2px;
}

button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.error {
  color: var(--danger);
  margin: 0.75rem 0 0;
}

.ok {
  color: var(--accent);
  margin: 0.75rem 0 0;
}

.admin-foot {
  margin: 1.1rem 0 0;
  font-size: 0.9rem;
}

.admin-foot a {
  color: var(--muted);
}

.app-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.85);
  backdrop-filter: blur(6px);
}

.brand-inline {
  font-family: var(--font-display);
  font-size: 1.35rem;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.top-actions input[type="search"] {
  min-width: min(240px, 70vw);
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  min-height: 0;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(255, 252, 246, 0.7);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-head {
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.issue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  flex: 1;
}

.issue-list li {
  padding: 0.85rem 0.9rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.issue-list li.active,
.issue-list li:hover {
  background: rgba(15, 106, 90, 0.08);
}

.issue-list .meta {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.25rem;
}

.thread {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(255, 255, 255, 0.35);
}

.empty-thread {
  margin: auto;
  color: var(--muted);
}

.thread-head {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
}

.thread-head h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 500;
}

.messages {
  flex: 1;
  overflow: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.msg {
  max-width: 48rem;
  padding: 0.7rem 0.85rem;
  background: #fffdf8;
  border: 1px solid var(--line);
  animation: rise 0.25s ease both;
}

.msg .who {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.msg.status {
  background: transparent;
  border-style: dashed;
  color: var(--muted);
  font-size: 0.9rem;
}

.msg img {
  max-width: min(100%, 420px);
  display: block;
  margin-top: 0.4rem;
}

.composer {
  border-top: 1px solid var(--line);
  padding: 0.75rem;
  position: relative;
  background: rgba(255, 252, 246, 0.9);
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
}

.file-btn {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  cursor: pointer;
}

.mention-picker {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: calc(100% - 0.25rem);
  background: #fffdf8;
  border: 1px solid var(--line);
  max-height: 160px;
  overflow: auto;
  z-index: 5;
}

.mention-picker button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--ink);
  border-radius: 0;
}

.mention-picker button:hover {
  background: rgba(15, 106, 90, 0.08);
}

.search-results {
  border-top: 1px solid var(--line);
  padding: 0.75rem;
  font-size: 0.9rem;
  overflow: auto;
  max-height: 40%;
}

dialog {
  border: 1px solid var(--line);
  padding: 1rem;
  width: min(420px, 92vw);
  background: #fffdf8;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

@media (max-width: 800px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    max-height: 38vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}
