:root {
  color-scheme: light;
  --ink-950: #111917;
  --ink-900: #17211f;
  --ink-800: #26312e;
  --ink-700: #3f4c48;
  --ink-600: #5e6965;
  --ink-500: #7a8480;
  --line-strong: #cfc9bd;
  --line: #dfdbd2;
  --line-soft: #ebe7df;
  --paper: #fffdf9;
  --paper-warm: #f6f3ed;
  --paper-deep: #ede8df;
  --accent: #bd461d;
  --accent-hover: #993413;
  --accent-soft: #f7e7de;
  --green: #16845f;
  --green-soft: #e1f2eb;
  --red: #b3261e;
  --red-soft: #fbe8e5;
  --amber: #a76010;
  --amber-soft: #fbf0d9;
  --shadow-small: 0 3px 12px rgb(17 25 23 / 8%);
  --shadow-modal: 0 28px 80px rgb(17 25 23 / 24%);
  --font-body: "Aptos", "Segoe UI Variable Text", "Noto Sans SC", "Microsoft YaHei UI", sans-serif;
  --font-display: "Bahnschrift", "Aptos Display", "Noto Sans SC", "Microsoft YaHei UI", sans-serif;
  --font-mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --header-height: 72px;
  --footer-height: 36px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  background: var(--paper-warm);
  font-size: 16px;
}

body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink-900);
  background: var(--paper-warm);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button,
select,
input[type="checkbox"] {
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
}

button,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

::selection {
  color: var(--ink-950);
  background: #f0bca6;
}

:focus-visible {
  outline: 3px solid rgb(189 70 29 / 34%);
  outline-offset: 2px;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: #bbb5ab;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background-color: #918b82;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .15em;
  line-height: 1.4;
  text-transform: uppercase;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--ink-500);
  box-shadow: 0 0 0 3px rgb(122 132 128 / 12%);
}

.status-dot.online,
.status-dot.working {
  background: var(--green);
  box-shadow: 0 0 0 3px rgb(22 132 95 / 14%);
}

.status-dot.warning {
  background: var(--amber);
  box-shadow: 0 0 0 3px rgb(167 96 16 / 15%);
}

.button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button:disabled {
  opacity: .47;
}

.button-primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 2px 0 rgb(101 39 16 / 14%);
}

.button-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 5px 14px rgb(153 52 19 / 18%);
}

.button-quiet {
  color: var(--ink-800);
  background: var(--paper);
  border-color: var(--line-strong);
}

.button-quiet:hover:not(:disabled) {
  color: var(--ink-950);
  border-color: #a7a197;
  background: #fff;
}

.button-ghost {
  color: var(--ink-600);
  background: transparent;
  border-color: transparent;
}

.button-ghost:hover:not(:disabled) {
  color: var(--ink-900);
  background: rgb(255 255 255 / 7%);
}

.icon-button {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink-700);
  background: transparent;
  font-size: 19px;
  line-height: 1;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.icon-button:hover {
  color: var(--ink-950);
  border-color: var(--line-strong);
  background: var(--paper-warm);
}

