:root {
  color-scheme: light dark;
  --ink: #10231b;
  --muted: #52675d;
  --surface: #fff;
  --canvas: #eff7f2;
  --line: #d4e2da;
  --mint: #d9f7ed;
  --lime: #d7ff5e;
  --on-lime: #11241a;
  --note: #fff2d5;
  --error: #a12834;
  --copy-icon: #84888d;
  font: 16px/1.5 system-ui, "Noto Sans Thai", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f1f8f3;
    --muted: #afc3b8;
    --surface: #182a21;
    --canvas: #101b16;
    --line: #395348;
    --mint: #234637;
    --note: #433820;
    --error: #ffc2c9;
    --copy-icon: #b0b4ba;
  }
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid #268878; outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }

#app { width: min(100%, 620px); margin-inline: auto; }
.workspace { min-height: 100dvh; background: var(--surface); border-inline: 1px solid var(--line); }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 64px; padding: max(8px, env(safe-area-inset-top)) 16px 8px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 5px; font-size: 18px; font-weight: 700; letter-spacing: -.04em; white-space: nowrap; }
.brand small { margin-left: 2px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0; }
.brand svg { flex: none; }
.brand .mini-product-logo { display: block; width: auto; height: 21.3px; }

.login { max-width: 450px; margin-inline: auto; padding: max(clamp(28px, 8vh, 84px), env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom)); }
:root:has(#app > .login) {
  color-scheme: light;
  --canvas: #f4f2ee;
  --surface: #fff;
  --ink: #111014;
  --muted: #606065;
  --line: #dedbd5;
  --error: #a12834;
}
.login > .brand { justify-content: center; }
.mini-login-logo { display: block; width: 118px; height: auto; }
.login-form .primary { background: #000; color: #fff; }
.login-form .primary:hover:not(:disabled) { background: #242424; }
@media (prefers-color-scheme: dark) {
  :root:has(#app > .login) {
    color-scheme: dark;
    --canvas: #111014;
    --surface: #201f24;
    --ink: #f6f5f2;
    --muted: #c1bec5;
    --line: #4b4951;
    --error: #ffc2c9;
  }
  .mini-login-logo { background: #f4f2ee; border-radius: 6px; padding: 3px 5px; width: 128px; }
  .login-form .primary { border-color: #77737d; }
}
.login > h1 { margin: 18px 0 4px; font-size: clamp(25px, 7vw, 34px); letter-spacing: -.04em; }
.login > p { color: var(--muted); }
.login-card { margin-top: 20px; padding: clamp(14px, 5vw, 22px); border: 1px solid var(--line); border-radius: 24px; background: var(--surface); }
.line-sign-in { display: grid; gap: 8px; }
.line-button { display: grid; grid-template-columns: 40px minmax(0, 1fr) 40px; align-items: center; min-height: 52px; padding: 4px 8px; border: 1px solid transparent; border-radius: 16px; background: #06c755; color: #0c2316; font-weight: 750; }
.line-button:hover { background: #27d36c; }
.line-mark { justify-self: center; padding: 4px 5px; border-radius: 8px; background: #fff; color: #0c2316; font-size: 10px; font-weight: 850; line-height: 1; }
.line-arrow { font-size: 22px; line-height: 1; }
.line-sign-in p { color: var(--muted); text-align: center; font-size: 13px; }
.login-divider { display: flex; align-items: center; gap: 10px; margin-block: 18px; color: var(--muted); font-size: 13px; text-align: center; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.login-form { display: grid; gap: 12px; }
.login-form label { display: grid; gap: 5px; font-size: 14px; font-weight: 600; }
.login-form .error { padding: 0; }
.login-password-field { display: grid; gap: 5px; }
.login-password-field > div { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.login-password-field a { color: var(--ink); font-size: 13px; text-underline-offset: 2px; }
.line-dialog h2 { font-size: 20px; }
.line-dialog p { margin-top: 8px; color: var(--muted); }
.line-dialog form { display: flex; justify-content: flex-end; margin-top: 16px; }
input, textarea, select { min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--canvas); }
.primary, .quiet, .icon, .filters button { border: 1px solid transparent; border-radius: 999px; min-height: 44px; padding: 7px 13px; }
.primary { background: var(--lime); color: var(--on-lime); font-weight: 700; }
.quiet, .icon { background: transparent; color: var(--muted); font-size: 13px; }
.quiet:hover, .icon:hover { background: var(--canvas); }
.error { color: var(--error); font-size: 13px; padding: 0 16px; overflow-wrap: anywhere; }
.error:empty { display: none; }

.inbox-heading { display: flex; align-items: end; justify-content: space-between; gap: 10px; padding: 20px 16px 14px; }
.inbox-heading h1 { font-size: clamp(24px, 6vw, 32px); }
.overline, .workspace-name, select { color: var(--muted); font-size: 12px; }
.inbox-heading select { max-width: 46%; }
.workspace-name { max-width: 43%; text-align: end; overflow-wrap: anywhere; }
.filters { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 16px 12px; }
.filters button { min-height: 44px; background: var(--canvas); color: var(--muted); border-color: var(--line); font-size: 13px; white-space: nowrap; }
.filters [aria-pressed="true"] { background: var(--mint); color: var(--ink); border-color: #63b39c; font-weight: 700; }
.conversation-list { border-top: 1px solid var(--line); }
.conversation { display: flex; align-items: center; width: 100%; gap: 10px; min-height: 74px; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); text-align: start; }
.conversation:hover { background: var(--canvas); }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%; color: #123329; background: #a9eadc; font-weight: 700; }
.conversation:nth-child(3n+2) .avatar { background: #ffdac9; }
.conversation:nth-child(3n) .avatar { background: #e2f3aa; }
.conversation-copy { flex: 1; min-width: 0; }
.conversation-copy > * { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.snippet, .channel { color: var(--muted); font-size: 12px; }
.conversation-meta { display: grid; justify-items: end; gap: 4px; }
.unread { display: grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px; background: var(--lime); color: var(--on-lime); font-size: 11px; font-weight: 700; }
.empty { padding: 24px 16px; color: var(--muted); text-align: center; }
.list-actions { display: flex; justify-content: flex-end; padding: 6px 16px; }

.thread { display: flex; flex-direction: column; height: 100dvh; min-height: 0; }
.thread-bar {
  justify-content: flex-start;
  min-height: 52px;
  gap: 2px;
  padding: max(4px, env(safe-area-inset-top)) 6px 4px;
}
.thread-title { flex: 1; min-width: 0; }
.thread-title h1 { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-title > span { color: var(--muted); font-size: 12px; }
.icon { width: 44px; padding: 0; font-size: 28px; line-height: 1; }
.thread-bar .icon { flex: none; }
.thread-assignee { max-width: 24%; padding-inline: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-action { display: grid; place-items: center; }
.thread-action svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.messages { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 16px; background: var(--canvas); }

/* Keep scrolling inside the inbox or thread when a vertical gesture reaches an edge. */
html:has(#app > .thread, #app > .workspace > .conversation-list),
body:has(#app > .thread, #app > .workspace > .conversation-list) {
  overflow: hidden;
  overscroll-behavior-y: none;
}

#app > .workspace:has(> .conversation-list) {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
}

#app > .workspace > .conversation-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.conversation-list, .messages {
  overscroll-behavior-y: contain;
}
.message { max-width: 84%; padding: 10px 13px; border-radius: 16px; background: var(--surface); align-self: flex-start; }
.message p { white-space: pre-wrap; overflow-wrap: anywhere; }
.message.outgoing { align-self: flex-end; background: var(--mint); }
.message.note { background: var(--note); align-self: stretch; max-width: 100%; }
.message small { display: block; margin-bottom: 3px; color: var(--muted); }
dialog { width: min(90%, 360px); padding: 20px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 22px; }
dialog::backdrop { background: #09171080; }
.assign-dialog h2 { font-size: 18px; margin-bottom: 8px; }
.assign-dialog [data-agent] { display: block; width: 100%; min-height: 44px; padding: 8px; text-align: start; border: 0; border-bottom: 1px solid var(--line); background: transparent; }

.ai-status { padding: 8px 16px; background: var(--mint); color: var(--ink); font-size: 12px; }
.login-form .backup-option { display: flex; align-items: center; gap: 8px; }

.composer {
  display: grid;
  gap: 2px;
  margin: 6px 8px max(6px, env(safe-area-inset-bottom));
  padding: 5px 6px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
}

.composer textarea {
  width: 100%;
  min-height: calc(3em + 8px);
  max-height: 100px;
  padding: 6px 7px 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  resize: none;
  field-sizing: content;
}

.composer textarea:focus-visible { outline: none; }

.composer:has(textarea:focus-visible) {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ink) 10%, transparent);
}

.composer-toolbar,
.composer-modes {
  display: flex;
  align-items: center;
  gap: 6px;
}

.composer-toolbar { flex-wrap: wrap; }

.composer-toolbar button,
.composer .composer-send {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}

.composer-toolbar button:hover,
.composer-toolbar button[aria-pressed="true"] {
  background: var(--mint);
  color: var(--ink);
}

.composer-toolbar svg,
.composer .composer-send svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.composer .composer-send {
  margin-inline-start: auto;
  background: var(--lime);
  color: var(--on-lime);
}

.attachment-queue {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.attachment-queue li {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding-inline-start: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 12px;
}

.attachment-queue li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-link { display: block; color: inherit; overflow-wrap: anywhere; }
[data-composer-dialog] h2 { margin-bottom: 8px; font-size: 18px; }
.emoji-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.canned-list { display: grid; gap: 6px; max-height: 45dvh; overflow: auto; }
.emoji-grid button, .canned-list button {
  min-height: 44px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--canvas);
}
.emoji-grid button { font-size: 22px; }
.canned-list button { text-align: start; }
.canned-list small { display: block; white-space: pre-wrap; overflow-wrap: anywhere; }

.composer.is-private-note {
  border-color: #a77c32;
  box-shadow: inset 0 2px #a77c32;
}

[data-recap-dialog] h2 { margin-bottom: 8px; font-size: 18px; }
[data-recap-status] { color: var(--muted); font-size: 13px; }
[data-recap-text] { width: 100%; margin-top: 8px; resize: vertical; }
.recap-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.messages { padding-inline: clamp(20px, 6vw, 32px); }
.message.incoming { background: transparent; padding-inline: 0; }
.composer { margin-inline: 14px; }
.thread-search { padding: 6px 14px; }
.thread-search input { width: 100%; }
.message-copy {
  display: grid;
  place-items: center;
  width: 36px;
  height: 32px;
  margin-top: 2px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--copy-icon);
}
.message-copy:hover { background: var(--surface); }
.message-copy svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.copy-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.mobile-team-thread {
  background: var(--mint);
}
.mobile-team-thread .message.incoming {
  background: var(--surface);
  padding: 10px 12px;
}
.mobile-team-thread .message.outgoing {
  background: var(--canvas);
}
.mobile-team-thread > button {
  align-self: center;
}
.mobile-team-tabs,
.mobile-team-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .875rem;
}
.mobile-team-tabs {
  align-self: center;
  padding: 4px;
  margin: 4px 0;
  border-radius: 999px;
  background: var(--canvas);
}
.mobile-team-tabs button,
.mobile-team-actions button:not(.composer-send) {
  min-height: 40px;
  padding: 4px 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
}
.mobile-team-tabs button[aria-pressed="true"],
.mobile-team-actions button:not(.composer-send) {
  background: var(--surface);
  box-shadow: 0 1px 3px #0002;
}
.composer.mobile-team-composer {
  background: var(--mint);
}
.thread-search [data-search-count]:not(:empty) {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}
.messages mark {
  background: #ffe287;
  color: #241a05;
  border-radius: 3px;
}

.workspace-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  max-width: 52%;
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--canvas);
  color: var(--ink);
  font-size: 16px;
  text-align: start;
}
.workspace-picker span:first-child { overflow-wrap: anywhere; }
.workspace-dialog { width: min(calc(100% - 32px), 440px); border-radius: 24px; }
.workspace-dialog h2 { margin-bottom: 12px; font-size: 20px; }
.workspace-options { display: grid; gap: 6px; max-height: 55dvh; overflow-y: auto; }
.workspace-options button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 52px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--canvas);
  font-size: 17px;
  text-align: start;
  overflow-wrap: anywhere;
}
.workspace-options button[aria-pressed="true"] { background: var(--mint); font-weight: 650; }
.workspace-dialog form { display: flex; justify-content: flex-end; margin-top: 8px; }

.ai-status {
  align-self: center;
  max-width: calc(100% - 28px);
  margin: 4px 14px 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  text-align: center;
}
[data-ai-confirm] h2 { margin-bottom: 8px; font-size: 18px; }
[data-ai-confirm] p { color: var(--muted); }

.team-preview-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); font-size: 13px; }
.inbox-team-link { margin-inline: 16px; }
.team-body { display: grid; gap: 16px; padding: 16px; }
.team-body p { color: var(--muted); }
.team-preview-banner { padding: 10px 12px; border-radius: 12px; background: var(--canvas); font-size: 12px; }
.team-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.team-sample-links { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.team-sample-links a { text-underline-offset: 3px; }
.team-body h1 { font-size: clamp(23px, 6vw, 30px); }
.team-body h2 { font-size: 18px; }
.team-seat { padding: 5px 10px; border-radius: 999px; background: var(--mint); white-space: nowrap; font-size: 13px; }
.team-invite, .team-activation { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 18px; }
.team-invite > div { display: flex; flex-wrap: wrap; gap: 8px; }
.team-invite input { flex: 1 1 140px; }
.team-feedback { display: grid; gap: 6px; }
.team-feedback:empty { display: none; }
.team-members { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.team-members li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; }
.team-members strong { overflow-wrap: anywhere; }
.team-members small { display: block; color: var(--muted); }
.team-member-action { flex: 0 1 auto; background: var(--canvas); }
.team-dialog p { margin-top: 8px; }

.member-inboxes { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 6px; }
.member-inboxes label { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.member-inboxes input { width: 18px; height: 18px; }
.member-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.team-workspace-label { display: grid; gap: 6px; }
