/* SMS – Super Messaging Service
   Frontend styling, translated from the Claude Design prototype
   (design/SMS - Super Messaging Service.dc.html) into plain CSS.
   See design/DESIGN_NOTES.md for the token inventory this file implements. */

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

:root {
  /* --- Colour tokens (design/DESIGN_NOTES.md §2) --- */
  --color-page-bg: #EEF0F4;
  --color-surface: #FFFFFF;
  --color-thread-bg: #F7F7F5;
  --color-surface-subtle: #F9FAFB;
  --color-track: #F2F4F7;
  --color-border: #E4E7EC;
  --color-border-subtle: #F2F4F7;
  --color-divider: #E9EDF3;
  --color-input-border: #D0D5DD;

  --color-text: #0F172A;
  --color-text-secondary: #334155;
  --color-text-muted: #64748B;
  --color-text-placeholder: #98A2B3;

  --color-navy: #0B1B3F;
  --color-accent: #2D5BFF;
  --color-accent-hover: #1F46D6;
  --color-accent-tint-bg: #E8EEFF;
  --color-accent-tint-border: #C3D0FF;

  --color-success: #16B981;
  --color-success-text: #0F8F66;
  --color-success-tint-bg: #E7F8F1;
  --color-success-border: #A7E8CF;
  --color-success-surface: #F3FBF7;

  --color-warning-text: #B54708;

  --color-danger-text: #C2410C;
  --color-danger-tint-bg: #FFF4F0;
  --color-danger-border: #F8B4A0;

  --color-toast-bg: #0B1B3F;
  --color-toast-link: #9DB4FF;

  /* Avatar palette, rotated by a hash of the contact's name/phone. */
  --avatar-1: #2D5BFF;
  --avatar-2: #7A5AF8;
  --avatar-3: #0E9384;
  --avatar-4: #DD2590;
  --avatar-5: #B54708;
  --avatar-6: #475467;
  --avatar-none: #98A2B3;

  /* --- Radii --- */
  --radius-xs: 5px;
  --radius-tab: 7px;
  --radius-icon: 8px;
  --radius-input: 10px;
  --radius-card: 12px;
  --radius-toast: 11px;
  --radius-bubble: 14px;
  --radius-modal: 16px;
  --radius-sheet: 18px;
  --radius-pill: 999px;

  /* --- Shadows --- */
  --shadow-tab: 0 1px 2px rgba(16, 24, 40, .1);
  --shadow-focus: 0 0 0 3px rgba(45, 91, 255, .14);
  --shadow-modal: 0 24px 48px -12px rgba(16, 24, 40, .36);
  --shadow-toast: 0 12px 24px -8px rgba(16, 24, 40, .5);
  --shadow-fab: 0 10px 20px -6px rgba(45, 91, 255, .6);

  /* --- Spacing scale (observed in the prototype, not a strict 8pt grid) --- */
  --space-1: 3px;
  --space-2: 4px;
  --space-3: 6px;
  --space-4: 8px;
  --space-5: 10px;
  --space-6: 12px;
  --space-7: 14px;
  --space-8: 16px;
  --space-9: 18px;
  --space-10: 20px;
  --space-11: 22px;
  --space-12: 24px;
  --space-13: 28px;
  --space-14: 32px;
  --space-15: 40px;
  --space-16: 56px;

  /* --- Type scale --- */
  --fs-11: 11px;
  --fs-12: 12px;
  --fs-13: 13px;
  --fs-14: 14px;
  --fs-15: 15px;
  --fs-16: 16px;
  --fs-17: 17px;
  --fs-20: 20px;
  --fs-22: 22px;
  --fs-26: 26px;
  --fs-30: 30px;

  --font-sans: Inter, -apple-system, "Segoe UI", system-ui, sans-serif;

  --breakpoint: 860px;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-sans);
  background: var(--color-page-bg);
  color: var(--color-text);
  font-size: var(--fs-15);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { color: var(--color-accent-hover); text-decoration: underline; }

button, input, textarea, select { font: inherit; color: inherit; }
input, textarea, select { outline: none; }
::placeholder { color: var(--color-text-placeholder); }

button {
  cursor: pointer;
  background: none;
  border: none;
}

.hidden { display: none !important; }

kbd {
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--color-border);
  background: var(--color-surface-subtle);
  font: inherit;
  font-weight: 600;
  color: var(--color-text-muted);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes sheetIn {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* ==========================================================================
   App shell
   ========================================================================== */

#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  overflow: hidden;
}

