:root {
  --bg: #07111f;
  --card: rgba(248, 251, 255, 0.91);
  --card-strong: #ffffff;
  --primary: #0f766e;
  --primary-2: #2563eb;
  --accent: #f59e0b;
  --text: #0f172a;
  --muted: #64748b;
  --line: rgba(100, 116, 139, 0.2);
  --danger: #dc2626;
  --ok: #16a34a;
  --shadow: 0 24px 70px rgba(2, 6, 23, 0.25);
  --soft-shadow: 0 14px 34px rgba(15, 23, 42, 0.11);
  --radius-lg: 24px;
  --radius-md: 16px;
}

* { box-sizing: border-box; }

html,
body,
#app { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 7% 4%, rgba(20, 184, 166, 0.35), transparent 28%),
    radial-gradient(circle at 96% 12%, rgba(37, 99, 235, 0.3), transparent 28%),
    linear-gradient(135deg, #06131f 0%, #0f172a 58%, #092f35 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent 78%);
}

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

button {
  border: 0;
  border-radius: 13px;
  padding: 11px 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.18);
  transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
  white-space: nowrap;
}

button:hover { transform: translateY(-1px); filter: brightness(1.03); }
button:active { transform: translateY(0); }

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.92);
  color: var(--text);
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
  background: #fff;
}

textarea { min-height: 88px; resize: vertical; }
pre { margin: 0; white-space: pre-wrap; word-break: break-word; }
a { text-decoration: none; }
.hidden { display: none !important; }

.glass-card {
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.58);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
}

.login-card {
  width: min(560px, 100%);
  padding: 42px;
}

.brand {
  color: var(--primary);
  font-weight: 900;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
}

.brand.small { font-size: 15px; margin-bottom: 4px; }
.login-card h1 { margin: 0 0 12px; font-size: 34px; letter-spacing: -0.04em; }
.login-card p { color: var(--muted); line-height: 1.8; }
.login-form,
.user-form,
.announcement-form,
.upload-panel { display: grid; gap: 12px; }
.hint,
.muted { color: var(--muted); font-size: 13px; }
.form-message { min-height: 22px; color: var(--danger); font-size: 13px; }

.main-layout {
  height: 100vh;
  display: grid;
  grid-template-columns: 318px minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  overflow: hidden;
}

.sidebar {
  min-height: 0;
  padding: 16px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto minmax(120px, 1fr) auto;
  gap: 14px;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.ghost-btn {
  color: var(--primary);
  background: rgba(15,118,110,0.1);
  box-shadow: none;
}

.ghost-btn.subtle {
  padding: 8px 12px;
  color: var(--muted);
  background: rgba(100, 116, 139, 0.1);
}

.sidebar-nav {
  display: grid;
  gap: 9px;
}

.nav-btn {
  color: var(--text);
  background: rgba(255,255,255,0.68);
  box-shadow: none;
  text-align: left;
  border: 1px solid rgba(255,255,255,0.5);
}

.nav-btn.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 16px 28px rgba(37, 99, 235, 0.18);
}

.panel-section {
  min-height: 0;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  overflow: hidden;
}

.panel-section:first-of-type {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.section-title {
  font-weight: 900;
  margin-bottom: 10px;
  letter-spacing: -0.02em;
}

.user-list {
  min-height: 0;
  display: grid;
  gap: 8px;
  align-content: start;
  overflow: auto;
  padding-right: 3px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 14px;
  background: rgba(241,245,249,0.82);
}

.avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
}

.tips-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.85;
}

.content-area {
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
  overflow: hidden;
}

.topbar {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.topbar h2 { margin: 0; letter-spacing: -0.04em; }
.top-actions { display: flex; gap: 10px; align-items: center; min-width: min(430px, 45%); }
.top-actions input { min-width: 0; }
.top-actions button { flex: 0 0 auto; }

.tab-view {
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.grid-chat {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 16px;
}

.chat-column {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  position: relative;
}

.chat-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.84), rgba(241,245,249,0.72));
}

.chat-status-bar strong { margin-right: 8px; }
.chat-tools { display: flex; gap: 8px; align-items: center; }

