:root {
  --bg: #f4f4ef;
  --pane: #ffffff;
  --ink: #14161a;
  --ink-2: #4b5058;
  --muted: #6f747c;
  --faint: #9aa0a8;
  --line: #e9e9e2;
  --line-2: #dcdcd4;
  --hover: #f7f7f2;
  --selected: #fff5e1;
  --amber: #ffa92e;
  --amber-hi: #ffbe5e;
  --danger: #b42318;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button {
  font-family: inherit;
}

svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Boot */
.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #0b0b0c;
  z-index: 60;
  transition: opacity 0.25s ease;
}

.boot.fade {
  opacity: 0;
  pointer-events: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--amber);
  color: var(--amber);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}

.brand-mark.large {
  width: 44px;
  height: 44px;
  font-size: 22px;
  border-width: 2px;
}

.brand-mark.small {
  width: 22px;
  height: 22px;
  font-size: 12px;
}

/* Login */
.login {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(255, 169, 46, 0.14), transparent 70%),
    #0a0a0b;
  z-index: 50;
}

.login-card {
  width: min(400px, 100%);
  background: #111214;
  border: 1px solid #25272c;
  border-radius: 16px;
  padding: 30px 28px 26px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
  color: #e9eaec;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 26px;
}

.login-brand-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #c9cbd0;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.login-sub {
  margin: 0 0 22px;
  font-size: 13px;
  color: #93989f;
}

.login-sub strong {
  color: #cfd2d6;
  font-weight: 500;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8b9099;
}

.field input {
  width: 100%;
  background: #0b0c0e;
  border: 1px solid #2a2d33;
  border-radius: 8px;
  padding: 10px 12px;
  color: #f4f4f5;
  font-size: 14px;
  outline: none;
}

.field input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(255, 169, 46, 0.18);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--ink-2);
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.btn svg {
  width: 15px;
  height: 15px;
}

.btn.primary {
  background: var(--amber);
  color: #1a1205;
}

.btn.primary:hover {
  background: var(--amber-hi);
}

.btn.subtle {
  background: #fff;
  border-color: var(--line-2);
  color: var(--ink-2);
}

.btn.subtle:hover {
  border-color: var(--faint);
}

.btn.ghost:hover {
  color: var(--ink);
}

.btn.full {
  width: 100%;
  padding: 11px 14px;
  font-size: 13.5px;
  margin-top: 4px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.form-error {
  margin: 12px 0 0;
  font-size: 12.5px;
  color: #e8837b;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--hover);
  color: var(--ink);
}

/* App shell */
.app {
  display: grid;
  grid-template-columns: 236px 400px minmax(0, 1fr);
  height: 100dvh;
  background: var(--bg);
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 14px;
  background: #f1f1ec;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 2px 6px;
}

.brand-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.compose {
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
}

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

.folder {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  text-align: left;
}

.folder:hover {
  background: #e9e9e2;
}

.folder.active {
  background: #fff6e6;
  color: var(--ink);
  font-weight: 600;
}

.folder svg {
  width: 16px;
  height: 16px;
  color: var(--faint);
}

.folder.active svg {
  color: var(--ink-2);
}

.badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--amber);
  color: #1a1205;
  font-size: 11px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 10px 6px 2px;
  border-top: 1px solid var(--line-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.account {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2e9e5b;
  flex-shrink: 0;
}

.text-btn {
  align-self: flex-start;
  border: none;
  background: none;
  padding: 0;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}

.text-btn:hover {
  color: var(--ink);
}

/* List pane */
.list-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--pane);
  border-right: 1px solid var(--line);
}

.list-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.search {
  position: relative;
  flex: 1;
}

.search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--faint);
}

.search input {
  width: 100%;
  border: 1px solid transparent;
  background: #f3f3ee;
  border-radius: 8px;
  padding: 8px 10px 8px 32px;
  font-size: 13px;
  color: var(--ink);
  outline: none;
}

.search input::placeholder {
  color: var(--faint);
}

.search input:focus {
  background: #fff;
  border-color: var(--line-2);
}

.list-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 12px 16px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.list-meta .muted {
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--faint);
}

.message-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.message-item {
  display: block;
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  padding: 12px 16px 13px;
  cursor: pointer;
  color: var(--ink);
}

.message-item:hover {
  background: var(--hover);
}

.message-item.selected {
  background: var(--selected);
}

.message-item .row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.message-item .sender {
  display: flex;
  align-items: center;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-item.is-read .sender {
  font-weight: 500;
  color: var(--ink-2);
}

.message-item .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  margin-right: 7px;
  flex-shrink: 0;
}

