:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #edf2f7;
  --text: #1a202c;
  --muted: #64748b;
  --line: #d8e0ea;
  --accent: #0f766e;
  --accent-2: #2563eb;
  --danger: #c2410c;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(15, 118, 110, 0.16), transparent 35%),
    linear-gradient(300deg, rgba(37, 99, 235, 0.14), transparent 42%),
    var(--bg);
}

.login-panel {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand.compact {
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #0f766e;
  color: #fff;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.brand p,
.toolbar p,
.reader-header p {
  margin: 2px 0 0;
  color: var(--muted);
}

.login-form,
.compose-form {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 650;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
  padding: 11px 12px;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.primary,
.ghost,
.danger,
.icon-button,
.folder {
  border: 0;
  border-radius: 8px;
}

.primary {
  background: var(--accent);
  color: #fff;
  padding: 11px 14px;
  font-weight: 750;
}

.ghost {
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
}

.danger {
  background: #fff3ed;
  color: var(--danger);
  border: 1px solid #fed7aa;
  padding: 9px 12px;
  font-weight: 700;
}

.icon-button {
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 20px;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(340px, 430px) minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #101828;
  color: #fff;
  padding: 22px;
  display: flex;
  flex-direction: column;
}

.sidebar .brand-mark {
  background: #22c55e;
  color: #052e16;
}

.sidebar .brand p {
  color: #94a3b8;
}

.folders {
  display: grid;
  gap: 8px;
}

.folder {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
}

.folder strong {
  min-width: 28px;
  text-align: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 2px 7px;
}

.folder.is-active,
.folder:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.compose-button {
  margin-top: 20px;
}

.logout-button {
  margin-top: auto;
  color: #cbd5e1;
}

.mail-column {
  border-right: 1px solid var(--line);
  background: #fff;
  min-width: 0;
}

.toolbar,
.reader-header {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.toolbar h2,
.reader-header h2,
.compose-form h2 {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search {
  width: 190px;
}

.message-list {
  height: calc(100vh - 86px);
  overflow: auto;
}

.message-item {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 14px 18px;
  text-align: left;
  display: grid;
  gap: 5px;
}

.message-item:hover,
.message-item.is-selected {
  background: #f0fdfa;
}

.message-item.unread .subject {
  font-weight: 800;
}

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

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

.sender {
  font-weight: 700;
}

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

.reader {
  min-width: 0;
  background: #fbfcfe;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.message-body {
  overflow: auto;
  padding: 26px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
  line-height: 1.68;
}

.empty {
  color: var(--muted);
  padding: 20px;
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 26px 20px;
}

.attachment {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px 10px;
  color: var(--muted);
}

dialog {
  width: min(620px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.compose-form {
  margin: 0;
  padding: 20px;
}

.compose-form header,
.compose-form footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

  .reader {
    grid-column: 2;
    min-height: 52vh;
    border-top: 1px solid var(--line);
  }

  .mail-column {
    min-height: 48vh;
  }
}

@media (max-width: 720px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
    padding: 16px;
  }

  .brand.compact {
    margin-bottom: 14px;
  }

  .folders {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .folder {
    height: auto;
    min-height: 44px;
    gap: 8px;
  }

  .compose-button {
    margin-top: 12px;
  }

  .logout-button {
    margin-top: 4px;
  }

  .mail-column,
  .reader {
    grid-column: auto;
  }

  .toolbar,
  .reader-header {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-actions,
  .search {
    width: 100%;
  }

  .message-list {
    height: auto;
    max-height: 48vh;
  }
}
