:root {
  --page: #f7f9fc;
  --surface: #fff;
  --surface-soft: #edf5f2;
  --ink: #202124;
  --muted: #5f6368;
  --line: #dadce0;
  --row: #f2f6fb;
  --ktc: #0b6f63;
  --ktc-2: #0f8a7a;
  --ktc-soft: #d8f1ed;
  --gold: #b5892f;
  --danger: #b3261e;
  --danger-bg: #fceeee;
  --ok: #146c43;
  --ok-bg: #eaf7ef;
  --shadow: 0 8px 24px rgba(60, 64, 67, .16);
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--page);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

a {
  color: inherit;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(130deg, rgba(11, 111, 99, .13), rgba(181, 137, 47, .09)),
    var(--page);
}

.login-shell {
  width: min(1040px, calc(100% - 32px));
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 56px;
  align-items: center;
}

.login-brand .logo,
.brand-mark {
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--ktc), var(--ktc-2));
  color: #fff;
  font-weight: 800;
  letter-spacing: .02em;
}

.login-brand .logo {
  width: 72px;
  height: 72px;
  box-shadow: var(--shadow);
}

.login-brand h1 {
  margin: 24px 0 10px;
  font-size: 52px;
  line-height: 1;
}

.login-brand p {
  margin: 0;
  max-width: 460px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.5;
}

.login-card {
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card h2 {
  margin: 0 0 22px;
  font-size: 28px;
  font-weight: 500;
}

label {
  display: block;
  margin: 16px 0 7px;
  color: #3c4043;
  font-weight: 700;
}

input,
textarea,
.rich-editor {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

input:focus,
textarea:focus,
.rich-editor:focus {
  border-color: var(--ktc);
  outline: 3px solid rgba(11, 111, 99, .16);
}

.btn,
button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 18px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.btn.primary,
button.primary {
  border-color: var(--ktc);
  background: var(--ktc);
  color: #fff;
}

.btn.primary:hover,
button.primary:hover {
  background: #07584f;
}

.full {
  width: 100%;
  margin-top: 24px;
}

.fine-print,
.muted,
.meta,
.reader-empty p,
.list-toolbar span {
  color: var(--muted);
}

.fine-print {
  margin: 18px 0 0;
  font-size: 13px;
  line-height: 1.5;
}

.notice,
.errors {
  margin-bottom: 16px;
  border-radius: 12px;
  padding: 12px 14px;
}

.notice {
  color: var(--ok);
  background: var(--ok-bg);
  border: 1px solid rgba(20, 108, 67, .22);
}

.errors {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid rgba(179, 38, 30, .22);
}

.errors p {
  margin: 0;
}

.errors p + p {
  margin-top: 6px;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 256px 1fr;
  grid-template-rows: 72px 1fr;
  grid-template-areas:
    "top top"
    "side main";
}

.topbar {
  grid-area: top;
  display: grid;
  grid-template-columns: 256px minmax(300px, 760px) 1fr;
  gap: 18px;
  align-items: center;
  padding: 12px 22px 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid #edf0f3;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #3c4043;
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  font-size: 13px;
}

.brand-copy {
  display: grid;
  line-height: 1.1;
}

.brand-copy strong {
  font-size: 21px;
  font-weight: 500;
}

.brand-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 48px;
  border-radius: 999px;
  background: #edf2f7;
}

.search button {
  min-width: 78px;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.search input {
  border: 0;
  background: transparent;
  min-height: 48px;
  padding-left: 0;
}

.search:focus-within {
  background: #fff;
  box-shadow: var(--shadow);
}

.account {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.top-link {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 12px;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}

.top-link:hover {
  background: #f1f3f4;
  color: var(--ink);
}

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--gold);
  color: #fff;
  font-weight: 800;
}

.sidebar {
  grid-area: side;
  padding: 18px 12px 18px 0;
  background: var(--surface);
}

.compose {
  display: inline-flex;
  min-width: 150px;
  min-height: 56px;
  align-items: center;
  justify-content: center;
  margin: 0 0 20px 12px;
  border-radius: 18px;
  background: #c7efe8;
  color: #073f39;
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 2px 7px rgba(60, 64, 67, .18);
}

.compose:hover {
  box-shadow: var(--shadow);
}

.sidebar nav {
  display: grid;
  gap: 2px;
}

.sidebar nav a {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 0 18px 18px 0;
  padding: 0 14px 0 22px;
  color: #3c4043;
  text-decoration: none;
}

.nav-label {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-count {
  min-width: 24px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 7px;
  background: #eef2f6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.sidebar nav a.active {
  background: var(--ktc-soft);
  color: #063f38;
  font-weight: 800;
}

.sidebar nav a.active .nav-count {
  background: #fff;
  color: #063f38;
}

.sidebar nav a:hover {
  background: #f1f3f4;
}

.nav-icon {
  width: 32px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .06em;
}

.content {
  grid-area: main;
  min-width: 0;
  padding: 12px 16px 16px 0;
  overflow: hidden;
}

.mail-grid {
  display: grid;
  grid-template-columns: minmax(380px, 42%) minmax(0, 1fr);
  gap: 14px;
  height: calc(100vh - 100px);
}

.message-list,
.reader,
.compose-panel {
  border: 1px solid #edf0f3;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: none;
}

.message-list,
.reader {
  min-height: 0;
  overflow: auto;
}

.list-toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 10px 16px;
  border-bottom: 1px solid #edf0f3;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
}

.list-toolbar div {
  display: grid;
  gap: 2px;
}

.list-toolbar strong {
  font-size: 16px;
}

.refresh-link {
  color: var(--ktc);
  font-weight: 800;
  text-decoration: none;
}

.message-row {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr auto;
  gap: 14px;
  align-items: center;
  min-height: 50px;
  padding: 0 16px;
  border-bottom: 1px solid #f0f2f5;
  color: #3c4043;
  text-decoration: none;
}

.message-row:hover {
  position: relative;
  z-index: 1;
  background: #f8fafc;
  box-shadow: 0 1px 4px rgba(60, 64, 67, .18);
}

.message-row.selected {
  box-shadow: inset 4px 0 0 var(--ktc);
  background: #f3faf8;
}

.message-row.unread {
  color: var(--ink);
  background: #fff;
  font-weight: 800;
}

.from,
.subject {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.from b {
  color: var(--muted);
  font-weight: 700;
}

.date {
  color: var(--muted);
  font-size: 12px;
}

.thread-pill {
  display: inline-flex;
  min-width: 22px;
  height: 20px;
  margin-left: 8px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--ktc-soft);
  color: #063f38;
  font-size: 12px;
}

.attach-pill {
  display: inline-flex;
  height: 20px;
  margin-left: 8px;
  align-items: center;
  justify-content: center;
  border: 1px solid #d9e2ea;
  border-radius: 999px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.reader {
  padding: 28px;
}

.reader-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid #edf0f3;
}

.reader h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 500;
  line-height: 1.25;
}