.text-button {
  min-width: 56px;
  border: 0;
  padding: 0 13px;
  color: var(--accent);
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

.text-button:hover {
  color: var(--accent-hover);
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field > span:first-child,
.field-label-row {
  color: var(--ink-700);
  font-size: 13px;
  font-weight: 700;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 10px 12px;
  color: var(--ink-950);
  background: #fff;
  caret-color: var(--accent);
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.field textarea {
  min-height: 132px;
  resize: vertical;
  line-height: 1.62;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #98958e;
}

.field input:hover,
.field textarea:hover,
.field select:hover {
  border-color: #aaa49a;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgb(189 70 29 / 12%);
}

.field-compact {
  max-width: 150px;
}

.password-wrap {
  min-height: 44px;
  display: flex;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.password-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(189 70 29 / 12%);
}

.password-wrap input {
  min-width: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none !important;
}

.form-error {
  display: block;
  min-height: 21px;
  color: var(--red);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.55;
}

/* Login */
.login-view {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(420px, 1.08fr) minmax(420px, .92fr);
  background: var(--paper-warm);
}

.login-brand-panel {
  position: relative;
  isolation: isolate;
  min-height: 100dvh;
  overflow: hidden;
  padding: clamp(34px, 5vw, 72px);
  display: flex;
  flex-direction: column;
  color: #f7f4ee;
  background: var(--ink-950);
}

.login-brand-panel::before,
.login-brand-panel::after {
  content: "";
  position: absolute;
  z-index: -1;
  pointer-events: none;
}

.login-brand-panel::before {
  inset: 0;
  opacity: .32;
  background-image:
    linear-gradient(rgb(255 255 255 / 4%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 4%) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 78%);
}

.login-brand-panel::after {
  width: 220px;
  height: 220px;
  right: -110px;
  top: 17%;
  border: 44px solid rgb(189 70 29 / 28%);
  border-radius: 50%;
}

.brand-lockup,
.header-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-lockup > span:last-child,
.header-brand > span:last-child {
  display: grid;
  gap: 1px;
}

.brand-lockup b,
.header-brand b {
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: .12em;
  line-height: 1.05;
}

.brand-lockup small,
.header-brand small {
  color: #a9b2ae;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: .16em;
}

.brand-mark {
  position: relative;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: block;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 10%);
  border-radius: 10px;
  background: #202a27;
}

.brand-mark i {
  position: absolute;
  left: 9px;
  width: 22px;
  height: 7px;
  display: block;
  transform: skewY(-24deg);
  border-radius: 2px;
}

.brand-mark i:nth-child(1) {
  top: 9px;
  background: #f07037;
}

.brand-mark i:nth-child(2) {
  top: 17px;
  background: #e7e2d8;
}

.brand-mark i:nth-child(3) {
  top: 25px;
  width: 14px;
  background: #34a982;
}

.brand-lockup-large .brand-mark {
  width: 48px;
  height: 48px;
  flex-basis: 48px;
}

.brand-lockup-large .brand-mark i {
  left: 11px;
  width: 26px;
}

.brand-lockup-large .brand-mark i:nth-child(1) { top: 11px; }
.brand-lockup-large .brand-mark i:nth-child(2) { top: 20px; }
.brand-lockup-large .brand-mark i:nth-child(3) { top: 29px; width: 16px; }

.login-manifesto {
  width: min(590px, 92%);
  margin: auto 0;
  padding: 80px 0;
}

.login-manifesto .eyebrow {
  color: #ef8657;
}

.login-manifesto h1 {
  margin-bottom: 24px;
  font-family: var(--font-display);
  font-size: clamp(42px, 5.4vw, 76px);
  font-weight: 700;
  letter-spacing: -.045em;
  line-height: 1.08;
}

.login-manifesto > p:last-child {
  max-width: 510px;
  margin: 0;
  color: #b8c0bc;
  font-size: 16px;
  line-height: 1.85;
}

.login-system-line {
  padding-top: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid rgb(255 255 255 / 12%);
  color: #a8b1ad;
  font-family: var(--font-mono);
  font-size: 11px;
}

.login-system-line span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.login-form-panel {
  min-height: 100dvh;
  padding: clamp(28px, 6vw, 88px);
  display: grid;
  place-items: center;
}

.login-card {
  width: min(430px, 100%);
  display: grid;
  gap: 20px;
}

.login-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(28px, 3vw, 38px);
  letter-spacing: -.025em;
  line-height: 1.2;
}

.form-intro {
  margin: -9px 0 5px;
  color: var(--ink-600);
  line-height: 1.75;
}

.agreement-row,
.send-confirm-check {
  display: grid;
  grid-template-columns: 19px 1fr;
  align-items: start;
  gap: 10px;
  color: var(--ink-600);
  font-size: 13px;
  line-height: 1.65;
}

.agreement-row input,
.send-confirm-check input {
  width: 17px;
  height: 17px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.login-submit {
  min-height: 48px;
  justify-content: space-between;
  padding-inline: 18px;
}

.login-submit b {
  font-size: 18px;
}

/* Main application shell */
.sms-app {
  min-height: 100dvh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) var(--footer-height);
  overflow: hidden;
  background: var(--paper-warm);
}

.app-header {
  position: relative;
  z-index: 20;
  min-height: var(--header-height);
  padding: 12px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  color: #f7f5f0;
  background: var(--ink-950);
  border-bottom: 3px solid var(--accent);
}

.header-brand {
  flex: 0 0 auto;
}

.header-brand b {
  font-size: 16px;
  letter-spacing: .06em;
}

.brand-mark-compact {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
  border-radius: 8px;
}

.brand-mark-compact i {
  left: 7px;
  width: 20px;
  height: 6px;
}

.brand-mark-compact i:nth-child(1) { top: 8px; }
.brand-mark-compact i:nth-child(2) { top: 15px; }
.brand-mark-compact i:nth-child(3) { top: 22px; width: 12px; }

.header-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.app-header .button {
  min-height: 38px;
}

.app-header .button-quiet {
  color: #e7e9e7;
  background: rgb(255 255 255 / 5%);
  border-color: rgb(255 255 255 / 18%);
}

.app-header .button-quiet:hover:not(:disabled) {
  color: #fff;
  border-color: rgb(255 255 255 / 34%);
  background: rgb(255 255 255 / 10%);
}

.app-header .button-ghost {
  color: #adb6b2;
}

.refresh-status {
  min-width: 118px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  color: #b7c0bc;
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
}

.refresh-status > i {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: #75817d;
}

.refresh-status > i.online {
  background: #30c18d;
  box-shadow: 0 0 0 4px rgb(48 193 141 / 10%);
}

.refresh-status > i.working {
  background: #efa060;
  box-shadow: 0 0 0 4px rgb(239 160 96 / 12%);
  animation: status-pulse 1s ease-in-out infinite;
}

.refresh-status > i.error {
  background: #ef776f;
  box-shadow: 0 0 0 4px rgb(239 119 111 / 12%);
}

.device-picker {
  height: 38px;
  max-width: 250px;
  display: flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 7px;
  background: rgb(255 255 255 / 5%);
}

.device-picker > span {
  height: 100%;
  padding: 0 10px;
  display: grid;
  place-items: center;
  border-right: 1px solid rgb(255 255 255 / 14%);
  color: #909b97;
  font-size: 11px;
}

.device-picker select {
  min-width: 0;
  max-width: 185px;
  height: 100%;
  border: 0;
  padding: 0 28px 0 10px;
  color: #f3f4f2;
  background: transparent;
  font-size: 12px;
  outline: none;
}

.device-picker select option {
  color: var(--ink-900);
  background: #fff;
}

.cloud-account-button {
  max-width: 210px;
}

.cloud-account-button span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.refresh-icon {
  display: inline-block;
  font-size: 16px;
  line-height: 1;
}

.is-loading .refresh-icon {
  animation: spin 800ms linear infinite;
}

.app-main {
  min-height: 0;
  padding: 20px 24px;
  display: grid;
  overflow: hidden;
}

.app-main > section {
  min-width: 0;
  min-height: 0;
}

.app-footer {
  height: var(--footer-height);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 22px;
  color: var(--ink-600);
  background: #e8e3da;
  border-top: 1px solid var(--line-strong);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .025em;
}

.app-footer span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.app-footer span:last-child {
  margin-left: auto;
}

/* Cloud account setup */
.setup-view {
  width: min(1040px, 100%);
  max-height: 100%;
  margin: auto;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(380px, .95fr);
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: var(--shadow-small);
}

.setup-copy {
  position: relative;
  overflow: hidden;
  padding: clamp(38px, 5vw, 66px);
  color: #eff2ef;
  background: var(--ink-900);
}

.setup-copy::after {
  content: "CLOUD / SMS";
  position: absolute;
  right: -16px;
  bottom: 6px;
  color: rgb(255 255 255 / 4%);
  font-family: var(--font-display);
  font-size: clamp(52px, 8vw, 92px);
  font-weight: 800;
  letter-spacing: -.05em;
  white-space: nowrap;
  pointer-events: none;
}

.setup-index {
  width: 42px;
  height: 42px;
  margin-bottom: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 50%;
  color: #f2a07a;
  font-family: var(--font-mono);
  font-size: 12px;
}

.setup-copy .eyebrow {
  color: #f2a07a;
}

.setup-copy h1 {
  margin-bottom: 18px;
  font-family: var(--font-display);
  font-size: clamp(32px, 4vw, 48px);
  letter-spacing: -.035em;
  line-height: 1.15;
}

.setup-copy > p:not(.eyebrow) {
  max-width: 510px;
  margin-bottom: 30px;
  color: #b9c2be;
  line-height: 1.85;
}

.privacy-points {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 20px 0 0;
  display: grid;
  gap: 13px;
  border-top: 1px solid rgb(255 255 255 / 11%);
  list-style: none;
  color: #c9cfcc;
  font-size: 13px;
}

.privacy-points li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.privacy-points i {
  width: 6px;
  height: 6px;
  margin-top: 7px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: #39aa83;
}

.setup-card {
  padding: clamp(34px, 5vw, 62px);
  display: grid;
  align-content: center;
  gap: 19px;
}

.setup-card-head {
  margin-bottom: 7px;
  padding-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.setup-card-head span {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
}

.setup-card-head small {
  color: var(--ink-500);
  font-family: var(--font-mono);
  font-size: 10px;
}

.setup-submit {
  min-height: 47px;
  margin-top: 4px;
}

.credential-note {
  margin: -5px 0 0;
  color: var(--ink-500);
  font-size: 12px;
  line-height: 1.65;
}

/* Device empty state */
.empty-view {
  width: min(620px, 100%);
  margin: auto;
  padding: 60px 28px;
  text-align: center;
}

.empty-symbol {
  width: 70px;
  height: 70px;
  margin: 0 auto 24px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--accent);
  background: var(--paper);
  font-family: var(--font-mono);
  font-size: 24px;
}

.empty-view h2 {
  margin-bottom: 12px;
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: -.02em;
}

.empty-view p {
  margin: 0 auto 26px;
  color: var(--ink-600);
  line-height: 1.8;
}

/* SMS workspace */
.sms-workspace {
  width: min(1520px, 100%);
  height: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 370px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: var(--shadow-small);
}

.conversation-pane,
.thread-pane {
  min-width: 0;
  min-height: 0;
}

.conversation-pane {
  display: flex;
  flex-direction: column;
  background: #f7f4ee;
  border-right: 1px solid var(--line-strong);
}

.conversation-head {
  min-height: 84px;
  padding: 17px 20px 15px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.conversation-head .eyebrow {
  margin-bottom: 4px;
}

.conversation-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 23px;
  letter-spacing: -.025em;
  line-height: 1.15;
}

.count-badge {
  min-width: 30px;
  height: 26px;
  padding: 0 8px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink-700);
  background: var(--paper);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.sms-summary {
  min-height: 65px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.sms-summary > span {
  min-width: 0;
  padding: 11px 15px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--line-soft);
}

.sms-summary > span:last-child {
  border-right: 0;
}

.sms-summary small {
  margin-bottom: 1px;
  color: var(--ink-500);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
}

.sms-summary b {
  overflow: hidden;
  color: var(--ink-900);
  font-family: var(--font-mono);
  font-size: 17px;
  text-overflow: ellipsis;
}

.sms-summary > span:nth-child(2) b {
  color: var(--accent);
}

.conversation-search {
  height: 56px;
  padding: 10px 13px;
  display: flex;
  align-items: center;
  gap: 9px;
  border-bottom: 1px solid var(--line);
}

.conversation-search > span {
  color: var(--ink-500);
  font-size: 16px;
}

.conversation-search input {
  min-width: 0;
  height: 34px;
  flex: 1;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink-900);
  background: #eae6de;
  font-size: 13px;
  outline: none;
}

