:root {
  color-scheme: light;
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "PingFang SC",
    sans-serif;
  color: #263b33;
  background: var(--page);
  font-size: 16px;
  --accent: #287663;
  --border: #dfe6df;
  --muted: #738078;
  --page: #f6f8f5;
  --surface: #fff;
  --hover: #edf3ee;
  --soft: #f2f5f2;
  --composer-border: #ccdacf;
  --strong: #456454;
  --warning: #fff2d8;
  --warning-border: #ebd29e;
  --error: #a84132;
  --on-accent: #fff;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  color: #e6ebe8;
  background: #151917;
  --accent: #55c59a;
  --border: #313a36;
  --muted: #9aa49f;
  --page: #151917;
  --surface: #1a201d;
  --hover: #1a2c24;
  --soft: #17251f;
  --composer-border: #46514c;
  --strong: #e6ebe8;
  --warning: #382919;
  --warning-border: #755a34;
  --error: #ed7b7b;
  --on-accent: #10231b;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
textarea,
select {
  font: inherit;
}
button,
select {
  cursor: pointer;
}
button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: inherit;
  border-radius: 9px;
  padding: 8px 12px;
  min-height: 38px;
}
button:hover {
  background: var(--hover);
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
button.primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}
a {
  color: var(--accent);
  text-decoration: none;
  overflow-wrap: anywhere;
}
a:hover {
  text-decoration: underline;
}
input,
textarea,
select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: var(--surface);
  color: inherit;
}
textarea {
  resize: vertical;
  line-height: 1.6;
  width: 100%;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
[hidden] {
  display: none !important;
}
header {
  height: 76px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 960px) / 2));
  gap: 20px;
  background: var(--page);
  position: sticky;
  top: 0;
  z-index: 2;
}
.identity,
.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.8px;
  white-space: nowrap;
}
.divider {
  height: 20px;
  border-left: 1px solid var(--border);
}
h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
}
.header-actions {
  gap: 8px;
  flex-shrink: 0;
}
.header-icon {
  width: 40px;
  height: 40px;
  padding: 8px;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
}
.header-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.theme-toggle .theme-sun,
:root[data-theme="dark"] .theme-toggle .theme-moon {
  display: none;
}
:root[data-theme="dark"] .theme-toggle .theme-sun {
  display: block;
}
.login-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
#toggle-search .close-icon,
header.searching #toggle-search .search-icon {
  display: none;
}
header.searching #toggle-search .close-icon {
  display: block;
}
header.searching #sync-state {
  display: none;
}
#filter {
  width: 80px;
  min-height: 40px;
  padding: 8px 0 8px 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 14px;
}
#sync-state {
  font-size: 13px;
  color: var(--muted);
  margin-right: 8px;
}
main {
  max-width: 820px;
  margin: auto;
  padding: 24px 24px 220px;
}
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  flex: 1;
  min-width: 0;
  max-width: 300px;
}
.search input {
  border: 0;
  width: 100%;
  min-width: 0;
  background: none;
}
.date-heading {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  margin: 26px 2px 10px;
}
.message {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
  margin: 10px 0;
}
.message-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}
.message-head time {
  flex: 1;
}
.message-head button {
  font-size: 13px;
  padding: 4px 8px;
  min-height: 30px;
  border-color: transparent;
}
.message-head details {
  position: relative;
}
.message-head summary {
  cursor: pointer;
  padding: 6px 10px;
  list-style: none;
}
.menu {
  position: absolute;
  right: 0;
  z-index: 1;
  background: var(--surface);
  box-shadow: 0 4px 24px #183c2524;
  border: 1px solid var(--border);
  padding: 6px;
  border-radius: 10px;
  min-width: 112px;
  display: grid;
  gap: 4px;
}
.menu button {
  text-align: left;
}
.message-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.65;
  margin: 0;
}
.message-body.collapsed {
  display: -webkit-box;
  -webkit-line-clamp: 8;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.message.completed .message-body {
  color: var(--muted);
}
.body-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.body-row input {
  /* Center on the first text line, including when the message wraps. */
  margin: calc(0.825em - 9px) 0 0;
  padding: 0;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
.body-content {
  min-width: 0;
  flex: 1;
}
.links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.links a {
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  max-width: 100%;
}
.photo-button {
  border: 0;
  padding: 0;
  max-width: 100%;
  background: var(--soft);
  display: block;
  margin-bottom: 10px;
}
.photo-button img {
  display: block;
  max-width: 100%;
  max-height: 260px;
  border-radius: 9px;
}
.empty {
  padding: 60px 16px;
  text-align: center;
  color: var(--muted);
  line-height: 1.8;
}
.empty strong {
  font-size: 20px;
  color: var(--strong);
  font-weight: 500;
}
.compose-wrap {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, var(--page) 14%);
  padding: 22px 24px max(18px, env(safe-area-inset-bottom));
  z-index: 2;
}
#composer {
  max-width: 772px;
  margin: auto;
  background: var(--surface);
  border: 1px solid var(--composer-border);
  border-radius: 15px;
  padding: 12px 14px;
  box-shadow: 0 5px 24px #203b250a;
}
#body {
  border: 0;
  padding: 2px 4px;
  max-height: 180px;
  min-height: 54px;
  resize: vertical;
}
.compose-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}
.todo-switch {
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.todo-switch input {
  accent-color: var(--accent);
}
.shortcut {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}
.compose-actions #send {
  margin-left: auto;
}
.compose-actions button {
  font-size: 14px;
}
.muted {
  color: var(--muted);
  font-size: 14px;
}
#error,
.draft-error {
  background: var(--warning);
  border: 1px solid var(--warning-border);
  border-radius: 10px;
  padding: 12px;
  line-height: 1.6;
  font-size: 14px;
}
#attachment {
  font-size: 13px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px;
}
#attachment-name {
  overflow-wrap: anywhere;
}
#toast {
  position: fixed;
  bottom: 220px;
  left: 50%;
  transform: translateX(-50%);
  background: #263b33;
  color: white;
  border-radius: 10px;
  padding: 10px 18px;
  z-index: 10;
  max-width: 90%;
  font-size: 14px;
}
.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  max-width: 450px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
}
.login-card h1 {
  font-size: 24px;
  margin-top: 28px;
  line-height: 1.5;
}
.login-card p {
  line-height: 1.7;
}
.login-card label {
  display: block;
  margin: 24px 0 8px;
}
.login-card > button {
  width: 100%;
  margin-top: 12px;
}
#login-error {
  color: var(--error);
}
dialog {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  max-width: calc(100vw - 32px);
  width: 540px;
  color: inherit;
  background: var(--surface);
}
dialog::backdrop {
  background: #11251a66;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}
dialog h2 {
  margin-top: 0;
  font-size: 20px;
}
#image-view {
  width: auto;
  max-width: 90vw;
  max-height: 90dvh;
}
#full-image {
  display: block;
  max-width: 100%;
  max-height: 74dvh;
  margin-top: 10px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
