:root {
  color-scheme: light;
  --bg: #eef3f8;
  --panel: #ffffff;
  --ink: #202124;
  --muted: #6b7280;
  --line: #dfe5ec;
  --brand: #1a73e8;
  --brand-strong: #1558b0;
  --accent: #f9ab00;
  --danger: #b42318;
  --green: #0f9d58;
  --red: #d93025;
  --shadow: 0 18px 45px rgba(60, 64, 67, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  margin: 0;
  width: 100%;
  max-width: 100vw;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.button.secondary {
  background: #e6edf0;
  color: var(--ink);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(20, 108, 117, 0.9), rgba(23, 32, 42, 0.86)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='600' viewBox='0 0 900 600'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.18'%3E%3Cpath d='M40 90h820v420H40z'/%3E%3Cpath d='m40 90 410 260L860 90'/%3E%3Cpath d='M40 510l280-220M860 510 580 290'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
}

.login-panel {
  width: min(100%, 430px);
  padding: 34px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.brand-block {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark,
.logo span {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 1.9rem;
  line-height: 1.15;
}

.login-form,
.compose-form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 0.92rem;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

textarea {
  resize: vertical;
}

.muted {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.form-error,
.notice.error {
  border: 1px solid rgba(180, 35, 24, 0.22);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff4f2;
  color: var(--danger);
}

.app-shell {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, calc(100vw - 248px));
  overflow-x: hidden;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 18px 14px;
  background: #f8fbff;
  border-right: 1px solid #d9e4f2;
  color: var(--ink);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px;
  font-size: 1.04rem;
  font-weight: 800;
}

.logo span {
  background: var(--brand);
  box-shadow: 0 8px 18px rgba(26, 115, 232, 0.24);
}

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

.nav-section {
  display: grid;
  gap: 4px;
}

.nav-label {
  margin: 0 0 3px;
  padding: 0 14px;
  color: #7b8794;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar nav a,
.sidebar nav span,
.logout {
  width: 100%;
  justify-content: flex-start;
  border-radius: 0 999px 999px 0;
  padding: 11px 14px;
  background: transparent;
  color: #3c4043;
  font-weight: 700;
}

.sidebar nav span {
  color: #8a94a3;
  cursor: default;
}

.sidebar nav .nav-label {
  border-radius: 0;
  background: transparent;
  cursor: default;
}

.sidebar nav a.active,
.sidebar nav a:hover,
.logout:hover {
  background: #dfeaff;
  color: #174ea6;
}

.sidebar nav a.subtle-nav {
  margin-top: 6px;
  color: #6b7280;
  font-size: 0.86rem;
}

.sidebar form {
  margin-top: auto;
}

.content {
  width: 100%;
  max-width: 100%;
  height: 100vh;
  padding: 18px clamp(20px, 3vw, 54px) 42px;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  contain: inline-size;
  overscroll-behavior: contain;
}

.inbox-hero {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(360px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 10px 0 18px;
  background: rgba(238, 243, 248, 0.92);
  backdrop-filter: blur(12px);
}

.search-box {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(26, 115, 232, 0.14);
  border-radius: 999px;
  padding: 0 8px 0 22px;
  background: #fff;
  color: #5f6368;
  font-weight: 700;
  box-shadow: 0 12px 28px rgba(60, 64, 67, 0.1);
}

.search-box::before {
  content: "";
  width: 18px;
  height: 18px;
  margin-right: 12px;
  border: 2px solid #5f6368;
  border-radius: 50%;
  box-shadow: 8px 8px 0 -6px #5f6368;
  transform: rotate(-15deg);
}

.search-box input {
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  font-weight: 800;
  outline: none;
  color: var(--ink);
}

.search-box button {
  min-height: 34px;
  border-radius: 999px;
  padding: 0 14px;
}

.compose-fab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 118px;
  height: 46px;
  border-radius: 999px;
  padding: 0 20px;
  background: var(--brand);
  color: #fff;
  font-size: 0.86rem;
  font-weight: 900;
  box-shadow: 0 12px 26px rgba(26, 115, 232, 0.28);
}

.compose-fab span {
  font-size: 1.35rem;
  line-height: 1;
}

.dashboard-strip,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 10px 0 18px;
}

.dashboard-strip h1 {
  font-size: 2.25rem;
}

.inbox-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inbox-tools button {
  min-height: 36px;
  border: 1px solid #d1d9e6;
  background: #fff;
  color: #3c4043;
  box-shadow: none;
}

.bundle-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.bundle-tab {
  min-height: 74px;
  display: grid;
  gap: 6px;
  align-content: center;
  border: 1px solid #dfe5ec;
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff;
  color: #3c4043;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.08);
}

.bundle-tab span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.bundle-tab strong {
  font-size: 1.35rem;
}

.bundle-tab.active {
  border-color: rgba(26, 115, 232, 0.38);
  background: #eaf2ff;
  color: #174ea6;
}

.mail-list {
  display: grid;
  gap: 10px;
}

.mail-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) minmax(170px, auto);
  gap: 14px;
  align-items: center;
  min-height: 82px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.12);
  transition:
    box-shadow 120ms ease,
    transform 120ms ease,
    border-color 120ms ease;
}

.mail-row:hover {
  border-color: #c9d7ee;
  box-shadow: 0 8px 22px rgba(60, 64, 67, 0.16);
  transform: translateY(-1px);
}

.mail-row.unseen {
  border-left: 4px solid var(--brand);
}

.mail-row.unseen .sender,
.mail-row.unseen .subject {
  font-weight: 800;
}

.avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 800;
}