.view-app {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* ==========================================================================
   Brand mark
   ========================================================================== */

.brand-mark {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.brand-mark img { display: block; flex: none; }

.brand-wordmark {
  font-size: var(--fs-15);
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
}

.brand-wordmark strong {
  color: var(--color-navy);
  font-weight: 700;
  letter-spacing: -.02em;
}

.brand-wordmark span {
  font-size: var(--fs-11);
  font-weight: 600;
  letter-spacing: .12em;
  color: var(--color-text-placeholder);
  margin-left: var(--space-5);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  height: 38px;
  padding: 0 var(--space-7);
  border-radius: var(--radius-input);
  font-size: var(--fs-14);
  font-weight: 600;
  border: none;
  white-space: nowrap;
  transition: background .12s ease;
}

.btn-primary {
  background: var(--color-accent);
  color: var(--color-surface);
}
.btn-primary:hover { background: var(--color-accent-hover); }
.btn-primary:disabled { background: var(--color-border); color: var(--color-text-placeholder); cursor: default; }

.btn-secondary {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  font-weight: 500;
}
.btn-secondary:hover { background: var(--color-surface-subtle); }

.btn-danger {
  background: var(--color-surface);
  border: 1px solid var(--color-danger-border);
  color: var(--color-danger-text);
  font-weight: 600;
}
.btn-danger:hover { background: var(--color-danger-tint-bg); }

.btn-danger-solid {
  background: var(--color-danger-text);
  color: var(--color-surface);
}
.btn-danger-solid:hover { background: #A6380C; }

.btn-block { width: 100%; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-icon);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: var(--fs-16);
  transition: background .12s ease;
}
.btn-icon:hover { background: var(--color-track); }

.btn-icon-outline {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}
.btn-icon-outline:hover { background: var(--color-surface-subtle); }

.btn-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--color-accent);
  font-size: var(--fs-13);
  font-weight: 500;
}
.btn-link:hover { color: var(--color-accent-hover); text-decoration: underline; }

/* ==========================================================================
   Inputs
   ========================================================================== */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  font-size: var(--fs-13);
  font-weight: 500;
  color: var(--color-text-secondary);
}

.input, textarea.input, select.input {
  height: 46px;
  padding: 0 var(--space-7);
  border-radius: var(--radius-input);
  border: 1px solid var(--color-input-border);
  background: var(--color-surface);
  font-size: var(--fs-15);
  color: var(--color-text);
}

.input:focus, textarea.input:focus, select.input:focus {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-focus);
}

/* ==========================================================================
   Login screen
   ========================================================================== */

.login-screen {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.login-form-col {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 clamp(32px, 8vw, 120px);
  gap: var(--space-13);
}

.login-heading { display: flex; flex-direction: column; gap: var(--space-4); }

.login-heading h1 {
  margin: 0;
  font-size: var(--fs-30);
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--color-text);
}

.login-heading p {
  margin: 0;
  font-size: var(--fs-15);
  line-height: 1.55;
  color: var(--color-text-muted);
  max-width: 380px;
}

.login-fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  max-width: 380px;
}

.login-error {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  border-radius: var(--radius-input);
  background: var(--color-danger-tint-bg);
  border: 1px solid var(--color-danger-border);
  color: var(--color-danger-text);
  font-size: var(--fs-13);
  font-weight: 500;
}

.login-fields button[type="submit"] {
  height: 46px;
  border-radius: var(--radius-input);
  border: none;
  background: var(--color-accent);
  color: var(--color-surface);
  font-size: var(--fs-15);
  font-weight: 600;
}
.login-fields button[type="submit"]:hover { background: var(--color-accent-hover); }

.login-microcopy {
  margin: 0;
  font-size: var(--fs-12);
  color: var(--color-text-placeholder);
}

.login-hero {
  background: var(--color-navy);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-9);
  padding: 0 clamp(32px, 6vw, 90px);
  position: relative;
  overflow: hidden;
}

.login-hero::before, .login-hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}
.login-hero::before {
  right: -80px; top: -80px; width: 360px; height: 360px;
  background: var(--color-accent); opacity: .18;
}
.login-hero::after {
  right: 60px; bottom: -120px; width: 280px; height: 280px;
  background: var(--color-success); opacity: .14;
}

.login-hero-kicker {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  position: relative;
  font-size: var(--fs-12);
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--color-toast-link);
}
.login-hero-kicker .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--color-success);
}

.login-hero-copy {
  position: relative;
  font-size: var(--fs-26);
  line-height: 1.4;
  font-weight: 500;
  color: var(--color-surface);
  max-width: 440px;
}

/* ==========================================================================
   Desktop top bar
   ========================================================================== */

.topbar {
  height: 56px;
  flex: none;
  padding: 0 var(--space-10);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-6);
  background: var(--color-surface);
}

.topbar .brand-phone {
  font-size: var(--fs-13);
  color: var(--color-text-placeholder);
}

.topbar-spacer { flex: 1; }

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-5) var(--space-2) var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--color-track);
  cursor: pointer;
  transition: background .12s ease;
}
.user-chip:hover { background: var(--color-border); }

.user-chip-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--color-accent); color: var(--color-surface);
  display: grid; place-items: center;
  font-size: var(--fs-11); font-weight: 700;
  cursor: pointer;
}

.user-chip-name {
  font-size: var(--fs-13);
  font-weight: 500;
  color: var(--color-text-secondary);
}

/* ==========================================================================
   Inbox screen layout
   ========================================================================== */

#screen-inbox {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.inbox-body {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
  position: relative;
}

.pane-list {
  width: 372px;
  flex: none;
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  min-height: 0;
}

.list-header-mobile {
  display: none;
}