.reader-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.reader-actions form {
  margin: 0;
}

.icon-btn {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: #fff;
  color: var(--ktc);
  font-weight: 800;
  text-decoration: none;
}

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

.busy {
  cursor: progress;
}

.busy [data-busy-form] button[type="submit"],
[data-busy-form].is-busy button[type="submit"] {
  opacity: .68;
  pointer-events: none;
}

.meta {
  display: grid;
  gap: 6px;
  margin: 18px 0 24px;
}

.meta p {
  margin: 0;
}

.attachments,
.thread-box {
  display: grid;
  gap: 8px;
  margin: 0 0 20px;
  padding: 13px 14px;
  border: 1px solid #e3e8ef;
  border-radius: 14px;
  background: #f8fbfd;
}

.attachments a,
.thread-box a {
  color: var(--ktc);
  font-weight: 800;
  text-decoration: none;
}

.body-text {
  line-height: 1.65;
  white-space: normal;
}

.reader-empty,
.empty {
  min-height: 260px;
  display: grid;
  place-items: center;
  align-content: center;
  color: var(--muted);
  text-align: center;
}

.reader-empty h2 {
  margin: 0 0 8px;
  color: var(--ink);
  font-weight: 500;
}

.pager {
  display: flex;
  justify-content: center;
  gap: 18px;
  padding: 14px;
  color: var(--muted);
}

.pager a {
  color: var(--ktc);
  font-weight: 800;
}

.compose-panel {
  width: min(880px, calc(100% - 12px));
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.compose-title {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: #e9f3f1;
  color: #073f39;
}

.compose-title h2 {
  margin: 0;
  font-size: 15px;
}

.compose-title a {
  color: #073f39;
  font-weight: 800;
  text-decoration: none;
}

.compose-panel form {
  display: grid;
  gap: 0;
}

.compose-panel input {
  border: 0;
  border-bottom: 1px solid #edf0f3;
  border-radius: 0;
}

.compose-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #edf0f3;
  background: #fff;
}

.compose-tools button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 8px;
}

.draft-status {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.rich-editor {
  min-height: 330px;
  overflow: auto;
  border: 0;
  border-radius: 0;
  line-height: 1.55;
}

.file-label {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 10px 14px;
  color: var(--muted);
}

.compose-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px 14px;
  border-top: 1px solid #edf0f3;
}

.settings-panel {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.settings-panel h2,
.settings-panel h3 {
  margin: 0;
  font-weight: 500;
}

code {
  padding: 2px 5px;
  border-radius: 6px;
  background: #f1f3f4;
}

@media (max-width: 900px) {
  .login-shell,
  .mail-grid {
    grid-template-columns: 1fr;
  }

  .login-brand {
    display: none;
  }

  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
      "top"
      "side"
      "main";
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .account {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .sidebar {
    padding: 12px;
    border-bottom: 1px solid #edf0f3;
  }

  .sidebar nav {
    display: flex;
    overflow-x: auto;
  }

  .sidebar nav a {
    border-radius: 18px;
    white-space: nowrap;
  }

  .content {
    padding: 12px;
  }

  .mail-grid {
    height: auto;
  }

  .message-row {
    grid-template-columns: 1fr auto;
  }

  .message-row .subject {
    grid-column: 1 / -1;
  }

  .reader-head,
  .reader-actions {
    display: grid;
    justify-content: stretch;
  }

  .reader-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .reader-actions .icon-btn,
  .reader-actions form,
  .reader-actions button {
    width: 100%;
  }
}