.avatar-primary {
  background: var(--brand);
}

.avatar-updates {
  background: var(--green);
}

.avatar-promos {
  background: var(--accent);
}

.avatar-social {
  background: #7b61ff;
}

.mail-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.mail-line {
  min-width: 0;
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

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

.subject {
  color: #202124;
}

.preview {
  color: var(--muted);
  font-size: 0.9rem;
}

.date {
  flex: 0 0 auto;
  max-width: 210px;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: right;
}

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

.quick-actions form,
.message-actions form {
  margin: 0;
}

.quick-actions button,
.message-actions button,
.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 32px;
  border: 0;
  border-radius: 999px;
  padding: 7px 10px;
  background: #f1f4f9;
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}

.quick-actions button:hover,
.message-actions button:hover,
.action-link:hover {
  background: #dfeaff;
  color: #174ea6;
}

.quick-actions .danger-link,
.message-actions .danger-link,
.danger-button {
  background: #fff4f2;
  color: var(--danger);
}

.quick-actions .danger-link:hover,
.message-actions .danger-link:hover,
.danger-button:hover {
  background: #ffe2de;
  color: var(--danger);
}

.delete-dialog {
  width: min(420px, calc(100vw - 32px));
}

.delete-dialog h2 {
  margin: 0 0 8px;
}

.delete-dialog p {
  margin: 0 0 18px;
  color: var(--muted);
}

.ai-summary-button,
.editor-toolbar .ai-editor-action {
  background: #102a43;
  color: #fff;
}

.ai-summary-button:hover,
.editor-toolbar .ai-editor-action:hover {
  background: #184b73;
  color: #fff;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  border-radius: 999px;
  padding: 2px 7px;
  background: #eef2f7;
  color: #64748b;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  vertical-align: middle;
}

.status-badge.pinned {
  background: #eaf2ff;
  color: #174ea6;
}

.status-badge.snoozed {
  background: #fff7d6;
  color: #8a5a00;
}

.status-badge.done {
  background: #e6f4ea;
  color: #137333;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 38px;
  background: #fff;
  color: var(--muted);
  text-align: center;
}

.message-view {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  padding-bottom: 24px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  background: #fff;
  color: var(--brand-strong);
  font-weight: 800;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.06);
}