.list-toolbar {
  padding: var(--space-6) var(--space-7) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.search-row {
  display: flex;
  gap: var(--space-4);
}

.search-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-wrap .search-icon {
  position: absolute;
  left: var(--space-6);
  font-size: var(--fs-14);
  color: var(--color-text-placeholder);
  pointer-events: none;
}

#search-input {
  width: 100%;
  height: 38px;
  padding: 0 14px 0 32px;
  border-radius: var(--radius-input);
  border: 1px solid var(--color-input-border);
  background: var(--color-surface);
  font-size: var(--fs-14);
  color: var(--color-text);
  transition: box-shadow .15s ease, border-color .15s ease;
}
#search-input:focus { border-color: var(--color-accent); box-shadow: var(--shadow-focus); }

#btn-new-sms {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}

.filter-tabs {
  display: flex;
  gap: var(--space-2);
  padding: 3px;
  background: var(--color-track);
  border-radius: var(--radius-input);
}

.filter-tab {
  flex: 1;
  height: 30px;
  border-radius: var(--radius-tab);
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  font-size: var(--fs-13);
  font-weight: 500;
  cursor: pointer;
}

.filter-tab.active {
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: 600;
  box-shadow: var(--shadow-tab);
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  border-top: 1px solid var(--color-border-subtle);
}

.empty-hint {
  padding: var(--space-15) var(--space-6);
  text-align: center;
  font-size: var(--fs-13);
  color: var(--color-text-placeholder);
}

.conv-row {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 10px 14px;
  padding-left: 11px;
  border-bottom: 1px solid var(--color-border-subtle);
  border-left: 3px solid transparent;
  background: var(--color-surface);
  cursor: pointer;
  transition: background .12s ease;
}
.conv-row:hover { background: #F7F9FC; }
.conv-row.selected { background: var(--color-accent-tint-bg); border-left-color: var(--color-accent); }

.conv-avatar {
  width: 38px; height: 38px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  font-size: var(--fs-12); font-weight: 700; letter-spacing: .02em;
}

.conv-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.conv-top-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-4);
}

.conv-name {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-14);
  font-weight: 500;
  color: var(--color-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-row.unread .conv-name { font-weight: 700; color: var(--color-text); }

.conv-time {
  flex: none;
  font-size: var(--fs-12);
  color: var(--color-text-placeholder);
}
.conv-row.unread .conv-time { font-weight: 600; color: var(--color-accent-hover); }

.conv-preview {
  font-size: var(--fs-13);
  line-height: 1.35;
  color: var(--color-text-placeholder);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-row.unread .conv-preview { color: var(--color-text-secondary); font-weight: 500; }

.conv-lastby {
  font-size: var(--fs-11);
  color: var(--color-text-placeholder);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  height: 14px;
}

.conv-side {
  width: 20px;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.conv-unread-badge {
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--color-accent); color: var(--color-surface);
  font-size: var(--fs-11); font-weight: 700;
  display: grid; place-items: center;
}

.conv-failed-dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--color-danger-tint-bg); color: var(--color-danger-text);
  font-size: var(--fs-11); font-weight: 700;
  display: grid; place-items: center;
}

.fab-new-sms { display: none; }

/* ==========================================================================
   Thread pane
   ========================================================================== */

.pane-thread {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--color-thread-bg);
}

.thread-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  text-align: center;
  padding: var(--space-15);
}

.thread-empty-icon {
  width: 56px; height: 56px; border-radius: var(--radius-card);
  background: var(--color-accent-tint-bg); color: var(--color-accent);
  display: grid; place-items: center; font-size: var(--fs-22);
}

.thread-empty h2 {
  margin: 0; font-size: var(--fs-17); font-weight: 600; color: var(--color-text);
}

.thread-empty p {
  margin: 0; font-size: var(--fs-14); color: var(--color-text-muted);
  max-width: 320px; line-height: 1.5;
}

.thread-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.thread-header {
  height: 64px;
  flex: none;
  padding: 0 var(--space-11);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.thread-avatar {
  width: 36px; height: 36px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  font-size: var(--fs-13); font-weight: 700; letter-spacing: .02em;
}

.thread-header-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  /* flex-basis 0% (not auto) so the available-width computation isn't
     circular with the ellipsis-truncated child below — see .name-text. */
  flex: 1 1 0%;
  min-width: 0;
}

.thread-name-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: 26px;
  margin: -3px -8px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-tab);
  background: transparent;
  font-size: var(--fs-15);
  font-weight: 600;
  color: var(--color-text);
  cursor: text;
  text-align: left;
  width: 100%;
  min-width: 0;
  transition: background .12s ease;
}
.thread-name-btn:hover { background: var(--color-track); }
.thread-name-btn .name-text {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.thread-name-btn .pencil { font-size: var(--fs-12); font-weight: 500; color: var(--color-text-placeholder); flex: none; }

#edit-name-input {
  height: 26px;
  width: 260px;
  margin: -3px -8px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-tab);
  border: 1px solid var(--color-accent);
  box-shadow: var(--shadow-focus);
  font-size: var(--fs-15);
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-surface);
}

.thread-phone {
  font-size: var(--fs-13);
  color: var(--color-text-muted);
}

/* Persistent warning badge for a non-Swedish conversation (docs/WISHLIST.md
   "Skicka till alla länder") — SMS to it costs more than to a Swedish
   number, so this stays visible in the header, not just on first send. */