.message-list {
  min-height: 0;
  padding: 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
  background:
    radial-gradient(circle at 18% 14%, rgba(15, 118, 110, 0.1), transparent 24%),
    radial-gradient(circle at 88% 70%, rgba(37, 99, 235, 0.08), transparent 28%);
}

.message {
  width: min(76%, 780px);
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  align-self: flex-start;
  animation: messageIn .18s ease both;
}

.message.mine {
  grid-template-columns: minmax(0, 1fr) 36px;
  align-self: flex-end;
}

.message-avatar {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.12);
}

.message.mine .message-avatar { grid-column: 2; grid-row: 1; }
.message-body { min-width: 0; }

.message-bubble {
  padding: 12px 14px;
  background: rgba(255,255,255,0.86);
  border: 1px solid rgba(255,255,255,0.78);
  border-radius: 8px 18px 18px 18px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.message.mine .message-bubble {
  color: #eff6ff;
  background: linear-gradient(135deg, #0f766e, #2563eb);
  border-color: rgba(255,255,255,0.18);
  border-radius: 18px 8px 18px 18px;
}

.message-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 7px;
}

.message.mine .message-meta { color: rgba(239,246,255,0.78); }
.message-actions { display: flex; gap: 6px; align-items: center; opacity: 0; transition: opacity .16s ease; }
.message:hover .message-actions { opacity: 1; }
.message-content { white-space: pre-wrap; line-height: 1.68; word-break: break-word; }

.chat-image {
  display: grid;
  gap: 8px;
}

.chat-image img {
  display: block;
  max-width: min(420px, 100%);
  max-height: 320px;
  object-fit: contain;
  border-radius: 14px;
  background: rgba(15,23,42,0.08);
  box-shadow: 0 10px 24px rgba(15,23,42,0.16);
}

.chat-image a {
  color: inherit;
  font-size: 12px;
  opacity: .82;
}

.image-fallback { display: none; font-size: 12px; opacity: .82; }
.image-load-failed img { display: none; }
.image-load-failed .image-fallback { display: inline; }
.inline-link { color: #2563eb; font-weight: 700; word-break: break-all; }
.message.mine .inline-link { color: #dbeafe; }

.date-divider {
  display: flex;
  justify-content: center;
  margin: 6px 0 2px;
}

.date-divider span {
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--line);
  font-size: 12px;
}

.message-action-btn {
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--primary);
  background: rgba(15, 118, 110, 0.1);
  box-shadow: none;
}

.message.mine .message-action-btn {
  color: #fff;
  background: rgba(255,255,255,0.16);
}

.command-block {
  background: #0f172a;
  color: #d1fae5;
  border-radius: 14px;
  padding: 12px;
  overflow-x: auto;
  margin-top: 8px;
  border: 1px solid rgba(147,197,253,0.22);
}

.message.mine .command-block { background: rgba(15, 23, 42, 0.92); }

.command-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  color: #93c5fd;
}

.copy-btn {
  padding: 6px 10px;
  border-radius: 9px;
  background: rgba(37,99,235,0.82);
}

.composer {
  border-top: 1px solid var(--line);
  padding: 12px;
  display: grid;
  gap: 10px;
  background: rgba(248, 250, 252, 0.86);
}

.composer-mode,
.composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.mode-pill,
.quick-replies button {
  color: var(--text);
  background: rgba(255,255,255,0.82);
  border: 1px solid var(--line);
  box-shadow: none;
}

.mode-pill {
  padding: 8px 12px;
  border-radius: 999px;
}

.mode-pill.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.composer textarea { min-height: 82px; max-height: 180px; }
.quick-replies { display: flex; gap: 8px; flex-wrap: wrap; }
.quick-replies button { padding: 7px 10px; border-radius: 999px; font-size: 13px; }
.composer-hint { color: var(--muted); font-size: 12px; }
.composer-actions button[type="submit"] { min-width: 120px; }
.composer-send-group { display: flex; gap: 8px; align-items: center; }

.image-drop-zone {
  display: grid;
  place-items: center;
  min-height: 74px;
  border: 1px dashed rgba(37,99,235,0.42);
  border-radius: 16px;
  color: var(--primary-2);
  background: rgba(37,99,235,0.08);
  font-weight: 800;
}

