/* ============================================================
   Papilee Mail — stylesheet
   Gmail's palette and geometry, one file, no build step.
   ============================================================ */

:root {
  --bg:            #f6f8fc;
  --surface:       #ffffff;
  --surface-2:     #f2f6fc;
  --surface-3:     #eaf1fb;
  --border:        #e1e5eb;
  --border-soft:   #edf0f3;

  --text:          #202124;
  --text-2:        #3c4043;
  --muted:         #5f6368;
  --faint:         #9aa0a6;

  --blue:          #1a73e8;
  --blue-dark:     #1765cc;
  --blue-deep:     #0b57d0;
  --blue-weak:     #d3e3fd;
  --blue-chip:     #c2e7ff;
  --blue-ink:      #001d35;

  --danger:        #d93025;
  --danger-bg:     #fce8e6;
  --danger-line:   #f4c7c3;
  --danger-ink:    #b3261e;

  --star:          #dadce0;
  --warn:          #fbbc04;

  --shadow-1: 0 1px 2px rgba(60,64,67,.16), 0 1px 3px 1px rgba(60,64,67,.08);
  --shadow-2: 0 1px 3px rgba(60,64,67,.22), 0 4px 8px 3px rgba(60,64,67,.10);
  --shadow-3: 0 8px 28px rgba(60,64,67,.24);
  --shadow-card: 0 12px 40px rgba(60,64,67,.18);

  --header-h:  64px;
  --sidebar-w: 256px;
  --radius:    16px;
}

/* ---------------- reset ---------------- */

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Google Sans", "Roboto", -apple-system, BlinkMacSystemFont,
               "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
img { max-width: 100%; }

/* ---------------- header ---------------- */