.badge-foreign {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  height: 18px;
  padding: 0 var(--space-4);
  margin-top: 1px;
  border-radius: var(--radius-pill);
  background: var(--color-danger-tint-bg);
  border: 1px solid var(--color-danger-border);
  color: var(--color-warning-text);
  font-size: var(--fs-11);
  font-weight: 600;
  white-space: nowrap;
}


.thread-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

#btn-archive {
  height: 36px;
  padding: 0 var(--space-7);
  border-radius: var(--radius-input);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: var(--fs-13);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}
#btn-archive:hover { background: var(--color-surface-subtle); }

#btn-delete-trigger {
  height: 36px;
  padding: 0 var(--space-7);
  border-radius: var(--radius-input);
  font-size: var(--fs-13);
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}

#btn-archive .icon-glyph, #btn-delete-trigger .icon-glyph { display: none; }

#btn-rename-mobile, #btn-back { display: none; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-11) var(--space-12) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.thread-empty-hint {
  margin: auto;
  text-align: center;
  font-size: var(--fs-13);
  color: var(--color-text-placeholder);
  max-width: 300px;
  line-height: 1.5;
}

.day-separator {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  padding: 14px 0 10px;
}
.day-separator .line { flex: 1; height: 1px; background: var(--color-divider); }
.day-separator .label { font-size: var(--fs-12); font-weight: 500; color: var(--color-text-placeholder); white-space: nowrap; }

.msg-wrap {
  display: flex;
  flex-direction: column;
  margin-top: 8px;
}
.msg-wrap.out { align-items: flex-end; }
.msg-wrap.in { align-items: flex-start; }

.bubble {
  max-width: 560px;
  padding: 10px 14px;
  border-radius: var(--radius-bubble);
  font-size: var(--fs-15);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  animation: bubbleIn .16s ease-out;
}
.msg-wrap.out .bubble {
  background: var(--color-accent);
  color: var(--color-surface);
  border-radius: 14px 14px 4px 14px;
}
.msg-wrap.in .bubble {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 14px 14px 14px 4px;
}

.bubble-meta {
  margin-top: 4px;
  font-size: var(--fs-11);
  font-weight: 500;
  color: var(--color-text-placeholder);
}
.bubble-meta.failed { color: var(--color-danger-text); }

/* ==========================================================================
   Mock dev panel
   ========================================================================== */

.mock-panel {
  flex: none;
  border-top: 1px dashed var(--color-border);
  background: var(--color-surface-subtle);
  padding: var(--space-4) var(--space-11);
}