.conversation-search input:focus {
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px rgb(189 70 29 / 10%);
}

.conversation-search input::placeholder {
  color: #817f79;
}

.conversation-list {
  min-height: 0;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.conversation-item {
  position: relative;
  width: 100%;
  min-height: 73px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  padding: 10px 14px;
  color: var(--ink-900);
  background: transparent;
  text-align: left;
  transition: background-color 120ms ease, box-shadow 120ms ease;
}

.conversation-item:hover {
  background: #efebe4;
}

.conversation-item.active {
  background: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
}

.conversation-item:focus-visible {
  z-index: 1;
  outline-offset: -3px;
}

.conversation-avatar,
.thread-avatar {
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: #f5f4ef;
  background: var(--ink-800);
  font-family: var(--font-mono);
  font-weight: 700;
}

.conversation-avatar {
  width: 42px;
  height: 42px;
  font-size: 12px;
}

.conversation-item.active .conversation-avatar {
  background: var(--accent);
}

.conversation-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.conversation-top {
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.conversation-top b {
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-top time {
  flex: 0 0 auto;
  color: var(--ink-500);
  font-family: var(--font-mono);
  font-size: 9px;
}

.conversation-copy > small {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-600);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unread-badge {
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
  font-family: var(--font-mono);
  font-size: 9px;
  font-style: normal;
  font-weight: 700;
}

.conversation-empty {
  min-height: 230px;
  padding: 34px 25px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.conversation-empty > span {
  width: 42px;
  height: 42px;
  margin-bottom: 13px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--accent);
  background: var(--paper);
  font-family: var(--font-mono);
  font-size: 11px;
}

.conversation-empty b {
  margin-bottom: 5px;
  font-size: 14px;
}

.conversation-empty p {
  max-width: 250px;
  margin: 0;
  color: var(--ink-500);
  font-size: 12px;
  line-height: 1.65;
}

.thread-pane {
  display: flex;
  flex-direction: column;
  background: #f1eee8;
}

.thread-head {
  min-height: 72px;
  padding: 11px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line-strong);
  background: var(--paper);
}

.thread-back {
  display: none;
}

.thread-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  font-size: 12px;
}

.thread-heading {
  min-width: 0;
  flex: 1;
}

.thread-heading h2 {
  margin: 0 0 2px;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: -.01em;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-heading p {
  margin: 0;
  overflow: hidden;
  color: var(--ink-500);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-list {
  min-height: 0;
  flex: 1;
  padding: 24px clamp(18px, 4vw, 54px) 32px;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.message-day {
  align-self: center;
  margin: 6px 0 18px;
  padding: 4px 9px;
  border: 1px solid #d8d3ca;
  border-radius: 999px;
  color: var(--ink-500);
  background: rgb(255 253 249 / 76%);
  font-family: var(--font-mono);
  font-size: 9px;
}

.message-bubble {
  position: relative;
  width: fit-content;
  max-width: min(680px, 74%);
  margin: 0 0 10px;
  padding: 10px 13px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 4px 13px 13px 13px;
  color: var(--ink-900);
  background: var(--paper);
  box-shadow: 0 1px 2px rgb(17 25 23 / 4%);
}

.message-bubble.sent {
  align-self: flex-end;
  border-color: var(--ink-800);
  border-radius: 13px 4px 13px 13px;
  color: #f6f7f4;
  background: var(--ink-800);
}

.message-bubble.received {
  align-self: flex-start;
}

.message-bubble p {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  line-height: 1.6;
}

.message-bubble time {
  display: block;
  margin-top: 3px;
  color: var(--ink-500);
  font-family: var(--font-mono);
  font-size: 9px;
  text-align: right;
}

.message-bubble.sent time {
  color: #aeb9b5;
}

.thread-empty {
  min-height: 100%;
  margin: auto;
  padding: 50px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.thread-empty > span {
  width: 70px;
  height: 70px;
  margin-bottom: 20px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  color: var(--accent);
  background: var(--paper);
  box-shadow: inset 0 -3px 0 var(--paper-deep);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
}

.thread-empty h3 {
  margin: 0 0 7px;
  font-family: var(--font-display);
  font-size: 19px;
}

.thread-empty p {
  margin: 0;
  color: var(--ink-500);
  font-size: 13px;
}

/* Modal */
.modal {
  width: min(560px, calc(100vw - 32px));
  max-height: min(88dvh, 760px);
  margin: auto;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  padding: 0;
  color: var(--ink-900);
  background: var(--paper);
  box-shadow: var(--shadow-modal);
}

.modal[open] {
  display: flex;
  flex-direction: column;
  animation: modal-in 170ms ease-out both;
}

.modal::backdrop {
  background: rgb(10 16 14 / 64%);
  backdrop-filter: blur(2px);
}

.modal-head {
  min-height: 70px;
  padding: 13px 15px 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.modal-head p {
  margin: 0 0 3px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .14em;
}

.modal-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 21px;
  letter-spacing: -.02em;
  line-height: 1.25;
}

.modal-body {
  min-height: 0;
  padding: 22px;
  overflow-y: auto;
}

.modal-copy {
  margin: 0 0 19px;
  color: var(--ink-600);
  line-height: 1.75;
}

.modal-form {
  display: grid;
  gap: 17px;
}

.modal-actions {
  margin-top: 5px;
  padding-top: 16px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  border-top: 1px solid var(--line);
}

.modal-actions-stack {
  align-items: stretch;
}

.modal-actions-stack .button {
  flex: 1;
}

.character-count {
  color: var(--ink-500);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
}

.cloud-status-card {
  margin-bottom: 18px;
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 13px;
  border: 1px solid #b8d9cd;
  border-radius: 9px;
  background: var(--green-soft);
}

.cloud-status-card.warning {
  border-color: #e6c78e;
  background: var(--amber-soft);
}

.cloud-status-card > i {
  width: 10px;
  height: 10px;
  flex-basis: 10px;
}

.cloud-status-card > div {
  display: grid;
  gap: 2px;
}

.cloud-status-card b {
  font-size: 14px;
}

.cloud-status-card span {
  color: var(--ink-600);
  font-size: 12px;
}

.modal-info-list,
.send-summary {
  border-top: 1px solid var(--line);
}

.modal-info-row {
  min-height: 44px;
  padding: 9px 2px;
  display: grid;
  grid-template-columns: minmax(90px, .5fr) minmax(0, 1fr);
  align-items: start;
  gap: 16px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-info-row > span,
.message-preview > span {
  color: var(--ink-500);
  font-size: 12px;
}

.modal-info-row > b {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  text-align: right;
}

.modal-footnote {
  margin: 15px 0 0;
  color: var(--ink-500);
  font-size: 11px;
  line-height: 1.65;
}

.fee-warning {
  margin-bottom: 19px;
  padding: 15px;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  border: 1px solid #e2b573;
  border-radius: 9px;
  background: var(--amber-soft);
}

.fee-warning > span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--amber);
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
}

.fee-warning b {
  display: block;
  margin-bottom: 4px;
  color: #673b09;
}

.fee-warning p {
  margin: 0;
  color: #75521e;
  font-size: 12px;
  line-height: 1.65;
}

.send-summary {
  margin-bottom: 17px;
}

.message-preview {
  padding: 11px 2px 13px;
  border-bottom: 1px solid var(--line-soft);
}

.message-preview p {
  max-height: 180px;
  margin: 6px 0 0;
  overflow: auto;
  overflow-wrap: anywhere;
  color: var(--ink-900);
  line-height: 1.7;
  white-space: pre-wrap;
}

.send-confirm-check {
  padding: 13px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink-700);
  background: var(--paper-warm);
}

/* Toast */
.toast {
  position: fixed;
  z-index: 1000;
  left: 50%;
  bottom: 24px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 11px 15px;
  visibility: hidden;
  border: 1px solid rgb(255 255 255 / 16%);
  border-left: 3px solid #ef7b47;
  border-radius: 7px;
  color: #f7f6f2;
  background: var(--ink-950);
  box-shadow: 0 14px 35px rgb(17 25 23 / 24%);
  font-size: 13px;
  line-height: 1.5;
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms;
}

.toast.show {
  visibility: visible;
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes spin {
  to { transform: rotate(1turn); }
}

@keyframes status-pulse {
  0%, 100% { opacity: .55; }
  50% { opacity: 1; }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 1180px) {
  .app-header {
    align-items: flex-start;
    gap: 16px;
  }

  .header-brand {
    margin-top: 2px;
  }

  .header-actions {
    flex-wrap: wrap;
  }

  .refresh-status {
    min-width: auto;
  }

  .sms-workspace {
    grid-template-columns: 340px minmax(0, 1fr);
  }
}

@media (max-width: 920px) {
  .login-view {
    grid-template-columns: minmax(330px, .85fr) minmax(390px, 1.15fr);
  }

  .login-manifesto h1 {
    font-size: clamp(38px, 6vw, 58px);
  }

  .setup-view {
    grid-template-columns: minmax(0, 1fr) minmax(340px, .92fr);
  }

  .setup-copy,
  .setup-card {
    padding: 38px;
  }

  .app-main {
    padding: 14px;
  }

  .cloud-account-button span,
  .app-header #logoutBtn {
    max-width: 100px;
  }
}

@media (max-width: 760px) {
  :root {
    --footer-height: 32px;
  }

  body {
    font-size: 14px;
  }

  .login-view {
    min-height: 100dvh;
    display: block;
  }

  .login-brand-panel,
  .login-form-panel {
    min-height: auto;
  }

  .login-brand-panel {
    padding: 25px 24px 30px;
  }

  .login-brand-panel::after {
    width: 140px;
    height: 140px;
    right: -78px;
    top: 45px;
    border-width: 28px;
  }

  .login-manifesto {
    width: 100%;
    margin: 52px 0 42px;
    padding: 0;
  }

  .login-manifesto h1 {
    margin-bottom: 15px;
    font-size: clamp(36px, 12vw, 50px);
  }

  .login-manifesto > p:last-child {
    max-width: 560px;
    font-size: 14px;
    line-height: 1.75;
  }

  .login-system-line {
    font-size: 9px;
  }

  .login-form-panel {
    padding: 42px 24px 54px;
  }

  .login-card {
    width: min(480px, 100%);
  }

  .sms-app {
    grid-template-rows: auto minmax(0, 1fr) var(--footer-height);
  }

  .app-header {
    min-height: 64px;
    padding: 10px 12px;
    align-items: center;
    gap: 10px;
  }

  .header-brand > span:last-child {
    display: none;
  }

  .header-actions {
    flex: 1;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .refresh-status {
    margin-right: auto;
  }

  .refresh-status > span {
    display: none;
  }

  .device-picker {
    max-width: 135px;
  }

  .device-picker > span {
    display: none;
  }

  .device-picker select {
    max-width: 135px;
    padding-left: 8px;
  }

  .app-header .button {
    min-height: 38px;
    padding-inline: 10px;
  }

  .app-header #refreshBtn {
    width: 39px;
    overflow: hidden;
    color: transparent;
    gap: 0;
  }

  .app-header #refreshBtn .refresh-icon {
    color: #e7e9e7;
  }

  .cloud-account-button {
    width: 39px;
    padding: 0;
  }

  .cloud-account-button span {
    display: none;
  }

  .app-header #logoutBtn {
    display: none;
  }

  .app-main {
    padding: 0;
  }

  .sms-workspace {
    width: 100%;
    border: 0;
    border-radius: 0;
    grid-template-columns: minmax(0, 1fr);
    box-shadow: none;
  }

  .conversation-pane {
    grid-area: 1 / 1;
    border-right: 0;
  }

  .thread-pane {
    display: none;
    grid-area: 1 / 1;
  }

  .sms-workspace.thread-open .conversation-pane {
    display: none;
  }

  .sms-workspace.thread-open .thread-pane {
    display: flex;
  }

  .thread-back {
    display: inline-grid;
  }

  .message-list {
    padding: 18px 13px 25px;
  }

  .message-bubble {
    max-width: 86%;
  }

  .app-footer {
    padding: 0 13px;
    gap: 12px;
  }

  .app-footer span:nth-child(2) {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .app-footer span:last-child {
    display: none;
  }

  .setup-view {
    width: 100%;
    height: 100%;
    display: block;
    overflow-y: auto;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .setup-copy,
  .setup-card {
    padding: 30px 24px;
  }

  .setup-index {
    margin-bottom: 25px;
  }

  .setup-copy h1 {
    font-size: 34px;
  }

  .setup-copy::after {
    font-size: 54px;
  }

  .modal {
    width: min(560px, calc(100vw - 18px));
    max-height: calc(100dvh - 18px);
  }

  .modal-body {
    padding: 18px;
  }
}

@media (max-width: 520px) {
  .header-brand {
    display: none;
  }

  .brand-mark-compact {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  .device-picker {
    max-width: 94px;
  }

  .device-picker select {
    max-width: 94px;
  }

  .app-header #composeBtn {
    min-width: 78px;
    padding-inline: 10px;
  }

  .conversation-head {
    min-height: 78px;
  }

  .thread-head {
    padding-inline: 11px;
  }

  .thread-avatar {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .thread-heading h2 {
    font-size: 16px;
  }

  .modal-actions {
    align-items: stretch;
  }

  .modal-actions .button {
    flex: 1;
    white-space: normal;
  }

  .modal-info-row {
    grid-template-columns: 90px minmax(0, 1fr);
  }

  .fee-warning {
    grid-template-columns: 1fr;
  }

  .fee-warning > span {
    width: 30px;
    height: 30px;
  }

  .login-system-line span:last-child {
    display: none;
  }
}

@media (max-width: 380px) {
  .app-header #composeBtn {
    width: 39px;
    min-width: 39px;
    overflow: hidden;
    color: transparent;
    gap: 0;
  }

  .app-header #composeBtn > span {
    color: #fff;
  }

  .sms-summary > span {
    padding-inline: 11px;
  }

  .modal-info-row {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .modal-info-row > b {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