@media (max-width: 600px) {
  header {
    padding: 0 12px;
    height: 66px;
    gap: 8px;
  }
  .identity {
    gap: 8px;
  }
  .identity .divider,
  .identity h1 {
    display: none;
  }
  header.searching .identity,
  header.searching #refresh,
  header.searching #logout {
    display: none;
  }
  .search {
    max-width: none;
  }
  .brand {
    font-size: 20px;
  }
  h1 {
    font-size: 17px;
  }
  #sync-state {
    display: none;
  }
  .header-actions {
    gap: 4px;
  }
  .header-icon {
    width: 38px;
    height: 40px;
  }
  #filter {
    width: 72px;
  }
  main {
    padding: 18px 14px 215px;
  }
  .compose-wrap {
    padding-left: 12px;
    padding-right: 12px;
  }
  .shortcut {
    display: none;
  }
  .compose-actions {
    gap: 8px;
  }
  .message {
    padding: 12px 14px;
  }
  .login-card {
    padding: 24px;
  }
}

.login-card input {
  width: 100%;
}
@media (max-width: 360px) {
  header {
    height: auto;
    min-height: 66px;
    flex-wrap: wrap;
    padding-top: 10px;
    padding-bottom: 10px;
    row-gap: 6px;
  }
  .header-actions {
    margin-left: auto;
  }
}
