:root {
  --ink: #19221b;
  --muted: #6f786f;
  --line: #e7e9e3;
  --paper: #f7f7f2;
  --white: #fff;
  --accent: #d7ff68;
  --accent-dark: #263612;
  --sidebar: #172019;
}

* { box-sizing: border-box; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.eyebrow {
  margin: 0 0 12px;
  color: #7a837b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .17em;
}
.brand-mark {
  display: grid;
  width: 58px;
  height: 58px;
  margin-bottom: 50px;
  place-items: center;
  border-radius: 18px 5px 18px 18px;
  color: var(--accent-dark);
  background: var(--accent);
  font: 800 26px/1 Georgia, serif;
}
.brand-mark.small { width: 37px; height: 37px; margin: 0; border-radius: 12px 4px 12px 12px; font-size: 18px; }

.login-shell {
  min-height: 100vh;
  width: 100%;
  padding: 32px;
  background: #fff;
}
#login-view:not(.hidden) {
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: min(100%, 420px);
  margin: 0 auto;
}
.login-card h1 { margin: 0 0 16px; color: #707873; font: 750 22px/1.2 Inter, "PingFang SC", sans-serif; }
.login-card .auth-form { width: 100%; gap: 20px; }
.login-card .auth-form label { gap: 9px; color: #707873; font-size: 15px; font-weight: 750; }
.login-card .auth-form input {
  height: 56px;
  padding: 0 18px;
  border: 1px solid #e4e6e0;
  border-radius: 12px;
  color: #4f5651;
  background: #fbfcf9;
  font-size: 16px;
  font-weight: 600;
}
.login-card .primary-button {
  width: 100%;
  min-height: 58px;
  margin-top: 4px;
  padding: 0 20px;
  border-radius: 12px;
  font-size: 17px;
}
.primary-button {
  display: flex;
  width: min(100%, 440px);
  padding: 17px 20px;
  align-items: center;
  justify-content: space-between;
  border-radius: 12px;
  color: white;
  background: var(--ink);
  text-decoration: none;
  transition: transform .2s, background .2s;
}
.primary-button:hover { background: #2c392e; transform: translateY(-2px); }
.primary-button { border: 0; cursor: pointer; }
.auth-form { display: grid; width: min(100%, 440px); gap: 15px; }
.auth-form label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 650; }
.auth-form input { width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px; outline: 0; color: var(--ink); background: #fafbf8; }
.auth-form input:focus { border-color: #8c9d5f; box-shadow: 0 0 0 3px rgba(140,157,95,.14); }
.fine-print { margin: 18px 0 0; color: #9ca29b; font-size: 12px; }
.config-note { width: min(100%, 440px); margin-top: 16px; padding: 12px 14px; border-radius: 10px; color: #794222; background: #fff0e7; font-size: 13px; line-height: 1.5; }

.mail-shell { display: grid; min-height: 100vh; grid-template-columns: 245px minmax(430px, 1fr); }
.sidebar { position: sticky; top: 0; display: flex; height: 100vh; padding: 28px 20px 20px; flex-direction: column; color: white; background: var(--sidebar); }
.brand { display: flex; margin-bottom: 65px; gap: 12px; align-items: center; }
.sidebar nav { display: grid; gap: 7px; }
.nav-item {
  display: flex;
  padding: 12px 14px;
  justify-content: space-between;
  border: 0;
  border-radius: 10px;
  color: #aeb8af;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.nav-item.active { color: #172019; background: var(--accent); }
.nav-item:disabled { cursor: default; opacity: .45; }
.count { font-size: 12px; }
.sidebar-footer { display: flex; margin-top: auto; padding-top: 20px; gap: 10px; align-items: center; border-top: 1px solid rgba(255,255,255,.1); }
.avatar { display: grid; min-width: 38px; width: 38px; height: 38px; place-items: center; overflow: hidden; border-radius: 50%; color: #344022; background: #dfeabf; font-weight: 800; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-copy { min-width: 0; flex: 1; }
.user-copy b, .user-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-copy b { font-size: 13px; }
.user-copy small { margin-top: 3px; color: #8c978e; font-size: 10px; }
.icon-button { display: grid; width: 40px; height: 40px; place-items: center; border: 1px solid var(--line); border-radius: 10px; color: inherit; background: transparent; cursor: pointer; }

.inbox-panel { max-width: 1020px; width: 100%; margin: 0 auto; padding: 52px 6vw; }
.toolbar { display: flex; align-items: flex-end; justify-content: space-between; }
.toolbar h2 { margin: 0; font: 500 42px/1.1 Georgia, serif; }
.toolbar-actions { display: flex; gap: 10px; }
.search-box { display: flex; width: 260px; padding: 0 13px; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.search-box input { width: 100%; padding: 10px 0; border: 0; outline: 0; background: transparent; }
.filter-row { display: flex; margin-top: 38px; padding-bottom: 14px; gap: 9px; align-items: center; border-bottom: 1px solid var(--line); }
.filter { padding: 7px 14px; border: 0; border-radius: 20px; color: var(--muted); background: transparent; cursor: pointer; }
.filter.active { color: var(--ink); background: #e8eadf; }
#status-text { margin-left: auto; color: #969d96; font-size: 12px; }
.message-row {
  display: grid;
  padding: 22px 8px;
  grid-template-columns: 9px minmax(130px, 190px) 1fr auto;
  gap: 18px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: padding .2s, background .2s;
}
.message-row:hover { padding-left: 15px; padding-right: 15px; background: rgba(255,255,255,.7); }
.unread-dot { width: 7px; height: 7px; border-radius: 50%; background: transparent; }
.message-row.unread .unread-dot { background: #779329; }
.sender { overflow: hidden; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.message-copy { min-width: 0; }
.message-copy b, .message-copy p { overflow: hidden; margin: 0; text-overflow: ellipsis; white-space: nowrap; }
.message-copy b { font-size: 14px; }
.message-copy p { margin-top: 6px; color: var(--muted); font-size: 13px; }
.message-row time { color: #878f88; font-size: 12px; white-space: nowrap; }
.load-more { display: block; margin: 25px auto; padding: 10px 20px; border: 1px solid var(--line); border-radius: 10px; background: white; cursor: pointer; }
.empty-state { padding: 120px 20px; color: var(--muted); text-align: center; }
.empty-state div { display: grid; width: 48px; height: 48px; margin: auto; place-items: center; border-radius: 50%; color: #40521c; background: var(--accent); }
.empty-state h3 { margin: 16px 0 6px; color: var(--ink); }
.empty-state p { margin: 0; }

.reader-backdrop { position: fixed; inset: 0; background: rgba(15,22,17,.28); z-index: 5; }
.reader {
  position: fixed;
  z-index: 6;
  top: 0;
  right: 0;
  width: min(680px, 92vw);
  height: 100vh;
  padding: 70px clamp(28px, 6vw, 76px);
  overflow-y: auto;
  background: white;
  box-shadow: -25px 0 80px rgba(20,30,22,.16);
}
.reader-close { position: absolute; top: 24px; right: 25px; border: 0; color: var(--muted); background: transparent; font-size: 28px; cursor: pointer; }
.reader h2 { margin: 0; font: 500 clamp(30px, 4vw, 48px)/1.15 Georgia, serif; }
.sender-line { display: flex; margin: 34px 0; gap: 12px; align-items: center; }
.sender-line b, .sender-line small { display: block; }
.sender-line small { margin-top: 4px; color: var(--muted); }
.reader-body { padding-top: 30px; border-top: 1px solid var(--line); color: #313a33; font-size: 15px; line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; }
.reader-body.html-message { margin: 0 -28px; padding: 20px 0 0; white-space: normal; }
.mail-frame { display: block; width: 100%; min-height: 72vh; border: 0; background: white; }
.toast { position: fixed; z-index: 20; right: 25px; bottom: 25px; max-width: 420px; padding: 13px 18px; border-radius: 10px; color: white; background: #303b32; box-shadow: 0 12px 30px rgba(0,0,0,.2); }
.admin-fab { position: fixed; z-index: 4; right: 24px; bottom: 24px; padding: 11px 16px; border: 0; border-radius: 20px; color: var(--accent-dark); background: var(--accent); box-shadow: 0 10px 25px rgba(38,54,18,.18); cursor: pointer; }
.modal-backdrop { position: fixed; z-index: 30; inset: 0; display: grid; padding: 24px; place-items: center; background: rgba(15,22,17,.4); }
.modal { position: relative; width: min(560px, 100%); max-height: 92vh; padding: 42px; overflow-y: auto; border-radius: 18px; background: white; box-shadow: 0 30px 90px rgba(0,0,0,.22); }
.modal h2 { margin: 0 0 28px; font: 500 34px/1.1 Georgia, serif; }
.modal .auth-form { width: 100%; }
.user-list { display: grid; margin-top: 28px; gap: 8px; }
.user-item { display: flex; padding: 12px; align-items: center; justify-content: space-between; border-radius: 9px; background: var(--paper); }
.user-item b, .user-item small { display: block; }
.user-item small { margin-top: 3px; color: var(--muted); }

@media (max-width: 800px) {
  .login-shell { padding: 24px; }
  .login-card h1 { font-size: 21px; }
  .login-card .auth-form { gap: 18px; }
  .login-card .auth-form label { font-size: 15px; }
  .login-card .auth-form input { height: 54px; padding: 0 16px; border-radius: 11px; font-size: 16px; }
  .login-card .primary-button { min-height: 56px; padding: 0 18px; border-radius: 11px; font-size: 17px; }
  .mail-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 16px 20px; flex-direction: row; align-items: center; }
  .brand { margin: 0; }
  .sidebar nav { display: none; }
  .sidebar-footer { margin: 0 0 0 auto; padding: 0; border: 0; }
  .user-copy { display: none; }
  .inbox-panel { padding: 32px 20px; }
  .toolbar { display: block; }
  .toolbar-actions { margin-top: 20px; }
  .search-box { width: 100%; }
  .message-row { grid-template-columns: 8px 1fr auto; gap: 12px; }
  .message-row .sender { grid-column: 2; }
  .message-copy { grid-column: 2; }
  .message-row time { grid-column: 3; grid-row: 1; }
}