.composer.dragging .image-drop-zone { display: grid !important; }

@keyframes messageIn {
  from { opacity: 0; transform: translateY(6px) scale(.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.side-column {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.info-card {
  min-height: 0;
  padding: 16px;
  overflow: auto;
}

.files-layout {
  height: 100%;
  min-height: 0;
  padding: 16px;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  overflow: hidden;
}

.upload-panel {
  align-self: start;
  position: sticky;
  top: 0;
  padding: 16px;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.92), rgba(241,245,249,0.84)),
    radial-gradient(circle at top right, rgba(245, 158, 11, 0.18), transparent 42%);
  border: 1px solid rgba(255,255,255,0.78);
  box-shadow: var(--soft-shadow);
}

.upload-panel input[type="file"] {
  min-height: 48px;
  padding: 10px;
  background: #fff;
}

.file-browser {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.file-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 2px 4px 12px;
}

.file-list,
.command-list,
.announcement-list,
.log-list {
  min-height: 0;
  display: grid;
  gap: 10px;
  align-content: start;
  overflow: auto;
  padding: 2px 6px 8px 2px;
}

.file-list {
  grid-template-columns: repeat(auto-fill, minmax(265px, 1fr));
}

.file-item,
.announcement-item,
.command-item,
.log-item,
.stat-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,0.76);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
}

.file-item {
  display: grid;
  gap: 8px;
  align-content: start;
}

.file-title {
  font-weight: 900;
  word-break: break-all;
  line-height: 1.35;
}

.file-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.file-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.file-actions button { padding: 9px 13px; }
.danger-btn { background: var(--danger); }

.admin-grid {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  overflow: auto;
}

.admin-grid .glass-card { padding: 16px; }
.admin-log-card { grid-column: 1 / -1; min-height: 280px; }
.stats-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.stat-number { font-size: 28px; font-weight: 900; color: var(--primary); }

.message-list::-webkit-scrollbar,
.file-list::-webkit-scrollbar,
.user-list::-webkit-scrollbar,
.info-card::-webkit-scrollbar,
.command-list::-webkit-scrollbar,
.announcement-list::-webkit-scrollbar,
.log-list::-webkit-scrollbar,
.admin-grid::-webkit-scrollbar { width: 9px; }

.message-list::-webkit-scrollbar-thumb,
.file-list::-webkit-scrollbar-thumb,
.user-list::-webkit-scrollbar-thumb,
.info-card::-webkit-scrollbar-thumb,
.command-list::-webkit-scrollbar-thumb,
.announcement-list::-webkit-scrollbar-thumb,
.log-list::-webkit-scrollbar-thumb,
.admin-grid::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.35);
  border-radius: 999px;
}

@media (max-width: 1100px) {
  body { overflow: auto; }
  .main-layout {
    min-height: 100vh;
    height: auto;
    grid-template-columns: 1fr;
    overflow: visible;
  }
  .sidebar {
    grid-template-rows: auto auto auto auto;
    overflow: visible;
  }
  .content-area { overflow: visible; }
  .tab-view { min-height: 620px; overflow: visible; }
  .grid-chat,
  .files-layout,
  .admin-grid { grid-template-columns: 1fr; }
  .files-layout { overflow: visible; }
  .upload-panel { position: static; }
  .file-list { max-height: 58vh; }
  .side-column { grid-template-rows: auto auto; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 680px) {
  .main-layout { padding: 10px; gap: 10px; }
  .topbar,
  .chat-status-bar,
  .composer-actions { flex-direction: column; align-items: stretch; }
  .top-actions { min-width: 0; width: 100%; flex-direction: column; }
  .message { width: 96%; }
  .message-actions { opacity: 1; }
  .composer-mode,
  .composer-send-group { flex-wrap: wrap; }
  .composer-send-group button { flex: 1; }
  .login-card { padding: 26px; }
  .login-card h1 { font-size: 26px; }
  .file-toolbar { flex-direction: column; }
  .file-list { grid-template-columns: 1fr; }
}