.mock-panel summary {
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.mock-panel summary::-webkit-details-marker { display: none; }
.mock-panel summary::before { content: "⚙"; font-size: var(--fs-12); }

.mock-panel-body {
  display: flex;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.mock-panel-body input {
  flex: 1;
  height: 32px;
  padding: 0 var(--space-5);
  border-radius: var(--radius-tab);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: var(--fs-13);
}

.mock-panel-body button {
  height: 32px;
  padding: 0 var(--space-6);
  border-radius: var(--radius-tab);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: var(--fs-13);
  font-weight: 500;
}
.mock-panel-body button:hover { background: var(--color-track); }

/* ==========================================================================
   Compose box
   ========================================================================== */

.compose {
  flex: none;
  padding: var(--space-6) var(--space-12) var(--space-9);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

.compose-box {
  border: 1px solid var(--color-input-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
  padding: 10px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

#compose-text {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font-size: var(--fs-15);
  line-height: 1.5;
  color: var(--color-text);
  background: transparent;
  min-height: 48px;
  max-height: 140px;
  font-family: inherit;
}

.compose-row {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.compose-counter {
  font-size: var(--fs-12);
  font-weight: 500;
  white-space: nowrap;
  flex: none;
  color: var(--color-text-placeholder);
}
.compose-counter.over { color: var(--color-warning-text); }

.compose-helper {
  font-size: var(--fs-12);
  color: var(--color-text-placeholder);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compose-spacer { flex: 1; }

#btn-templates {
  height: 30px;
  padding: 0 var(--space-5);
  border-radius: var(--radius-tab);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: var(--fs-12);
  font-weight: 500;
  flex: none;
}
#btn-templates:hover { background: var(--color-surface-subtle); }

#compose-send {
  height: 38px;
  padding: 0 20px;
  border-radius: var(--radius-input);
  border: none;
  font-size: var(--fs-14);
  font-weight: 600;
  background: var(--color-border);
  color: var(--color-text-placeholder);
  cursor: default;
  transition: background .15s ease;
}
#compose-send.can-send {
  background: var(--color-accent);
  color: var(--color-surface);
  cursor: pointer;
}
#compose-send.can-send:hover { background: var(--color-accent-hover); }

/* ==========================================================================
   Modals / dialogs
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .42);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 120px;
  z-index: 60;
}

.modal-backdrop.hidden { display: none; }

.modal {
  width: 520px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 160px);
  background: var(--color-surface);
  border-radius: var(--radius-modal);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-sm { width: 420px; padding: var(--space-10); gap: var(--space-7); }
.modal-sm.modal { display: flex; flex-direction: column; }

.modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.modal-header-row {
  display: flex;
  align-items: center;
}

.modal-header-row h3 {
  margin: 0;
  font-size: var(--fs-16);
  font-weight: 600;
  color: var(--color-text);
}

.modal-close {
  width: 32px; height: 32px; border-radius: var(--radius-icon);
  background: var(--color-track); color: var(--color-text-muted);
  font-size: var(--fs-15);
  margin-left: auto;
}
.modal-close:hover { background: var(--color-border); }

.modal-back { display: none; }

#new-sms-search {
  height: 44px;
  padding: 0 var(--space-7);
  border-radius: var(--radius-input);
  border: 1px solid var(--color-input-border);
  font-size: var(--fs-15);
  color: var(--color-text);
}
#new-sms-search:focus { border-color: var(--color-accent); box-shadow: var(--shadow-focus); }

.modal-list {
  max-height: 320px;
  overflow-y: auto;
}

.suggestion-item, .new-number-item {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  padding: 10px 20px;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border-subtle);
}
.suggestion-item:hover, .new-number-item:hover { background: #F7F9FC; }

.new-number-item .plus-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--color-accent-tint-bg); color: var(--color-accent);
  display: grid; place-items: center; font-size: var(--fs-15); font-weight: 700;
}

.suggestion-item .conv-avatar { width: 36px; height: 36px; }

.suggestion-text, .new-number-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.suggestion-text strong, .new-number-text strong {
  font-size: var(--fs-14);
  font-weight: 500;
  color: var(--color-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.suggestion-text span, .new-number-text span {
  font-size: var(--fs-12);
  color: var(--color-text-muted);
}

.modal-empty {
  padding: 28px 20px;
  text-align: center;
  font-size: var(--fs-13);
  color: var(--color-text-placeholder);
}

.error-text {
  margin: 0;
  padding: 12px 20px;
  font-size: var(--fs-13);
  color: var(--color-danger-text);
}

/* Rename + delete-confirm modals share .modal-sm */

.modal-sm h3 { margin: 0; font-size: var(--fs-16); font-weight: 600; color: var(--color-text); }
.modal-sm p { margin: 0; font-size: var(--fs-13); color: var(--color-text-muted); line-height: 1.5; }
#rename-input {
  height: 44px; padding: 0 var(--space-7);
  border-radius: var(--radius-input); border: 1px solid var(--color-input-border);
  font-size: var(--fs-15); color: var(--color-text);
}
#rename-input:focus { border-color: var(--color-accent); box-shadow: var(--shadow-focus); }

.modal-actions {
  display: flex;
  gap: var(--space-4);
  justify-content: flex-end;
}

/* ==========================================================================
   Templates ("Mallar") popover + manage dialog
   ========================================================================== */

.modal-templates { width: 340px; padding: var(--space-8) var(--space-8) var(--space-6); gap: 0; }
.modal-templates .modal-header-row { padding-bottom: var(--space-6); }
.modal-templates .modal-header-row h3 { margin: 0; font-size: var(--fs-16); font-weight: 600; color: var(--color-text); }

.templates-popover-list {
  max-height: 280px;
  overflow-y: auto;
  margin: 0 calc(-1 * var(--space-8));
}

.template-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 9px var(--space-8);
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border-subtle);
}
.template-item:hover { background: #F7F9FC; }
.template-item .title { font-size: var(--fs-14); font-weight: 600; color: var(--color-text); }
.template-item .snippet {
  font-size: var(--fs-12);
  color: var(--color-text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.templates-empty {
  padding: 24px 4px;
  text-align: center;
  font-size: var(--fs-13);
  color: var(--color-text-placeholder);
}

.templates-popover-footer {
  padding-top: var(--space-6);
  margin-top: var(--space-3);
  border-top: 1px solid var(--color-border);
  text-align: center;
}

.modal-manage-templates { width: 480px; }

.templates-manage-list { max-height: 340px; overflow-y: auto; }

.template-manage-row {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-5) 20px;
  border-bottom: 1px solid var(--color-border-subtle);
}
.template-manage-row .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.template-manage-row .info strong { font-size: var(--fs-14); font-weight: 600; color: var(--color-text); }
.template-manage-row .info span {
  font-size: var(--fs-12);
  color: var(--color-text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.template-manage-row .actions { display: flex; gap: var(--space-3); flex: none; }
.template-manage-row .actions button {
  height: 30px;
  padding: 0 var(--space-5);
  border-radius: var(--radius-tab);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: var(--fs-12);
  font-weight: 500;
}
.template-manage-row .actions button:hover { background: var(--color-surface-subtle); }
.template-manage-row .actions .danger { color: var(--color-danger-text); border-color: var(--color-danger-border); }
.template-manage-row .actions .danger:hover { background: var(--color-danger-tint-bg); }

.templates-manage-footer { padding: var(--space-7) 20px var(--space-2); }

.templates-manage-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: var(--space-7);
}

.template-body-field {
  width: 100%;
  min-height: 120px;
  padding: var(--space-6) var(--space-7);
  border-radius: var(--radius-input);
  border: 1px solid var(--color-input-border);
  background: var(--color-surface);
  font-size: var(--fs-14);
  font-family: inherit;
  line-height: 1.5;
  color: var(--color-text);
  resize: vertical;
}
.template-body-field:focus { border-color: var(--color-accent); box-shadow: var(--shadow-focus); outline: none; }

.template-form-counter {
  margin-top: calc(-1 * var(--space-4));
  font-size: var(--fs-12);
  color: var(--color-text-placeholder);
}

/* ==========================================================================
   Toast
   ========================================================================== */

#toast {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  animation: toastIn .18s ease-out;
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: 11px 16px;
  border-radius: var(--radius-toast);
  background: var(--color-toast-bg);
  color: var(--color-surface);
  font-size: var(--fs-13);
  font-weight: 500;
  box-shadow: var(--shadow-toast);
  z-index: 70;
  max-width: calc(100vw - 32px);
}

#toast .toast-action {
  border: none;
  background: transparent;
  color: var(--color-toast-link);
  font-size: var(--fs-13);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  flex: none;
}

/* ==========================================================================
   Import screen
   ========================================================================== */

#screen-import {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.import-topbar {
  height: 64px;
  flex: none;
  padding: 0 var(--space-13);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.import-topbar h2 {
  margin: 0;
  font-size: var(--fs-17);
  font-weight: 600;
  color: var(--color-text);
}

.import-topbar .import-subtitle {
  font-size: var(--fs-13);
  color: var(--color-text-placeholder);
}

.import-body {
  flex: 1;
  overflow: auto;
  padding: var(--space-13) var(--space-13) var(--space-15);
  display: flex;
  justify-content: center;
}

.import-content {
  width: 880px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-11);
}