.message-topbar {
  min-width: 0;
  max-width: 100%;
  position: sticky;
  top: 18px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid rgba(217, 228, 242, 0.88);
  border-radius: 8px;
  padding: 10px;
  background: rgba(248, 251, 255, 0.94);
  backdrop-filter: blur(14px);
  box-shadow: 0 14px 36px rgba(60, 64, 67, 0.1);
  margin-bottom: 6px;
}

.message-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 18px;
  align-items: stretch;
  min-width: 0;
  max-width: 100%;
}

.message-subject-block,
.message-meta-card,
.message-body-shell {
  min-width: 0;
  max-width: 100%;
  border: 1px solid rgba(26, 115, 232, 0.12);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 38px rgba(60, 64, 67, 0.1);
}

.message-subject-block {
  display: grid;
  align-content: center;
  gap: 10px;
  min-height: 178px;
  padding: 28px;
  background:
    linear-gradient(120deg, rgba(26, 115, 232, 0.1), rgba(15, 157, 88, 0.08)),
    #fff;
}

.message-view h1 {
  margin: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(1.65rem, 2.5vw, 2.7rem);
  line-height: 1.08;
}

.message-meta-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 22px;
}

.message-meta-card .avatar {
  width: 54px;
  height: 54px;
  font-size: 1rem;
}

.message-meta-card dl {
  grid-template-columns: 58px minmax(0, 1fr);
  margin: 0;
  gap: 9px 12px;
}

.message-meta-card dd {
  color: #202124;
}

.compose-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--panel);
  min-width: 0;
}

.message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-left: auto;
}

.message-actions .primary {
  background: var(--brand);
  color: #fff;
}

.message-actions .primary:hover {
  background: var(--brand-strong);
  color: #fff;
}

.message-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(60, 64, 67, 0.06);
}

.message-tab {
  border-radius: 999px;
  padding: 9px 14px;
  background: #fff;
  color: #3c4043;
  border: 1px solid var(--line);
  font-weight: 800;
}

.message-tab.active {
  border-color: rgba(26, 115, 232, 0.38);
  background: #eaf2ff;
  color: #174ea6;
}

.message-tab.disabled {
  color: #9aa5b1;
  background: #f2f5f8;
}

.ai-summary-panel {
  border: 1px solid rgba(26, 115, 232, 0.16);
  border-radius: 8px;
  padding: 20px;
  background:
    linear-gradient(120deg, rgba(16, 42, 67, 0.05), rgba(26, 115, 232, 0.08)),
    #fff;
  box-shadow: 0 12px 30px rgba(60, 64, 67, 0.1);
}

.ai-summary-panel pre {
  margin: 0;
  white-space: pre-wrap;
  color: #202124;
  font: inherit;
  line-height: 1.55;
}

.settings-form {
  display: grid;
  gap: 18px;
  max-width: 620px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: var(--panel);
}

.compose-page {
  width: min(100%, 1280px);
}

.compose-card {
  overflow: hidden;
  border-color: rgba(26, 115, 232, 0.16);
  box-shadow: 0 18px 40px rgba(60, 64, 67, 0.12);
}

.compose-fields {
  display: grid;
  gap: 0;
  padding: 8px 22px 0;
}

.compose-fields label {
  position: relative;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-height: 52px;
  border-bottom: 1px solid #edf1f6;
  font-weight: 800;
}

.compose-fields input {
  border: 0;
  border-radius: 0;
  padding-inline: 0;
  background: transparent;
}

.recipient-suggestions {
  position: absolute;
  top: calc(100% - 5px);
  left: 110px;
  right: 0;
  z-index: 8;
  display: none;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(60, 64, 67, 0.18);
}

.recipient-suggestions.open {
  display: grid;
}

