/* ISAS 邮箱 — brand tokens sampled from the company badge */
:root {
  --blue: #0e71ac;
  --navy: #0b2e52;
  --gold: #e1c65b;
  --gold-ink: #8c6a1f;
  --ink: #16202b;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f6f8fa;
  --card: #fff;
  --danger: #b42318;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(11, 46, 82, .08), 0 8px 24px rgba(11, 46, 82, .06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 14px; margin: 4px 0 0; }

/* ------------------------------------------------------------- login */
.screen { min-height: 100%; }
.center { display: flex; align-items: center; justify-content: center; padding: 24px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 24px; }
.login-card { width: 100%; max-width: 380px; }
.brand { font-size: 21px; margin: 0 0 2px; color: var(--navy); letter-spacing: .3px; }
.brand span { color: var(--blue); }
.login-card .muted { margin: 0 0 20px; font-size: 14px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
input[type=text], input[type=email], input[type=password], input[type=search], textarea {
  width: 100%; margin-top: 5px; padding: 10px 12px; font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
input:focus, textarea:focus { outline: 2px solid rgba(14, 113, 172, .35); border-color: var(--blue); }

/* ------------------------------------------------------------ buttons */
.btn {
  font: inherit; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer;
}
.btn:hover { border-color: #cbd5e1; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #0c649a; }
.btn.sm { padding: 6px 12px; font-size: 14px; }
.btn.block { width: 100%; margin-top: 6px; }
.btn.ghost { background: transparent; }
.btn.link { border: 0; color: var(--muted); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn {
  border: 0; background: transparent; font-size: 22px; line-height: 1; padding: 4px 10px;
  color: var(--navy); cursor: pointer;
}

/* ------------------------------------------------------------- shell */
#app { display: flex; flex-direction: column; height: 100%; }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--navy); color: #fff; padding-top: max(10px, env(safe-area-inset-top));
}
.topbar .icon-btn { color: #fff; }
.topbar-title { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 16px; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.badge {
  background: var(--gold); color: var(--gold-ink); font-size: 12px; font-weight: 700;
  border-radius: 999px; padding: 1px 8px;
}
.folders {
  display: flex; gap: 4px; padding: 8px 12px; background: #fff; border-bottom: 1px solid var(--line);
  overflow-x: auto; align-items: center;
}
.folder {
  border: 0; background: transparent; font: inherit; color: var(--muted);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.folder.active { background: rgba(14, 113, 172, .1); color: var(--blue); font-weight: 600; }
#search { max-width: 240px; margin-left: auto; }

.panes { flex: 1; display: flex; min-height: 0; }
.pane { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.list-pane { width: 380px; border-right: 1px solid var(--line); background: #fff; }
.detail-pane { flex: 1; background: #fff; }

/* -------------------------------------------------------------- list */
.msg-list { list-style: none; margin: 0; padding: 0; }
.msg-item { padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.msg-item:hover { background: #f8fafc; }
.msg-item.active { background: rgba(14, 113, 172, .07); }
.msg-item .row1 { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.msg-item .who { font-weight: 600; color: var(--navy); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-item .when { font-size: 12px; color: var(--muted); flex: none; }
.msg-item .subject { margin: 2px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-item .snippet { margin: 2px 0 0; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-item.unread .who::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--blue); margin-right: 6px; vertical-align: middle;
}
.msg-item.unread .subject { font-weight: 600; }
.clip { font-size: 12px; color: var(--muted); }
.empty, .placeholder { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ------------------------------------------------------------ detail */
.detail { padding: 18px 20px 40px; }
.detail h2 { margin: 0 0 12px; font-size: 19px; color: var(--navy); }
.detail-meta { font-size: 13px; color: var(--ink); display: grid; gap: 3px; margin-bottom: 12px; }
.detail-meta .k { color: var(--muted); margin-right: 6px; }
.auth { font-size: 12px; color: var(--muted); margin-left: 8px; }
.auth.bad { color: var(--danger); }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.attachments { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.attachments a {
  display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px;
  text-decoration: none; color: var(--blue); font-size: 14px; background: #fff;
}
.body-frame { width: 100%; min-height: 55vh; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

/* ----------------------------------------------------------- compose */
dialog {
  border: 0; border-radius: 12px; padding: 0; width: min(680px, 96vw);
  box-shadow: 0 24px 60px rgba(11, 46, 82, .28);
}
dialog::backdrop { background: rgba(11, 46, 82, .35); }
#compose-form { padding: 18px 20px 16px; }
.compose-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
#c-text { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; resize: vertical; }
.file-label { margin-top: 12px; }
.compose-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; gap: 12px; }

/* ------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; box-shadow: var(--shadow); z-index: 99;
}

.only-mobile { display: none; }

/* The `hidden` attribute is a UA-level display:none — any author `display` rule
   (e.g. .only-mobile below) silently beats it. Make it win everywhere. */
[hidden] { display: none !important; }

.menu-pop {
  position: absolute; top: 52px; right: 12px; background: #fff; border-radius: 10px;
  box-shadow: var(--shadow); padding: 6px; z-index: 50; display: flex; flex-direction: column; min-width: 150px;
}
.menu-pop button {
  border: 0; background: transparent; font: inherit; text-align: left; padding: 10px 14px;
  border-radius: 8px; cursor: pointer; color: var(--ink);
}
.menu-pop button:hover { background: #f1f5f9; }
.menu-pop .who { padding: 8px 14px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }

/* ------------------------------------------------------------ mobile */
@media (max-width: 760px) {
  .only-mobile { display: inline-block; }
  .list-pane { width: 100%; border-right: 0; }
  .detail-pane { display: none; }
  body.viewing .list-pane { display: none; }
  body.viewing .detail-pane { display: block; }
  #search { max-width: 150px; }
  .body-frame { min-height: 60vh; }
}