.import-steps {
  display: flex;
  gap: var(--space-5);
}

.import-step {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--radius-input);
  font-size: var(--fs-13);
  font-weight: 500;
  background: var(--color-surface-subtle);
  color: var(--color-text-placeholder);
  border: 1px solid #EAECF0;
  text-align: center;
}
.import-step.active {
  background: var(--color-accent-tint-bg);
  color: var(--color-accent-hover);
  font-weight: 600;
  border-color: var(--color-accent-tint-border);
}
.import-step.done { color: var(--color-success-text); }

.import-dropzone {
  border: 2px dashed #CDD5E0;
  border-radius: var(--radius-bubble);
  background: var(--color-surface-subtle);
  padding: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-6);
  text-align: center;
  transition: border-color .12s ease, background .12s ease;
}
.import-dropzone.dragover {
  border-color: var(--color-accent);
  background: var(--color-accent-tint-bg);
}

.import-dropzone-icon {
  width: 48px; height: 48px; border-radius: var(--radius-card);
  background: var(--color-accent-tint-bg); color: var(--color-accent);
  display: grid; place-items: center; font-size: var(--fs-20); font-weight: 700;
}

.import-dropzone h3 { margin: 0; font-size: var(--fs-16); font-weight: 600; color: var(--color-text); }
.import-dropzone p { margin: 0; font-size: var(--fs-14); color: var(--color-text-muted); }

.import-file-card {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-7) var(--space-8);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface);
}

.import-file-check {
  width: 36px; height: 36px; border-radius: var(--radius-tab);
  background: var(--color-success-tint-bg); color: var(--color-success-text);
  display: grid; place-items: center; font-size: var(--fs-15); font-weight: 700; flex: none;
}

.import-file-meta { flex: 1; min-width: 0; }
.import-file-meta .filename {
  font-size: var(--fs-14); font-weight: 600; color: var(--color-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.import-file-meta .rowcount { font-size: var(--fs-13); color: var(--color-text-muted); }

.import-mapping {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-8);
}

.import-mapping select {
  height: 44px;
  padding: 0 var(--space-6);
  border-radius: var(--radius-input);
  border: 1px solid var(--color-input-border);
  background: var(--color-surface);
  font-size: var(--fs-14);
  color: var(--color-text);
}

.import-table-wrap {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  overflow: auto;
}

.import-table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--fs-13);
}

.import-table thead th {
  padding: 10px 14px;
  font-size: var(--fs-12);
  font-weight: 600;
  color: var(--color-text-secondary);
  background: var(--color-surface-subtle);
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  white-space: nowrap;
}
.import-table thead th.mapped { color: var(--color-accent); }
.import-table thead th .col-tag { color: var(--color-accent); font-weight: 600; }

.import-table tbody td {
  padding: 11px 14px;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border-subtle);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.import-table tbody tr.invalid { background: #FFFBFA; }
.import-table tbody tr.invalid td.phone-cell { color: var(--color-danger-text); font-weight: 500; }

.import-table-footer {
  padding: 10px 14px;
  background: var(--color-surface-subtle);
  border-top: 1px solid var(--color-border);
  font-size: var(--fs-12);
  color: var(--color-text-muted);
}

.import-summary {
  display: flex;
  align-items: center;
  gap: var(--space-10);
  padding: var(--space-9) var(--space-10);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-surface-subtle);
  flex-wrap: wrap;
}

.import-summary-stat { display: flex; flex-direction: column; gap: 2px; }
.import-summary-stat .n { font-size: var(--fs-22); font-weight: 700; }
.import-summary-stat .label { font-size: var(--fs-13); color: var(--color-text-muted); }
.import-summary-stat.new .n { color: var(--color-success-text); }
.import-summary-stat.updated .n { color: var(--color-accent); }
.import-summary-stat.merged .n { color: var(--color-accent); }
.import-summary-stat.foreign .n { color: var(--color-warning-text); }
.import-summary-stat.invalid .n { color: var(--color-warning-text); }
.import-summary-stat.unchanged .n { color: var(--color-text-muted); }