.recipient-suggestions button {
  justify-content: flex-start;
  min-height: 40px;
  border-radius: 0;
  padding: 8px 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.recipient-suggestions button:hover {
  background: #edf4ff;
  color: #174ea6;
}

.editor-field {
  display: grid;
  gap: 10px;
  padding: 18px 22px;
}

.editor-shell {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.wysiwyg-editor {
  width: 100%;
  min-width: 0;
  min-height: 260px;
  max-width: 100%;
  overflow-wrap: anywhere;
  overflow-x: hidden;
  padding: 18px;
  background: #fff;
  line-height: 1.58;
  font-weight: 400;
  outline: none;
}

.inline-reply .wysiwyg-editor {
  min-height: 170px;
}

.wysiwyg-editor *,
.wysiwyg-editor {
  font-weight: 400;
}

.wysiwyg-editor b,
.wysiwyg-editor strong {
  font-weight: 800;
}

.quoted-reply,
.forwarded-meta {
  border-left: 3px solid #d7e3f5;
  margin: 16px 0 0;
  padding: 8px 0 8px 14px;
  color: #4b5563;
}

.quoted-reply-meta {
  margin-top: 18px;
  color: #64748b;
  font-weight: 700;
}

.editor-shell:focus-within {
  border-color: rgba(26, 115, 232, 0.55);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.12);
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px solid #edf1f6;
  padding: 8px;
  background: #f8fafc;
}

.editor-toolbar button {
  min-height: 32px;
  border: 1px solid var(--line);
  background: #fff;
  color: #3c4043;
  padding: 0 10px;
}

.editor-toolbar button.active {
  border-color: rgba(26, 115, 232, 0.45);
  background: #eaf2ff;
  color: #174ea6;
}

.attachments-panel,
.inline-reply {
  margin-top: 18px;
  border: 1px solid rgba(26, 115, 232, 0.14);
  border-radius: 8px;
  padding: 22px;
  background: #fff;
  min-width: 0;
  overflow: hidden;
  box-shadow: 0 16px 38px rgba(60, 64, 67, 0.1);
}

.attachments-panel h2,
.inline-reply h2 {
  margin: 0;
  font-size: 1.15rem;
}

.inline-reply-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.inline-reply-form {
  border-color: rgba(26, 115, 232, 0.14);
  padding: 0;
  box-shadow: none;
}

.attachment-drop {
  margin: 0 22px 18px;
  border: 1px dashed #bdd0ea;
  border-radius: 8px;
  padding: 14px;
  background: #f8fbff;
  color: #475569;
  font-weight: 800;
}

.inline-reply .attachment-drop {
  margin: 14px 0 0;
}

.attachment-drop input {
  margin-top: 8px;
}

.js-file-summary {
  color: var(--muted);
  font-weight: 700;
}

.composer-actions {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid #edf1f6;
  padding: 14px 22px;
  background: #fbfdff;
}

.inline-reply .composer-actions {
  margin-top: 14px;
  padding: 14px 0 0;
  background: transparent;
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.attachment-chip {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fafc;
}

.attachment-chip span {
  font-weight: 800;
}

.attachment-chip small {
  color: var(--muted);
}

.sent-list,
.contacts-list {
  display: grid;
  gap: 10px;
}

.sent-row,
.contact-row {
  display: grid;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.08);
}

.sent-row div,
.contact-row {
  min-width: 0;
}

.contact-summary {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.sent-row strong,
.sent-row span,
.sent-row small,
.contact-row strong,
.contact-row span {
  display: block;
  overflow-wrap: anywhere;
}

.sent-row small,
.sent-row time,
.contact-row span,
.contact-row small {
  color: var(--muted);
}

.contact-filter-panel {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.08);
}

.contact-filter {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.contact-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.contact-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

.contact-form label:has(textarea),
.contact-form button {
  grid-column: 1 / -1;
}

.contact-edit {
  border-top: 1px solid #edf1f6;
  padding-top: 12px;
}

.contact-edit summary {
  cursor: pointer;
  color: var(--brand-strong);
  font-weight: 800;
}

.contact-edit .contact-form {
  margin-top: 12px;
}

.delete-form {
  margin: 0;
}

.delete-form button {
  background: #fff4f2;
  color: var(--danger);
}

.contact-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.contact-edit-dialog {
  width: min(720px, calc(100vw - 32px));
}

.contact-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #edf1f6;
  padding: 18px 22px;
}

.contact-edit-dialog .contact-form {
  padding: 22px;
}

.ai-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  height: calc(100vh - 60px);
  min-height: 620px;
}