.header {
  position: sticky; top: 0; z-index: 200;
  height: var(--header-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.icon-btn {
  display: grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  color: var(--muted); font-size: 20px;
  transition: background .12s;
}
.icon-btn:hover { background: var(--surface-2); }

.brand-chip {
  display: flex; align-items: center; gap: 10px; flex: none;
  height: 50px; padding: 0 12px; border-radius: 26px;
  transition: background .12s;
}
.brand-chip:hover { background: var(--surface-2); }

.brand-mark {
  display: grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #1a73e8, #1558b0);
  color: #fff; font-size: 17px; font-weight: 700;
  box-shadow: 0 1px 2px rgba(26,115,232,.4);
}

.brand-word {
  font-size: 20px; font-weight: 500;
  color: var(--text-2); letter-spacing: -.3px;
}

.caret { margin-left: -2px; font-size: 11px; color: var(--muted); }

.search { position: relative; flex: 1; max-width: 760px; }

.search input {
  width: 100%; height: 48px;
  padding: 0 20px 0 48px;
  border: 0; outline: 0; border-radius: 24px;
  background: var(--surface-3);
  font-size: 15px;
  transition: background .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { background: #fff; box-shadow: var(--shadow-1); }

.search .mag {
  position: absolute; left: 16px; top: 13px;
  font-size: 19px; color: var(--muted); pointer-events: none;
}

.header-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.avatar {
  display: grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--muted); color: #fff;
  font-size: 15px; font-weight: 600;
}

/* ---------------- dropdown menus ---------------- */

.menu-wrap { position: relative; }

.menu {
  position: absolute; top: 54px; right: 0; z-index: 300;
  display: none; min-width: 320px; padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-3);
}
.menu.open { display: block; }
.menu.left { right: auto; left: 0; }

.menu-title {
  padding: 8px 14px 6px;
  font-size: 12px; font-weight: 600; letter-spacing: .5px;
  color: var(--muted); text-transform: uppercase;
}

.menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 10px;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.current { background: #e8f0fe; }
.menu-item .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item .sub { font-size: 12px; color: var(--muted); }
.menu-item .tick { margin-left: auto; font-weight: 700; color: var(--blue); }

.menu-sep { height: 1px; margin: 6px 4px; background: var(--border); }

.menu-hint {
  margin: 4px 6px 6px; padding: 10px 12px;
  border-radius: 10px; background: var(--surface-2);
  font-size: 12px; line-height: 1.5; color: var(--muted);
}
.menu-hint code {
  padding: 1px 5px; border: 1px solid var(--border); border-radius: 4px;
  background: #fff; color: var(--text);
}

/* ---------------- shell ---------------- */

.shell { display: flex; min-height: calc(100vh - var(--header-h)); }

/* ---------------- sidebar ---------------- */

.sidebar {
  display: flex; flex-direction: column; gap: 4px; flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w); padding: 12px 8px 24px;
}

.compose {
  display: flex; align-items: center; gap: 14px;
  height: 56px; margin: 0 8px 12px; padding: 0 22px;
  border-radius: var(--radius);
  background: var(--blue-chip); color: var(--blue-ink);
  font-size: 15px; font-weight: 500;
  box-shadow: var(--shadow-1);
  transition: box-shadow .15s;
}
.compose:hover { box-shadow: var(--shadow-2); }
.compose .plus { font-size: 22px; line-height: 1; }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav a {
  display: flex; align-items: center; gap: 16px;
  height: 40px; padding: 0 16px 0 14px;
  border-radius: 0 20px 20px 0;
  font-size: 14px; color: var(--text-2);
}
.nav a:hover { background: #eef1f6; }
.nav-logout { margin: 0; }
.nav-link { width: 100%; display: flex; align-items: center; gap: 16px; height: 40px; padding: 0 16px 0 14px; border: 0; border-radius: 0 20px 20px 0; background: transparent; text-align: left; font: inherit; font-size: 14px; color: var(--text-2); cursor: pointer; }
.nav-link:hover { background: #eef1f6; }
.account-switch-form { margin: 0; }
.menu button.menu-item { width: 100%; border: 0; background: transparent; text-align: left; font: inherit; cursor: pointer; }
.menu button.menu-item:hover { background: #eef1f6; }
.nav a.active { background: var(--blue-weak); color: var(--blue-ink); font-weight: 600; }

.nav .ico { flex: none; width: 22px; font-size: 16px; color: var(--muted); text-align: center; }
.nav a.active .ico { color: var(--blue-deep); }
.nav .count { margin-left: auto; font-size: 12px; color: var(--muted); }

.nav-head {
  padding: 16px 16px 6px;
  font-size: 12px; font-weight: 700; letter-spacing: .5px;
  color: var(--muted); text-transform: uppercase;
}

/* ---------------- content panel ---------------- */

.main { flex: 1; min-width: 0; padding: 12px 16px 32px 8px; }

.panel {
  min-height: calc(100vh - 100px);
  overflow: hidden;
  background: var(--surface);
  border-radius: var(--radius);
}

.toolbar {
  display: flex; align-items: center; gap: 4px;
  height: 52px; padding: 0 10px;
  border-bottom: 1px solid var(--border);
}
.toolbar .spacer { flex: 1; }

.page-info { padding: 0 10px; font-size: 12px; color: var(--muted); }

.flash {
  margin: 12px 16px; padding: 12px 16px;
  border: 1px solid #c6d8fb; border-radius: 10px;
  background: #e8f0fe; font-size: 14px;
}
.flash.err { border-color: var(--danger-line); background: var(--danger-bg); color: var(--danger-ink); }

/* ---------------- message list ---------------- */

.list { width: 100%; }

.row {
  display: grid;
  grid-template-columns: 40px 36px minmax(150px, 210px) minmax(0, 1fr) 88px;
  align-items: center;
  min-height: 48px; padding: 0 12px;
  border-bottom: 1px solid var(--border-soft);
  color: inherit;
  transition: background .12s, box-shadow .12s;
}
.row:hover {
  background: var(--surface-2);
  box-shadow: inset 1px 0 0 #dadce0, inset -1px 0 0 #dadce0, 0 1px 2px rgba(60,64,67,.14);
}
.row.unread { background: #fff; font-weight: 600; }
.row.read   { background: #f7f9fc; color: var(--muted); }

.row .pick { display: grid; place-items: center; }
.row .pick input { width: 17px; height: 17px; }

.row .star { font-size: 18px; color: var(--star); text-align: center; user-select: none; }
.row .star:hover { color: var(--warn); }

.row .who  { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; padding-right: 12px; }
.row .subj { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.row .snip { font-weight: 400; color: var(--muted); }
.row .when { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }

.row .dot {
  display: inline-block; width: 7px; height: 7px; margin-right: 7px;
  border-radius: 50%; background: var(--blue); vertical-align: 1px;
}

.empty { padding: 80px 20px; text-align: center; color: var(--muted); }
.empty .big { margin-bottom: 12px; font-size: 44px; }
.empty h2 { margin: 0 0 6px; font-weight: 400; color: var(--text); }

.pager {
  display: flex; align-items: center; justify-content: space-between;
  height: 52px; padding: 0 14px;
  border-top: 1px solid var(--border);
  font-size: 13px; color: var(--muted);
}
.pager a { color: var(--blue); }

/* ---------------- message view ---------------- */

.msg-head { padding: 24px 28px 18px; border-bottom: 1px solid var(--border); }

.msg-title {
  margin: 0 0 18px;
  font-size: 22px; font-weight: 400; line-height: 1.35; letter-spacing: -.2px;
}

.msg-meta { display: flex; align-items: flex-start; gap: 14px; }
.msg-meta .wire { min-width: 0; }

.msg-from { font-weight: 600; }
.msg-from .addr { font-weight: 400; color: var(--muted); }
.msg-line { margin-top: 3px; font-size: 12px; color: var(--muted); }

.msg-body {
  padding: 28px; line-height: 1.65;
  white-space: pre-wrap; overflow-wrap: anywhere;
}

.msg-attach { padding: 0 28px 20px; font-size: 13px; color: var(--muted); }

.pill {
  display: inline-block; margin: 2px 4px 2px 0; padding: 2px 10px;
  border: 1px solid var(--border); border-radius: 999px;
}

.actions { display: flex; gap: 8px; padding: 16px 28px 28px; flex-wrap: wrap; }

/* ---------------- buttons ---------------- */

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 18px;
  border: 1px solid var(--border); border-radius: 20px;
  background: #fff; font-size: 14px; font-weight: 500;
  transition: background .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-2); box-shadow: var(--shadow-1); }

.btn.primary { border-color: var(--blue); background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }

.btn.danger { border-color: var(--danger-line); color: var(--danger); }

.btn.link { height: auto; padding: 0 8px; border: 0; color: var(--blue); }

/* ---------------- composer ---------------- */

.composer {
  max-width: 820px; margin: 16px auto 40px;
  overflow: hidden; background: #fff;
  border-radius: 14px; box-shadow: var(--shadow-3);
}

.composer-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-weight: 600;
}
.composer-bar .right { margin-left: auto; font-size: 12px; font-weight: 400; color: var(--muted); }

.field { display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.field label { flex: none; width: 64px; font-size: 13px; color: var(--muted); }
.field input { flex: 1; padding: 14px 0; border: 0; outline: 0; background: #fff; }
.field textarea { width: 100%; min-height: 340px; padding: 18px 0; border: 0; outline: 0; resize: vertical; line-height: 1.6; }
.field.body { display: block; border-bottom: 0; }

.composer-foot { display: flex; align-items: center; gap: 10px; padding: 16px; border-top: 1px solid var(--border); }

/* ---------------- labels table ---------------- */

.table { width: 100%; border-collapse: collapse; }

.table th {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--muted); text-align: left;
}

.table td { padding: 13px 18px; border-bottom: 1px solid var(--border-soft); font-size: 14px; }
.table tr:hover { background: var(--surface-2); }
.table a { color: var(--blue); }

/* ---------------- login ---------------- */

.signin {
  display: grid; place-items: center; min-height: 100vh; padding: 24px;
  background:
    radial-gradient(1200px 600px at 12% -10%, #e8f0fe 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 110%, #d3e3fd 0%, transparent 55%),
    var(--bg);
}

.card {
  width: 100%; max-width: 440px; padding: 40px 36px;
  background: #fff; border-radius: 24px;
  box-shadow: var(--shadow-card);
}

.card .mark {
  display: grid; place-items: center;
  width: 52px; height: 52px; margin: 0 auto 18px;
  border-radius: 16px;
  background: linear-gradient(135deg, #1a73e8, #1558b0);
  color: #fff; font-size: 24px; font-weight: 700;
  box-shadow: 0 4px 12px rgba(26,115,232,.34);
}

.card h1 { margin: 0 0 6px; font-size: 24px; font-weight: 500; letter-spacing: -.3px; text-align: center; }
.card .lead { margin: 0 0 28px; color: var(--muted); text-align: center; }

.field-stack { margin-bottom: 18px; }
.field-stack label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 600; }

.input {
  width: 100%; padding: 14px 15px;
  border: 1px solid #dadce0; border-radius: 12px;
  background: #fff; font-size: 15px; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26,115,232,.15); }

.submit {
  width: 100%; height: 48px;
  border-radius: 12px; background: var(--blue);
  color: #fff; font-size: 15px; font-weight: 600;
  transition: background .12s, box-shadow .12s;
}
.submit:hover { background: var(--blue-dark); box-shadow: 0 2px 8px rgba(26,115,232,.36); }

.alert {
  margin-bottom: 18px; padding: 12px 14px;
  border: 1px solid var(--danger-line); border-radius: 12px;
  background: var(--danger-bg); color: var(--danger-ink); font-size: 14px;
}

.card-foot { margin-top: 24px; font-size: 13px; color: var(--muted); text-align: center; }
.card-foot a { color: var(--blue); }

/* ---------------- prose pages ---------------- */

.doc {
  max-width: 880px; margin: 24px auto 60px; padding: 44px;
  background: #fff; border-radius: 18px;
  box-shadow: 0 6px 24px rgba(60,64,67,.10);
  line-height: 1.7;
}
.doc h1 { margin-top: 0; font-weight: 500; letter-spacing: -.4px; }
.doc h2 { margin-top: 32px; font-size: 19px; font-weight: 500; }
.doc p { color: var(--text-2); }

/* ---------------- responsive ---------------- */

@media (max-width: 1000px) {
  .row { grid-template-columns: 34px 30px minmax(110px, 170px) minmax(0, 1fr) 74px; }
  .search input { height: 44px; }
}

@media (max-width: 760px) {
  .sidebar {
    position: fixed; top: var(--header-h); bottom: 0; left: -270px; z-index: 150;
    width: var(--sidebar-w); overflow-y: auto;
    background: var(--bg);
    box-shadow: 3px 0 14px rgba(0,0,0,.14);
    transition: left .2s ease;
  }
  .sidebar.open { left: 0; }

  .brand-word { display: none; }
  .main { padding: 8px; }
  .panel { border-radius: 12px; }

  .row { grid-template-columns: 30px 28px minmax(0, 1fr) 64px; }
  .row .who  { grid-column: 3; }
  .row .subj { grid-column: 3; margin-top: -2px; font-size: 13px; }
  .row .star { display: none; }
  .row .when { grid-column: 4; grid-row: 1 / span 2; }

  .msg-head, .msg-body { padding-right: 18px; padding-left: 18px; }
  .actions { padding-right: 18px; padding-left: 18px; }

  .card { padding: 28px 22px; }
  .doc  { padding: 26px; }
  .menu { min-width: 280px; }
}

/* Gmail-like mailbox feed and bulk actions */
.nav-count { margin-left:auto; color:var(--muted); font-size:12px; font-weight:600; font-variant-numeric:tabular-nums; }
.nav a { display:flex; align-items:center; gap:12px; }
.panel-heading { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:16px 24px 10px; }
.panel-heading h1 { font-size:22px; font-weight:500; margin:0; }
.compose-inline { border-radius:24px; background:var(--blue-chip); padding:10px 18px; font-weight:600; }
.mail-search { display:flex; gap:8px; padding:8px 24px 16px; }
.mail-search input { flex:1; min-width:0; border:1px solid var(--border); border-radius:24px; background:var(--surface-2); padding:12px 18px; outline-color:var(--blue); }
.mail-search button,.bulk-toolbar button { border-radius:20px; padding:9px 16px; background:var(--blue); color:white; font-weight:600; }
.bulk-toolbar { display:flex; align-items:center; gap:12px; flex-wrap:wrap; padding:10px 22px; border-top:1px solid var(--border-soft); border-bottom:1px solid var(--border); color:var(--muted); }
.bulk-toolbar select { border:1px solid var(--border); border-radius:8px; background:white; padding:8px 10px; }
.select-all-label { display:flex; align-items:center; gap:8px; }
.selection-count { margin-left:auto; font-size:12px; }
.gmail-message-list { width:100%; }
.gmail-message-row { display:flex; align-items:center; min-height:54px; gap:14px; padding:0 20px; border-bottom:1px solid var(--border-soft); background:var(--surface); }
.gmail-message-row:hover { box-shadow:inset 0 -1px var(--border), inset 0 1px var(--border); background:#f7faff; }
.gmail-message-row.unread { background:#f2f6fc; font-weight:600; }
.message-check { display:flex; align-items:center; flex:none; }
.message-check input,.select-all-label input { width:16px; height:16px; accent-color:var(--blue); cursor:pointer; }
.message-star { color:#9aa0a6; font-size:22px; flex:none; }
.message-main { min-width:0; flex:1; display:flex; align-items:center; gap:10px; overflow:hidden; }
.message-sender { width:180px; flex:none; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.message-subject { flex:none; max-width:38%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.message-snippet { min-width:0; color:var(--muted); font-weight:400; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.message-date { flex:none; color:var(--muted); font-size:12px; white-space:nowrap; }
.attachment-mark { flex:none; font-size:13px; }
.empty-mail { padding:48px 24px; color:var(--muted); text-align:center; }
.pagination { display:flex; justify-content:flex-end; gap:20px; padding:18px 24px; }
.flash.ok { background:#e6f4ea; color:#137333; padding:10px 16px; }
.flash.err { background:var(--danger-bg); color:var(--danger-ink); padding:10px 16px; }
@media(max-width:800px) {
 .gmail-message-row { gap:8px; padding:0 10px; }
 .message-sender { width:105px; }
 .message-main { display:block; }
 .message-subject { display:block; max-width:100%; }
 .message-snippet { display:none; }
 .message-date { font-size:11px; }
 .panel-heading { padding:14px; }
}

/* Rich-text compose toolbar and attachments */
.rich-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: 10px 16px; border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.rich-toolbar button, .format-color {
  border: 1px solid var(--border); border-radius: 6px;
  background: #fff; padding: 6px 10px; cursor: pointer;
  font: inherit; font-size: 13px;
}
.format-color { display: inline-flex; align-items: center; gap: 6px; }
.format-color input { width: 25px; height: 24px; padding: 0; border: 0; }
.rich-body { padding-top: 12px; }
.rich-editor {
  min-height: 300px; padding: 12px 0; outline: none;
  line-height: 1.6; overflow-wrap: anywhere;
}
.rich-editor:empty::before {
  content: "Write your message…"; color: var(--muted); pointer-events: none;
}
.attachment-picker {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 12px 16px; border-top: 1px solid var(--border);
  font-size: 13px;
}
.attachment-picker input[type="file"] { max-width: 100%; }