.message-item .when {
  font-size: 11.5px;
  color: var(--faint);
  flex-shrink: 0;
}

.message-item .subject {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-item.is-read .subject {
  font-weight: 500;
  color: var(--ink-2);
}

.message-item .snippet {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-item .clip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--faint);
  font-size: 11px;
  margin-left: 6px;
}

.message-item .clip svg {
  width: 12px;
  height: 12px;
}

/* Reader */
.reader-pane {
  position: relative;
  overflow-y: auto;
  min-width: 0;
  background: var(--pane);
}

.reader-content {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.reader-header {
  padding: 20px 30px 16px;
  border-bottom: 1px solid var(--line);
}

.reader-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.back {
  display: none;
}

.reader-header h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 650;
  line-height: 1.28;
  letter-spacing: -0.012em;
}

.reader-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.reader-meta .from {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.muted {
  color: var(--muted);
}

.reader-to {
  margin-top: 4px;
  font-size: 12px;
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.attachment {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line-2);
  background: #fcfcfa;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--ink-2);
  text-decoration: none;
  max-width: 100%;
}

.attachment:hover {
  border-color: var(--amber);
}

.attachment svg {
  width: 14px;
  height: 14px;
  color: var(--muted);
}

.attachment .size {
  color: var(--faint);
  font-size: 11px;
}

.email-body {
  flex: 1;
  padding: 22px 30px 60px;
  max-width: 800px;
  font-size: 14.5px;
  line-height: 1.62;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.email-body img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

.email-body a {
  color: #0b57c2;
}

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

.email-body td,
.email-body th {
  padding: 4px 6px;
  vertical-align: top;
}

.email-body blockquote {
  margin: 12px 0;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--line-2);
  color: var(--muted);
}

.email-body pre {
  white-space: pre-wrap;
  overflow-x: auto;
  background: #f7f7f2;
  padding: 12px;
  border-radius: 8px;
  font-size: 12.5px;
}

.email-body p {
  margin: 0 0 12px;
}

.email-body.plain {
  white-space: pre-wrap;
  font-size: 14px;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 100%;
  min-height: 240px;
  padding: 30px;
  color: var(--faint);
  font-size: 13px;
  text-align: center;
}

.empty svg {
  width: 26px;
  height: 26px;
  opacity: 0.55;
}

.empty-art {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  display: grid;
  place-items: center;
  opacity: 0.7;
}

.empty p {
  margin: 0;
}

/* Compose */
.compose-dialog {
  width: min(680px, 94vw);
  max-height: 92vh;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 30px 90px rgba(15, 15, 18, 0.28);
}

.compose-dialog::backdrop {
  background: rgba(12, 12, 14, 0.45);
  backdrop-filter: blur(2px);
}

.compose-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.compose-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
}

.compose-fields {
  padding: 4px 20px 0;
  max-height: 58vh;
  overflow-y: auto;
}

.field.inline {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.field.inline > span {
  width: 56px;
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.field.inline input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0;
  font-size: 13.5px;
  color: var(--ink);
  outline: none;
}

.field.body {
  margin: 0;
  padding: 14px 0 10px;
}

.field.body textarea {
  width: 100%;
  min-height: 200px;
  resize: vertical;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
}

.compose-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
}

.compose-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.compose-footer .form-error {
  margin: 0;
  color: var(--danger);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(8px);
  background: #14161a;
  color: #f1f2f4;
  font-size: 12.5px;
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  z-index: 80;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: #7a1f18;
}

/* Mobile */
.mobile-bar {
  display: none;
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    display: none;
  }

  .list-pane {
    border-right: none;
  }

  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
  }

  .mobile-bar .brand-mark {
    margin-right: auto;
  }

  .mobile-folders {
    display: flex;
    gap: 2px;
    background: #f1f1ec;
    border-radius: 8px;
    padding: 3px;
  }

  .seg {
    border: none;
    background: transparent;
    padding: 5px 11px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
  }

  .seg.active {
    background: #fff;
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  }

  .reader-pane {
    display: none;
  }

  body.reading .list-pane {
    display: none;
  }

  body.reading .reader-pane {
    display: block;
  }

  .back {
    display: inline-grid;
  }

  .reader-header {
    padding: 14px 18px;
  }

  .reader-header h2 {
    font-size: 18px;
  }

  .email-body {
    padding: 16px 18px 40px;
    font-size: 14px;
  }

  .list-toolbar {
    padding: 10px 12px;
  }

  .list-meta {
    padding: 8px 14px 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
