* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.4 system-ui, Segoe UI, Roboto, sans-serif; color: #202124; background: #f6f8fc; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; border: 1px solid #dadce0; background: #fff; border-radius: 18px; padding: 6px 14px; }
button.primary { background: #0b57d0; color: #fff; border-color: #0b57d0; }
input, textarea { font: inherit; width: 100%; padding: 9px 10px; border: 1px solid #dadce0; border-radius: 6px; margin-bottom: 8px; }
.err { color: #b3261e; min-height: 1em; margin: 4px 0 0; }

#login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
#loginForm { background: #fff; padding: 28px; border-radius: 12px; width: 100%; max-width: 360px; box-shadow: 0 1px 4px #0002; }
#loginForm h1 { font-size: 20px; margin: 0 0 16px; }

#app { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: 56px 1fr; height: 100vh; }
header { grid-column: 1 / 3; display: flex; align-items: center; gap: 12px; padding: 0 16px; }
header form { flex: 1; max-width: 640px; }
header input { margin: 0; border-radius: 24px; background: #eaf1fb; border-color: transparent; }
#menuBtn { display: none; border: 0; background: none; font-size: 20px; padding: 0; }
nav { padding: 8px 12px; overflow: auto; }
nav .primary { width: 100%; padding: 12px; border-radius: 16px; margin-bottom: 12px; }
nav ul { list-style: none; margin: 0; padding: 0; }
nav li { display: flex; justify-content: space-between; padding: 7px 14px; border-radius: 0 16px 16px 0; cursor: pointer; }
nav li.active { background: #d3e3fd; font-weight: 600; }
nav li .n { font-size: 12px; }
main { background: #fff; border-radius: 16px 0 0 0; overflow: auto; }

#msgList { list-style: none; margin: 0; padding: 0; }
#msgList li { display: grid; grid-template-columns: 28px 180px 1fr auto; gap: 8px; align-items: center; padding: 8px 16px; border-bottom: 1px solid #eee; cursor: pointer; }
#msgList li:hover { box-shadow: inset 0 0 0 1px #dadce0, 0 1px 3px #0002; }
#msgList li.unread { font-weight: 700; background: #fff; }
#msgList li:not(.unread) { background: #f6f8fc; }
#msgList .sn, #msgList .sub { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#msgList .snip { font-weight: 400; color: #5f6368; }
.star { border: 0; background: none; padding: 0; font-size: 18px; color: #bbb; }
.star.on { color: #f4b400; }
#empty { padding: 24px; color: #5f6368; }

#threadPane { padding: 16px 24px; max-width: 900px; }
.msg { border: 1px solid #e0e0e0; border-radius: 8px; padding: 12px 16px; margin-bottom: 12px; }
.msg .meta { display: flex; justify-content: space-between; gap: 8px; color: #5f6368; font-size: 13px; margin-bottom: 8px; flex-wrap: wrap; }
.msg .meta b { color: #202124; }
.msg pre { white-space: pre-wrap; word-break: break-word; font: inherit; margin: 0; }
.msg iframe { width: 100%; border: 0; min-height: 200px; }
.msg .att { margin-top: 8px; color: #5f6368; font-size: 13px; }
.msg .actions { margin-top: 10px; display: flex; gap: 8px; }

dialog { border: 0; border-radius: 12px; width: min(620px, 94vw); padding: 16px; box-shadow: 0 8px 30px #0005; }
dialog h3 { margin: 0 0 10px; }
.row { display: flex; gap: 8px; }

@media (max-width: 720px) {
  #app { grid-template-columns: 1fr; }
  header { grid-column: 1; }
  #menuBtn { display: block; }
  nav { display: none; position: fixed; top: 56px; left: 0; bottom: 0; width: 240px; background: #f6f8fc; z-index: 5; box-shadow: 2px 0 8px #0003; }
  nav.open { display: block; }
  #msgList li { grid-template-columns: 28px 1fr auto; }
  #msgList .sub { grid-column: 2 / 4; grid-row: 2; }
  main { border-radius: 0; }
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: #eaf1fb; border-radius: 14px; padding: 3px 4px 3px 10px; font-size: 13px; }
.chip button { border: 0; background: none; padding: 0 6px; border-radius: 50%; font-size: 16px; line-height: 1; }
.muted { color: #5f6368; font-size: 12px; margin-left: auto; align-self: center; }
.draftTag { color: #b3261e; }
.msg .att button { margin: 2px 6px 2px 0; font-size: 13px; padding: 3px 10px; }