.ai-sidebar,
.ai-chat {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(60, 64, 67, 0.1);
}

.ai-sidebar {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
}

.ai-sidebar button {
  width: 100%;
}

.ai-thread-list {
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
}

.ai-thread {
  display: grid;
  gap: 4px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 11px 12px;
  background: #f8fafc;
}

.ai-thread.active,
.ai-thread:hover {
  border-color: rgba(26, 115, 232, 0.22);
  background: #eaf2ff;
}

.ai-thread strong,
.ai-thread span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ai-thread span {
  color: var(--muted);
  font-size: 0.78rem;
}

.ai-chat {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.ai-chat-head {
  border-bottom: 1px solid #edf1f6;
  padding: 18px 22px;
}

.ai-chat-head h1 {
  margin: 0;
}

.ai-messages {
  display: grid;
  align-content: start;
  gap: 14px;
  overflow: auto;
  padding: 22px;
}

.ai-empty {
  place-self: center;
  max-width: 560px;
  color: var(--muted);
  text-align: center;
}

.ai-empty h2 {
  margin-bottom: 8px;
  color: var(--ink);
}

.ai-message {
  display: grid;
  gap: 6px;
  max-width: min(780px, 88%);
}

.ai-message span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.ai-message-content {
  margin: 0;
  border-radius: 8px;
  padding: 13px 15px;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.ai-message-content p,
.ai-message-content ul {
  margin: 0 0 12px;
}

.ai-message-content p:last-child,
.ai-message-content ul:last-child {
  margin-bottom: 0;
}

.ai-message-content ul {
  padding-left: 22px;
}

.ai-message-content code {
  border-radius: 5px;
  padding: 2px 5px;
  background: rgba(15, 23, 42, 0.08);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

.code-block {
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 8px;
  margin: 12px 0;
  background: #0f172a;
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 12px;
  color: #cbd5e1;
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.code-head button {
  min-height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  font-size: 0.72rem;
}

.code-head button:hover {
  background: rgba(255, 255, 255, 0.16);
}

.code-block pre {
  margin: 0;
  overflow-x: auto;
  padding: 14px;
  color: #e2e8f0;
  line-height: 1.55;
}

.code-block code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.ai-message.user {
  justify-self: end;
}

.ai-message.user .ai-message-content {
  background: var(--brand);
  color: #fff;
}

.ai-message.assistant .ai-message-content {
  background: #f1f5f9;
  color: var(--ink);
}

.ai-message.thinking .ai-message-content {
  color: var(--muted);
}

.ai-message.thinking .ai-message-content p::after {
  content: "";
  display: inline-block;
  width: 1.6em;
  animation: thinking-dots 1.2s steps(4, end) infinite;
}

@keyframes thinking-dots {
  0% {
    content: "";
  }
  25% {
    content: ".";
  }
  50% {
    content: "..";
  }
  75%,
  100% {
    content: "...";
  }
}

.ai-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  border-top: 1px solid #edf1f6;
  padding: 14px;
  background: #f8fbff;
}

.ai-compose textarea {
  resize: none;
}

.calendar-page {
  display: grid;
  gap: 18px;
}

.calendar-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid rgba(26, 115, 232, 0.14);
  border-radius: 8px;
  padding: 22px;
  background:
    linear-gradient(120deg, rgba(26, 115, 232, 0.1), rgba(15, 157, 88, 0.08)),
    #fff;
  box-shadow: 0 14px 34px rgba(60, 64, 67, 0.1);
}

.calendar-hero h1 {
  font-size: clamp(1.8rem, 3vw, 3rem);
}

.calendar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.calendar-board,
.calendar-agenda {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(60, 64, 67, 0.1);
}

.calendar-board {
  overflow: hidden;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays {
  border-bottom: 1px solid #edf1f6;
  background: #f8fbff;
}

.calendar-weekdays span {
  padding: 12px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.calendar-day {
  position: relative;
  min-width: 0;
  min-height: 138px;
  border-right: 1px solid #edf1f6;
  border-bottom: 1px solid #edf1f6;
  padding: 10px;
  background: #fff;
}

.calendar-day:nth-child(7n) {
  border-right: 0;
}

.calendar-day.outside {
  background: #f8fafc;
  color: #9aa5b1;
}

.calendar-day.today {
  background: #eef6ff;
  box-shadow: inset 0 0 0 2px rgba(26, 115, 232, 0.28);
}

.calendar-day-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.calendar-day-top strong {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  font-size: 0.86rem;
}

.calendar-day.today .calendar-day-top strong {
  background: var(--brand);
  color: #fff;
}

.calendar-day-add {
  width: 28px;
  min-width: 28px;
  min-height: 28px;
  border-radius: 999px;
  padding: 0;
  background: #eaf2ff;
  color: var(--brand-strong);
}

.calendar-day-events {
  display: grid;
  gap: 6px;
}

.calendar-event {
  width: 100%;
  min-height: 34px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  border-radius: 7px;
  padding: 6px 8px;
  text-align: left;
  box-shadow: none;
}

.calendar-event span {
  font-size: 0.7rem;
  font-weight: 900;
  opacity: 0.78;
}

.calendar-event strong {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.78rem;
}

.calendar-more {
  display: inline-flex;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.calendar-agenda {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 12px;
  padding: 16px;
}

.calendar-ai-panel {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(26, 115, 232, 0.16);
  border-radius: 8px;
  padding: 14px;
  background:
    linear-gradient(120deg, rgba(16, 42, 67, 0.05), rgba(26, 115, 232, 0.07)),
    #fff;
}

.calendar-ai-panel h3 {
  margin: 0;
}

.calendar-ai-panel form {
  display: grid;
  gap: 10px;
}

.calendar-ai-panel textarea {
  min-height: 96px;
  resize: vertical;
}

.calendar-ai-result {
  border: 1px solid rgba(15, 157, 88, 0.24);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f0fdf4;
  color: #137333;
  font-size: 0.9rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.calendar-agenda h2,
.agenda-day h3 {
  margin: 0;
}

.agenda-day {
  display: grid;
  gap: 8px;
}

.agenda-day h3 {
  color: #475569;
  font-size: 0.9rem;
}

.agenda-event {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.agenda-event div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.agenda-event strong,
.agenda-event span,
.agenda-event small {
  overflow-wrap: anywhere;
}

.agenda-event span,
.agenda-event small {
  color: var(--muted);
}

.color-blue {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #174ea6;
}

.color-green {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #137333;
}

.color-amber {
  border-color: #fde68a;
  background: #fffbeb;
  color: #8a5a00;
}

.color-red {
  border-color: #fecaca;
  background: #fff4f2;
  color: #b42318;
}

.color-violet {
  border-color: #ddd6fe;
  background: #f5f3ff;
  color: #5b21b6;
}

.calendar-form {
  display: grid;
  gap: 18px;
  padding: 28px;
  background:
    linear-gradient(120deg, rgba(26, 115, 232, 0.05), rgba(15, 157, 88, 0.04)),
    #fff;
}

.calendar-form-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.8fr 1fr;
  gap: 14px;
}

.calendar-form input,
.calendar-form textarea,
.calendar-form select {
  min-height: 46px;
  border-color: #d7e3f5;
  background: rgba(255, 255, 255, 0.94);
}

.calendar-form textarea {
  min-height: 170px;
}

.calendar-delete-form {
  margin-right: auto;
}

.files-page {
  display: grid;
  gap: 18px;
}

.files-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid rgba(26, 115, 232, 0.14);
  border-radius: 8px;
  padding: 22px;
  background:
    linear-gradient(120deg, rgba(26, 115, 232, 0.1), rgba(123, 97, 255, 0.08)),
    #fff;
  box-shadow: 0 14px 34px rgba(60, 64, 67, 0.1);
}

.files-hero h1 {
  font-size: clamp(1.8rem, 3vw, 3rem);
}

.files-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.files-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  color: var(--muted);
  font-weight: 800;
}

.files-breadcrumb a {
  color: var(--brand-strong);
}

.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 14px;
}

.files-inspector {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.files-inspector div {
  border: 1px solid rgba(26, 115, 232, 0.12);
  border-radius: 8px;
  padding: 14px 16px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(60, 64, 67, 0.06);
}

.files-inspector strong {
  display: block;
  font-size: 1.5rem;
}

.files-inspector span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.file-card {
  min-width: 0;
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background:
    linear-gradient(180deg, rgba(248, 251, 255, 0.9), rgba(255, 255, 255, 0.96)),
    #fff;
  box-shadow: 0 10px 28px rgba(60, 64, 67, 0.09);
}

.file-card:hover {
  border-color: rgba(26, 115, 232, 0.26);
  box-shadow: 0 16px 34px rgba(60, 64, 67, 0.12);
}

.file-card-main {
  min-width: 0;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.file-card-main strong,
.file-card-main small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-card-main small {
  grid-column: 2;
  color: var(--muted);
}

.file-icon {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #eaf2ff;
  color: #174ea6;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.folder-card .file-icon {
  background: #fff7d6;
  color: #8a5a00;
}

.file-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.share-list {
  display: grid;
  gap: 8px;
  border-top: 1px solid #edf1f6;
  padding-top: 12px;
}

.share-pill {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.share-pill input {
  min-height: 34px;
  border-color: #d7e3f5;
  background: #f8fbff;
  font-size: 0.82rem;
}

.share-pill button {
  min-height: 34px;
  background: #fff4f2;
  color: var(--danger);
}

.file-dialog {
  width: min(620px, calc(100vw - 32px));
}

.text-file-dialog {
  width: min(980px, calc(100vw - 32px));
}

.file-form {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.upload-progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6edf6;
}

.upload-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
  transition: width 160ms ease;
}

.text-file-form textarea {
  min-height: 420px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92rem;
  line-height: 1.55;
}

.contact-chip {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  border-radius: 8px;
  padding: 5px 9px;
  font: inherit;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.contact-chip.known {
  border: 1px solid rgba(19, 115, 51, 0.28);
  background: #eef8f0;
  color: #137333;
}

.contact-chip.unknown {
  border: 1px solid rgba(179, 38, 30, 0.28);
  background: #fff4f2;
  color: #b3261e;
  cursor: pointer;
}

.contact-chip.unknown:hover {
  background: #ffe8e4;
}

.contact-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 28px 80px rgba(32, 33, 36, 0.28);
}

.contact-dialog::backdrop {
  background: rgba(32, 33, 36, 0.28);
}

.contact-dialog form:first-child {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.contact-dialog h2 {
  margin: 0;
  font-size: 1.15rem;
}

.contact-dialog p {
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.dialog-backdrop-form {
  display: none;
}

dialog.calendar-dialog {
  width: min(1120px, calc(100vw - 40px));
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 40px);
  overflow: auto;
  border-color: rgba(26, 115, 232, 0.18);
}

dialog.calendar-dialog .contact-dialog-head {
  padding: 22px 28px;
  background:
    linear-gradient(120deg, rgba(26, 115, 232, 0.08), rgba(15, 157, 88, 0.06)),
    #fff;
}

dialog.calendar-dialog h2 {
  font-size: 1.35rem;
}

dialog.calendar-dialog .calendar-form {
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  align-items: start;
  padding: 28px;
}

dialog.calendar-dialog .calendar-form > input[type="hidden"] {
  display: none;
}

dialog.calendar-dialog .calendar-form > label:first-of-type,
dialog.calendar-dialog .calendar-form > .calendar-form-grid,
dialog.calendar-dialog .calendar-form > .dialog-actions {
  grid-column: 1 / -1;
}

dialog.calendar-dialog .calendar-form > label:nth-of-type(2) {
  grid-column: 1;
}

dialog.calendar-dialog .calendar-form > label:nth-of-type(3) {
  grid-column: 2;
}

dialog.calendar-dialog .calendar-form textarea {
  min-height: 260px;
  resize: vertical;
}

dialog.calendar-dialog .calendar-form-grid {
  grid-template-columns: 1.2fr 0.8fr 0.8fr 1fr;
}

.settings-form fieldset {
  display: grid;
  gap: 12px;
  margin: 0;
  border: 0;
  padding: 0;
}

.settings-form legend {
  margin-bottom: 4px;
  font-weight: 800;
}

.choice-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.choice-row input {
  width: auto;
}

dl {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 8px 14px;
  margin: 18px 0 0;
}

dt {
  color: var(--muted);
  font-weight: 800;
}

dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.message-body {
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 30px;
  background: transparent;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow-x: hidden;
  font: 1rem/1.68 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.message-html {
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0;
  min-height: 640px;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #fff;
  overflow: auto;
}

.message-body-shell {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  contain: layout inline-size;
  overflow: auto;
}

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

  .sidebar {
    position: static;
    z-index: 2;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    overflow-x: auto;
  }

  .sidebar nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
  }

  .sidebar form {
    margin-top: 0;
    margin-left: auto;
  }

  .content {
    width: 100vw;
    max-width: 100vw;
    padding: 14px;
  }

  .inbox-hero {
    grid-template-columns: 1fr;
  }

  .compose-fab {
    width: 100%;
  }

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

  .toolbar,
  .dashboard-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .message-topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
  }

  .message-actions {
    justify-content: flex-start;
    margin-left: 0;
    overflow-x: auto;
  }

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

  .message-subject-block {
    min-height: auto;
    padding: 22px;
  }

  .message-meta-card {
    grid-template-columns: 44px minmax(0, 1fr);
    padding: 18px;
  }

  .message-meta-card .avatar {
    width: 44px;
    height: 44px;
  }

  .message-body {
    padding: 20px;
  }

  .ai-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .ai-chat {
    min-height: 620px;
  }

  .ai-compose {
    grid-template-columns: 1fr;
  }

  .calendar-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .calendar-actions {
    justify-content: flex-start;
  }

  .calendar-layout {
    grid-template-columns: 1fr;
  }

  .calendar-agenda {
    position: static;
  }

  .calendar-weekdays {
    display: none;
  }

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

  .calendar-day {
    min-height: auto;
    border-right: 0;
  }

  .calendar-form-grid {
    grid-template-columns: 1fr;
  }

  dialog.calendar-dialog {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }

  dialog.calendar-dialog .contact-dialog-head {
    padding: 18px;
  }

  dialog.calendar-dialog .calendar-form {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  dialog.calendar-dialog .calendar-form > label:nth-of-type(2),
  dialog.calendar-dialog .calendar-form > label:nth-of-type(3) {
    grid-column: 1;
  }

  dialog.calendar-dialog .calendar-form-grid {
    grid-template-columns: 1fr;
  }

  .files-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .files-actions {
    justify-content: flex-start;
  }

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

  .files-inspector {
    grid-template-columns: 1fr;
  }

  .mail-row {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 6px;
  }

  .quick-actions {
    grid-column: 2;
    justify-content: flex-start;
    overflow-x: auto;
  }

  .date {
    text-align: left;
  }
}