.import-summary-divider { width: 1px; height: 36px; background: var(--color-border); }
.import-summary-spacer { flex: 1; }

.import-footnote { margin: 0; font-size: var(--fs-13); color: var(--color-text-muted); }

/* Per-file breakdown under the file card (multi-file import). */
.import-file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: var(--fs-13);
  color: var(--color-text-muted);
}
.import-file-list li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-xs);
}
.import-file-list .import-file-list-name { flex: 1; color: var(--color-text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-file-list .import-file-list-warning { color: var(--color-warning-text); font-weight: 600; }

/* "Sammanslagna dubbletter" review list. */
.import-duplicates {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-7) var(--space-8);
  background: var(--color-surface);
}
.import-duplicates h4 { margin: 0 0 var(--space-4); font-size: var(--fs-14); font-weight: 600; color: var(--color-text); }
.import-duplicates-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); font-size: var(--fs-13); }
.import-duplicates-list li { color: var(--color-text-muted); }
.import-duplicates-list .kept-name { color: var(--color-text); font-weight: 600; }

.import-done-summary { margin-top: var(--space-2); }

.import-done-card {
  border: 1px solid var(--color-success-border);
  background: var(--color-success-surface);
  border-radius: var(--radius-bubble);
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
  text-align: center;
}
.import-done-check {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--color-success-tint-bg); color: var(--color-success-text);
  display: grid; place-items: center; font-size: var(--fs-22); font-weight: 700;
}
.import-done-card h3 { margin: 0; font-size: var(--fs-17); font-weight: 600; color: var(--color-text); }
.import-done-card p { margin: 0; font-size: var(--fs-14); color: var(--color-text-muted); }

.import-error {
  font-size: var(--fs-13);
  color: var(--color-danger-text);
  margin: 0;
}

/* ==========================================================================
   Mobile layout (single breakpoint, DESIGN_NOTES.md §1)
   ========================================================================== */

