:root {
  --bg: #0a0e16;
  --panel: #121a28;
  --panel-2: #16202f;
  --card: #18222f;
  --line: #253043;
  --line-soft: #1d2635;
  --txt: #e9eef7;
  --muted: #8a97ac;
  --accent: #5b9dff;
  --accent-2: #35d0c0;
  --danger: #ff6b6b;
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

/* hidden 属性优先级必须高于各组件自身的 display 设置 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--txt);
  font: 14px/1.6 "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

/* ---------- 背景装饰 ---------- */
.bg { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.blob { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .35; }
.blob.a { width: 520px; height: 520px; left: -140px; top: -180px; background: #2a6bd8; }
.blob.b { width: 460px; height: 460px; right: -120px; bottom: -160px; background: #1f8f86; }

/* ---------- 布局 ---------- */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 292px 1fr;
  gap: 16px;
  height: 100vh;
  padding: 16px;
}

.side, .main {
  background: linear-gradient(180deg, rgba(24, 34, 47, .92), rgba(18, 26, 40, .92));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 0;
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
}

/* ---------- 侧栏 ---------- */
.side-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--line-soft); }
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.brand-dot {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px rgba(91, 157, 255, .35);
}
.brand-name { font-weight: 700; letter-spacing: .2px; }
.brand-sub { font-size: 12px; color: var(--muted); }

.side-filter { padding: 12px 16px 8px; }
.side-filter input { width: 100%; }

.mb-list {
  list-style: none; margin: 0; padding: 6px 10px 10px;
  flex: 1; min-height: 0; overflow-y: auto;
}
.mb {
  padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid transparent; margin-bottom: 4px; transition: background .15s, border-color .15s;
}
.mb:hover { background: var(--panel-2); }
.mb.active { background: #1c2a40; border-color: #2f4770; }
.mb-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mb-prefix { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: #06101f; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.mb-sub { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 12px; }
.tag {
  font-size: 11px; padding: 1px 7px; border-radius: 999px;
  background: #22314a; color: #a9c3ea; border: 1px solid #2c3f5e;
}
.tag.alt { background: #1d3a35; color: #86dfd1; border-color: #27564f; }
.mb-empty { padding: 22px 12px; color: var(--muted); font-size: 13px; text-align: center; }

.side-foot { padding: 12px 16px 16px; border-top: 1px solid var(--line-soft); display: grid; gap: 10px; }

/* ---------- 主区头部 ---------- */
.main-head {
  padding: 16px 18px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.main-title h1 { margin: 0; font-size: 19px; font-weight: 700; }
.main-title p { margin: 4px 0 0; font-size: 12.5px; }
.main-acts { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 列表 + 详情 ---------- */
.split {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 340px 1fr;
}
.list-pane { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line-soft); }
.list-head { padding: 10px 16px; font-size: 12px; border-bottom: 1px solid var(--line-soft); }
.mail-list { list-style: none; margin: 0; padding: 6px; flex: 1; min-height: 0; overflow-y: auto; }
.mail-item {
  padding: 11px 12px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid transparent; margin-bottom: 4px;
}
.mail-item:hover { background: var(--panel-2); }
.mail-item.active { background: #1c2a40; border-color: #2f4770; }
.mail-item.unread .mi-from { color: #fff; }
.mail-item.unread .mi-subject { color: var(--txt); font-weight: 600; }
.mi-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.mi-from { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi-time { flex: none; font-size: 11.5px; color: var(--muted); }
.mi-subject { font-size: 13px; color: #c3cee0; margin: 2px 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi-meta { display: flex; align-items: center; gap: 8px; font-size: 11.5px; }
.mi-meta .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-empty { padding: 24px 12px; text-align: center; color: var(--muted); }

.view-pane { min-height: 0; overflow-y: auto; padding: 20px 22px 26px; }
.empty { display: grid; place-items: center; height: 100%; color: var(--muted); }

.view-subject { margin: 0 0 12px; font-size: 18px; line-height: 1.45; word-break: break-word; }
.view-meta { display: grid; gap: 5px; padding-bottom: 14px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.vm-row { display: flex; gap: 10px; }
.vm-k { flex: none; width: 68px; color: var(--muted); }

.attach-box { margin: 14px 0 0; padding: 12px 14px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.attach-title { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.attach { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; }
.attach-name { font-weight: 600; font-size: 13px; word-break: break-all; }

.view-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 16px 0 12px; flex-wrap: wrap; }
.view-body { min-height: 0; }
.mail-text {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font-family: inherit; font-size: 14px; line-height: 1.75; color: #dbe4f2;
  background: #0e1520; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 14px 16px;
}
.mail-html { width: 100%; min-height: 480px; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); background: #fff; }

/* ---------- 分段控件 / 按钮 / 表单 ---------- */
.seg { display: inline-flex; padding: 3px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; }
.seg-btn {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12.5px;
  padding: 5px 14px; border-radius: 999px; cursor: pointer;
}
.seg-btn.active { background: #24344c; color: var(--txt); }

.btn {
  font: inherit; font-size: 13px; padding: 7px 14px; border-radius: 9px; cursor: pointer;
  background: var(--panel-2); color: var(--txt); border: 1px solid var(--line);
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: #1e2a3c; }
.btn.sm { padding: 5px 11px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #3f7fe0); border-color: transparent; color: #04101f; font-weight: 700; }
.btn.primary:hover { opacity: .9; }
.btn.danger { color: #ffc0c0; border-color: #4a2733; background: #291a20; }
.btn.danger:hover { background: #331f27; }
.btn:disabled { opacity: .55; cursor: default; }

input[type="text"], input[type="search"], input[type="password"], input, select, textarea {
  width: 100%; font: inherit; color: var(--txt); background: #0e1520;
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; outline: none;
}
input:focus { border-color: #3a68ad; box-shadow: 0 0 0 3px rgba(91, 157, 255, .13); }
input::placeholder { color: #5c6b81; }

.field { display: grid; gap: 7px; margin-bottom: 14px; }
.field label { font-size: 12.5px; color: var(--muted); }
.input-suffix { display: flex; align-items: center; gap: 8px; }
.input-suffix input { flex: 1; }
.input-suffix span { flex: none; color: var(--muted); font-size: 13px; }

.msg { margin: 0 0 12px; font-size: 12.5px; color: #ffb4b4; }

/* ---------- 弹窗 / 提示 ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(5, 9, 16, .68); backdrop-filter: blur(4px); padding: 20px; }
.modal-card {
  width: min(420px, 100%); background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
}
.modal-card h3 { margin: 0 0 16px; font-size: 16px; }
.modal-acts { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 60;
  background: #1d2a3f; border: 1px solid #33486a; color: var(--txt);
  padding: 9px 18px; border-radius: 999px; font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #2b3a52; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #3a4f70; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 窄屏 ---------- */
@media (max-width: 900px) {
  body { overflow: auto; }
  .app { grid-template-columns: 1fr; height: auto; }
  .side { max-height: 46vh; }
  .split { grid-template-columns: 1fr; }
  .list-pane { border-right: 0; border-bottom: 1px solid var(--line-soft); max-height: 46vh; }
}