@media (max-width: 859px) {
  .topbar { display: none; }

  .login-screen {
    display: flex;
    flex-direction: column;
    padding: 28px 22px;
    gap: var(--space-11);
  }
  .login-hero { display: none; }
  .login-form-col { padding: 0; justify-content: flex-start; gap: var(--space-11); }
  .login-heading h1 { font-size: var(--fs-26); }
  .login-fields { max-width: none; gap: var(--space-7); }
  .login-fields .input { height: 48px; font-size: var(--fs-16); }
  .login-fields button[type="submit"] { height: 50px; font-size: var(--fs-16); }

  .inbox-body { flex-direction: column; }

  .pane-list {
    width: 100%;
    border-right: none;
    position: absolute;
    inset: 0;
    z-index: 1;
  }
  .pane-thread {
    position: absolute;
    inset: 0;
    z-index: 2;
  }
  #app.mobile-pane-list .pane-thread { display: none; }
  #app.mobile-pane-chat .pane-list { display: none; }

  .list-header-mobile {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-2) var(--space-6) 0;
  }
  .list-header-mobile .mobile-title {
    font-size: var(--fs-20);
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--color-text);
  }
  .list-header-mobile .spacer { flex: 1; }
  .list-header-mobile .btn-icon-outline {
    width: 44px; height: 44px; border-radius: var(--radius-input);
  }
  .list-header-mobile .user-chip-avatar {
    width: 44px; height: 44px; border-radius: 50%; font-size: var(--fs-14);
  }

  .list-toolbar { padding: var(--space-5) var(--space-6) var(--space-5); }
  #search-input { height: 44px; font-size: var(--fs-15); }
  .filter-tabs { border-radius: var(--radius-input); }
  .filter-tab { height: 38px; font-size: var(--fs-14); }
  .search-row #btn-new-sms { display: none; }
  .search-row .search-wrap { flex: 1; }

  .conv-row { min-height: 72px; padding: 12px 14px; padding-left: 11px; }

  .fab-new-sms {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    position: absolute;
    right: 18px;
    bottom: 26px;
    height: 56px;
    padding: 0 22px;
    border-radius: 28px;
    border: none;
    background: var(--color-accent);
    color: var(--color-surface);
    font-size: var(--fs-15);
    font-weight: 600;
    box-shadow: var(--shadow-fab);
    z-index: 3;
  }
  .fab-new-sms:hover { background: var(--color-accent-hover); }

  .thread-empty { display: none; }

  .thread-header { height: 56px; padding: 0 var(--space-4) 0 var(--space-2); gap: var(--space-3); }
  #btn-back {
    display: inline-flex;
    width: 44px; height: 44px;
    color: var(--color-accent);
    font-size: var(--fs-20);
  }
  .thread-name-btn { cursor: default; pointer-events: none; }
  .thread-name-btn .pencil { display: none; }
  #btn-edit-name-toggle { display: none; }
  #btn-archive, #btn-delete-trigger {
    width: 44px; height: 44px; padding: 0; border: none;
    background: transparent; font-size: var(--fs-16); justify-content: center;
  }
  #btn-archive:hover, #btn-delete-trigger:hover { background: var(--color-track); }
  #btn-archive .label-text, #btn-delete-trigger .label-text { display: none; }
  #btn-archive .icon-glyph, #btn-delete-trigger .icon-glyph { display: inline; }
  #btn-rename-mobile { display: inline-flex; width: 44px; height: 44px; font-size: var(--fs-16); }

  .messages { padding: var(--space-8) var(--space-7) var(--space-4); }
  .bubble { max-width: 286px; }
  #compose-text { font-size: var(--fs-16); min-height: 36px; rows: 1; }
  .compose { padding: var(--space-5) var(--space-6) var(--space-7); }
  .compose-box { border-radius: var(--radius-bubble); padding: 8px 10px; }
  .compose-helper { display: none; }
  #compose-send { height: 44px; padding: 0 22px; font-size: var(--fs-15); }

  .mock-panel { padding: var(--space-4) var(--space-6); }

  /* New SMS: full-screen page instead of centered modal */
  #modal-new-sms.modal-backdrop {
    background: transparent;
    align-items: stretch;
    padding-top: 0;
  }
  #modal-new-sms .modal {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
  }
  #modal-new-sms .modal-header { padding: 0; border-bottom: none; gap: 0; }
  #modal-new-sms .modal-header-row {
    height: 56px; padding: 0 8px 0 4px;
    border-bottom: 1px solid var(--color-border);
  }
  #modal-new-sms .modal-header-row h3 { font-size: var(--fs-16); margin-left: var(--space-3); }
  #modal-new-sms .modal-close { display: none; }
  #modal-new-sms .modal-back {
    display: inline-flex;
    width: 44px; height: 44px;
    color: var(--color-accent);
    font-size: var(--fs-20);
    border-radius: var(--radius-input);
  }
  #modal-new-sms #new-sms-search { margin: var(--space-6) var(--space-7) 0; height: 48px; font-size: var(--fs-16); }
  #modal-new-sms .modal-list { flex: 1; max-height: none; margin-top: var(--space-6); }

  /* Rename: bottom sheet instead of centered modal */
  #modal-rename.modal-backdrop {
    align-items: flex-end;
    padding-top: 0;
    background: rgba(16, 24, 40, .42);
  }
  #modal-rename .modal {
    width: 100%;
    border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
    animation: sheetIn .18s ease-out;
    padding: 20px 16px 24px;
  }
  #modal-rename #rename-input { height: 48px; font-size: var(--fs-16); }
  #modal-rename .modal-actions button { flex: 1; height: 48px; }

  #modal-delete.modal-backdrop { align-items: flex-end; padding-top: 0; }
  #modal-delete .modal {
    width: 100%;
    border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
    animation: sheetIn .18s ease-out;
  }
  #modal-delete .modal-actions button { flex: 1; height: 48px; }

  /* Foreign-number send confirm: bottom sheet, same treatment as Radera. */
  #modal-foreign-confirm.modal-backdrop { align-items: flex-end; padding-top: 0; }
  #modal-foreign-confirm .modal {
    width: 100%;
    border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
    animation: sheetIn .18s ease-out;
  }
  #modal-foreign-confirm .modal-actions button { flex: 1; height: 48px; }

  /* Templates popover + manage dialog: bottom sheets on mobile, same
     treatment as the rename dialog. */
  #modal-templates.modal-backdrop,
  #modal-manage-templates.modal-backdrop {
    align-items: flex-end;
    padding-top: 0;
  }
  #modal-templates .modal,
  #modal-manage-templates .modal {
    width: 100%;
    max-height: calc(100vh - 56px);
    border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
    animation: sheetIn .18s ease-out;
  }
  #modal-templates .modal-templates,
  #modal-manage-templates .modal-manage-templates { width: 100%; }
  #template-form-save, #template-form-cancel { flex: 1; height: 48px; }

  /* Templates: bring controls up to the 44px minimum touch target used by
     the other icon buttons (rename/archive/delete, sound toggle). */
  #btn-templates { min-height: 44px; }
  #templates-popover-close { width: 44px; height: 44px; }
  .templates-popover-footer #btn-manage-templates {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 44px; min-width: 44px; padding: 0 var(--space-5);
  }
  #btn-add-template { min-height: 44px; }

  #toast { left: 12px; right: 12px; bottom: 96px; transform: none; max-width: none; }

  .import-topbar { height: 52px; padding: 0 var(--space-4) 0 var(--space-2); gap: var(--space-2); }
  .import-topbar .import-subtitle { display: none; }
  .import-topbar h2 { font-size: var(--fs-16); }
  #btn-import-back-desktop { display: none; }
  #btn-import-back-mobile { display: inline-flex; width: 44px; height: 44px; font-size: var(--fs-20); }
  .import-body { padding: var(--space-8) var(--space-6) var(--space-12); }
  .import-steps { display: none; }
  .import-dropzone { padding: 32px 20px; }
  .import-mapping { grid-template-columns: 1fr; gap: var(--space-7); }
  .import-summary { flex-direction: column; align-items: stretch; gap: var(--space-4); padding: var(--space-7) var(--space-8); }
  .import-summary-divider { display: none; }
  .import-summary-spacer { display: none; }
  .import-summary button { height: 48px; }
  .import-table td:nth-child(n+3), .import-table th:nth-child(n+3) { display: none; }
}

@media (min-width: 860px) {
  #btn-import-back-mobile { display: none; }
}
