:root {
  --mobile-touch: 44px;
  --mobile-control: 40px;
  --mobile-nav-height: 64px;
  --mobile-safe-top: env(safe-area-inset-top, 0px);
  --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
  --mobile-safe-left: env(safe-area-inset-left, 0px);
  --mobile-safe-right: env(safe-area-inset-right, 0px);
  --ui-radius: 8px;
  --ui-radius-compact: 6px;
  --ui-shadow-raised: 0 6px 18px rgba(28, 45, 68, 0.12);
  --ui-focus-ring: rgba(20, 133, 238, 0.24);
  --ui-surface-subtle: #f5f7f9;
  --ui-success: #16865a;
  --ui-warning: #a86408;
  --ui-danger: #d73a49;
}

button,
input,
select,
textarea {
  letter-spacing: 0;
}

button,
[role='button'] {
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease,
    box-shadow 150ms ease, opacity 150ms ease, transform 100ms ease;
}

button:focus-visible,
[role='button']:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--ui-focus-ring);
}

button:active:not(:disabled),
[role='button']:active:not([aria-disabled='true']) {
  transform: translateY(1px);
}

button:disabled,
[aria-disabled='true'] {
  cursor: not-allowed;
  opacity: 0.55;
}

.mobile-nav {
  display: none;
}

.mobile-back-button {
  display: none;
}

.settings-main .set-card {
  width: 100%;
  max-width: 620px;
  border-radius: var(--ui-radius);
  box-sizing: border-box;
}

.settings-main .set-card + .set-card {
  margin-top: 16px;
}

.settings-section-label {
  max-width: 620px;
  margin: 22px 0 8px;
  color: #68717d;
  font-size: 12px;
  font-weight: 600;
}

.set-identity-row {
  margin-top: 20px;
}

.set-identity-row > label {
  display: block;
  margin-bottom: 8px;
  color: #68717d;
  font-size: 12px;
  font-weight: 600;
}

.set-identity-control {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.set-identity-control .set-input {
  min-width: 0;
  margin-bottom: 0;
}

.settings-group {
  padding: 0;
  overflow: hidden;
}

.settings-row,
.settings-company-option {
  width: 100%;
  min-width: 0;
  min-height: 54px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  color: var(--text);
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  text-align: left;
}

.settings-row:last-child,
.settings-company-list > [role='listitem']:last-child .settings-company-option {
  border-bottom: 0;
}

.settings-row:hover:not(:disabled),
.settings-company-option:hover:not(:disabled) {
  background: var(--ui-surface-subtle);
}

.settings-row:focus-visible,
.settings-company-option:focus-visible {
  position: relative;
  z-index: 1;
  outline-offset: -3px;
}

.settings-row-icon {
  width: var(--mobile-control);
  height: var(--mobile-control);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--ui-radius-compact);
  background: #eef4fa;
  color: var(--blue);
}

.settings-row-icon svg {
  width: 20px;
  height: 20px;
}

.settings-row-copy {
  min-width: 0;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.settings-row-copy strong,
.settings-row-copy small {
  display: block;
}

.settings-row-copy strong {
  font-size: 14px;
  font-weight: 650;
}

.settings-row-copy small {
  margin-top: 3px;
  color: #747d88;
  font-size: 12px;
}

.settings-row-action {
  max-width: 168px;
  color: #68717d;
  font-size: 12px;
  line-height: 1.35;
  text-align: right;
  overflow-wrap: anywhere;
}

.settings-row-action svg {
  width: 18px;
  height: 18px;
}

.settings-company-modal {
  width: min(480px, calc(100vw - 32px));
  max-width: none;
  max-height: min(80dvh, 680px);
  padding: 0;
  overflow: hidden;
  border-radius: var(--ui-radius);
  box-shadow: var(--ui-shadow-raised);
}

.settings-company-picker {
  display: flex;
  flex-direction: column;
  max-height: min(80dvh, 680px);
  min-height: 0;
  background: #fff;
}

.settings-company-picker-head {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 12px 8px 18px;
  border-bottom: 1px solid var(--border);
}

.settings-company-picker-head h3 {
  min-width: 0;
  margin: 0;
  font-size: 16px;
}

.settings-company-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.settings-company-option {
  min-height: 58px;
}

.settings-company-option.is-current:disabled {
  opacity: 1;
  color: var(--text);
  background: #eef6fd;
}

.settings-company-option.is-current .settings-row-action {
  color: var(--blue-dark);
  font-weight: 650;
}

.settings-company-picker[aria-busy='true'] {
  cursor: progress;
}

.settings-company-picker[aria-busy='true'] .settings-company-option:not(.is-current) {
  opacity: 0.58;
}

@media (max-width: 768px),
  (pointer: coarse) and (max-height: 500px) {
  :root {
    --navh: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px));
  }

  html,
  body {
    width: 100%;
    min-width: 0;
    min-height: 100vh;
    min-height: 100dvh;
  }

  #app,
  #modal-container,
  #app *,
  #modal-container * {
    box-sizing: border-box;
  }

  #app {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
  }

  .chat-page,
  .contacts-page,
  .workbench-page,
  .company-admin-view,
  .docs-page,
  .game-rank-page,
  .department-reports-page {
    width: 100%;
    height: 100%;
    max-height: 100dvh;
    min-width: 0;
    min-height: 0;
    overflow-x: clip;
  }

  .chat-page,
  .contacts-page {
    display: block;
    position: relative;
    overflow: hidden;
  }

  .chat-conversation-pane,
  .chat-detail-pane,
  .contacts-list-pane,
  .contacts-detail-pane {
    position: absolute;
    inset: 0;
    width: 100%;
    max-width: none;
    min-width: 0;
    min-height: 0;
    padding-top: 0;
  }

  .chat-detail-pane,
  .contacts-detail-pane {
    z-index: 2;
  }

  .chat-page .chat-detail-pane {
    transform: none;
    transition: none;
  }

  .chat-page[data-mobile-pane='list'] .chat-detail-pane,
  .contacts-page[data-mobile-pane='list'] .contacts-detail-pane,
  .chat-page[data-mobile-pane='detail'] .chat-conversation-pane,
  .contacts-page[data-mobile-pane='detail'] .contacts-list-pane {
    visibility: hidden;
    pointer-events: none;
  }

  .mobile-back-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--mobile-touch);
    height: var(--mobile-touch);
    min-width: var(--mobile-touch);
    min-height: var(--mobile-touch);
    padding: 0;
    font-size: 24px;
    line-height: 1;
    border-radius: var(--ui-radius);
  }

  .workbench-back-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--mobile-touch) !important;
    height: var(--mobile-touch) !important;
    min-width: var(--mobile-touch) !important;
    min-height: var(--mobile-touch) !important;
    padding: 0 !important;
    border: 1px solid #dce3eb;
    border-radius: var(--ui-radius);
    background: #fff;
    color: #243247;
    font-size: 28px;
    line-height: 1;
    box-shadow: 0 2px 8px rgba(28, 45, 68, 0.08);
  }

  .chat-page .mobile-back-button,
  .contacts-page .mobile-back-button {
    display: inline-flex;
    font-size: 28px;
    line-height: 1;
    border: 1px solid #e1e6ed;
    background: #f5f7fa;
    color: #243247;
  }

  .contacts-page .mobile-back-button {
    position: absolute;
    top: 8px;
    left: calc(8px + var(--mobile-safe-left));
  }

  .contacts-page .detail-actions {
    flex-wrap: wrap;
    justify-content: center;
    padding: 0 16px 16px;
  }

  .chat-page .chat-body,
  .chat-page .chat-center {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
  }

  .chat-page .msg-list {
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .chat-page .msg-row {
    min-width: 0;
    max-width: min(88%, 620px);
  }

  .chat-page .bubble {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .chat-page .bubble img,
  .chat-page .bubble video {
    max-width: 100%;
    height: auto;
  }

  .chat-page .input-area {
    position: sticky;
    z-index: 8;
    bottom: 0;
    flex: 0 0 auto;
    padding-bottom: 8px;
    background: #fff;
  }

  .chat-page .input-toolbar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 2px;
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
  }

  .chat-page .input-toolbar .tool-btn {
    width: min(38px, 100%);
    min-width: 0 !important;
    justify-self: center;
    padding: 0;
    border-radius: var(--ui-radius-compact);
  }

  .chat-page #msg-input {
    min-height: var(--mobile-touch);
    max-height: min(34dvh, 180px);
    overflow-y: auto;
  }

  .chat-page .chat-composer button,
  .chat-page .input-toolbar button {
    min-width: var(--mobile-touch);
    min-height: var(--mobile-touch);
  }

  .video-analysis-page {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .mobile-scroll-region {
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .workbench-page.work-area {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  #app,
  #app * {
    scrollbar-width: none;
  }

  #app::-webkit-scrollbar,
  #app *::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
  }

  .mobile-long-text,
  .file-name,
  .message-text,
  .report-body {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .mobile-sticky-actions {
    position: sticky;
    z-index: 6;
    bottom: 0;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-top: 1px solid var(--border);
  }

  button,
  [role='button'] {
    min-height: var(--mobile-touch);
    max-width: 100%;
  }

  input:not([type]),
  input[type='text'],
  input[type='password'],
  input[type='search'],
  input[type='email'],
  input[type='url'],
  input[type='tel'],
  input[type='number'],
  input[type='date'],
  input[type='time'],
  input[type='datetime-local'],
  input[type='month'],
  input[type='week'],
  select {
    min-height: var(--mobile-touch);
  }

  input:not([type]),
  input[type='text'],
  input[type='password'],
  input[type='search'],
  input[type='email'],
  input[type='url'],
  input[type='tel'],
  input[type='number'],
  input[type='date'],
  input[type='time'],
  input[type='datetime-local'],
  input[type='month'],
  input[type='week'],
  select,
  textarea {
    width: 100%;
    max-width: 100%;
    border-radius: var(--ui-radius-compact);
  }

  textarea {
    min-height: 96px;
  }

  .btn-primary,
  .btn-block,
  .set-btn {
    min-height: 46px;
    border-radius: var(--ui-radius);
  }

  #app button,
  #app [role='button'] {
    min-height: var(--mobile-touch) !important;
    max-width: 100%;
  }

  #app .tab,
  #app [role='tab'] {
    min-height: var(--mobile-touch) !important;
    display: inline-flex;
    align-items: center;
  }

  #app input:not([type]),
  #app input[type='text'],
  #app input[type='password'],
  #app input[type='search'],
  #app input[type='email'],
  #app input[type='url'],
  #app input[type='tel'],
  #app input[type='number'],
  #app input[type='date'],
  #app input[type='time'],
  #app input[type='datetime-local'],
  #app input[type='month'],
  #app input[type='week'],
  #app select {
    min-height: var(--mobile-touch) !important;
  }

  input[type='checkbox'],
  input[type='radio'] {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    max-width: 20px;
    flex: 0 0 20px;
    padding: 0;
    accent-color: var(--blue);
  }

  label:has(input[type='checkbox']),
  label:has(input[type='radio']) {
    display: flex;
    align-items: center;
    min-width: 0;
    max-width: 100%;
    min-height: var(--mobile-touch);
  }

  .mobile-check-hit {
    width: var(--mobile-touch);
    min-width: var(--mobile-touch);
    min-height: var(--mobile-touch);
    padding: 0;
    justify-content: center;
  }

  input[type='file'] {
    width: auto;
    max-width: 100%;
    min-height: 0;
    border-radius: var(--ui-radius-compact);
  }

  input[type='file']::file-selector-button {
    min-height: var(--mobile-touch);
    margin-inline-end: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--ui-radius-compact);
    background: #fff;
    color: var(--text);
    font: inherit;
  }

  .snip-btn {
    min-width: var(--mobile-touch);
    min-height: var(--mobile-touch);
  }

  .snip-size {
    width: 72px !important;
    height: var(--mobile-touch) !important;
    min-width: 72px;
    min-height: var(--mobile-touch) !important;
    max-width: 72px;
    padding: 0;
    flex: 0 0 72px;
  }

  .snip-color {
    width: var(--mobile-touch) !important;
    height: var(--mobile-touch) !important;
    min-width: var(--mobile-touch);
    min-height: var(--mobile-touch) !important;
    padding: 7px !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--ui-radius-compact);
    background: #fff;
    appearance: none;
  }

  .snip-color::-webkit-color-swatch-wrapper {
    padding: 0;
  }

  .snip-color::-webkit-color-swatch {
    border: 0;
    border-radius: 4px;
  }

  .snip-color::-moz-color-swatch {
    border: 0;
    border-radius: 4px;
  }

  #app .btn-primary,
  #app .btn-block,
  #app .set-btn,
  #app #srv-ok {
    min-height: 46px !important;
  }

  #app #bug-view .bug-ptab,
  #app #bug-view .bug-actions button,
  #app #bug-view .bug-tbl td:nth-child(10) .btn-mini,
  #app #bug-view .tabs .tab,
  #app .task-table td:last-child .btn-mini,
  #app .task-detail-back {
    min-height: var(--mobile-touch) !important;
  }

  #app .icon-btn,
  #app .tool-btn,
  #app .video-zoom-btn,
  #app .file-folder-btn,
  #app .send-caret {
    min-width: var(--mobile-touch) !important;
    min-height: var(--mobile-touch) !important;
  }

  #app .set-av-edit,
  #app .ms-kick,
  #app .rb-btn,
  #app .sheet-addtab,
  #app .sheet-zbtn,
  #app .share-del {
    min-width: var(--mobile-touch) !important;
    min-height: var(--mobile-touch) !important;
  }

  #app .bubble.file-msg {
    padding-right: 58px;
  }

  #app .pend-x {
    top: -15px;
    right: -15px;
    width: var(--mobile-touch) !important;
    height: var(--mobile-touch) !important;
    min-width: var(--mobile-touch) !important;
    min-height: var(--mobile-touch) !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent !important;
    color: transparent;
    font-size: 0;
    line-height: 1;
    z-index: 2;
  }

  #app .pend-x::before {
    content: '\00D7';
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.64);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.24);
  }

  .company-icon-button {
    width: var(--mobile-touch);
    height: var(--mobile-touch);
    min-width: var(--mobile-touch);
    min-height: var(--mobile-touch);
    flex: 0 0 var(--mobile-touch);
    border-radius: var(--ui-radius-compact);
  }

  .gs-toggle {
    width: var(--mobile-touch) !important;
    height: var(--mobile-touch) !important;
    min-width: var(--mobile-touch) !important;
    min-height: var(--mobile-touch) !important;
    flex: 0 0 var(--mobile-touch);
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent !important;
    position: relative;
  }

  .gs-toggle::before {
    content: '';
    position: absolute;
    top: 11px;
    left: 2px;
    width: 40px;
    height: 22px;
    border-radius: 50%;
    background: #d0d3d8;
    transition: background-color 150ms ease;
  }

  .gs-toggle::after {
    top: 13px;
    left: 4px;
    width: 18px;
    height: 18px;
    transition: left 150ms ease;
  }

  .gs-toggle.on::before {
    background: var(--blue);
  }

  .gs-toggle[aria-checked='true']::before {
    background: var(--blue);
  }

  .gs-toggle.on::after,
  .gs-toggle[aria-checked='true']::after {
    left: 22px;
  }

  .gs-toggle:focus-visible {
    outline: 0;
    box-shadow: none;
  }

  .gs-toggle:focus-visible::before {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
  }

  .group-settings-pop .gs-row {
    min-height: 52px;
    padding: 4px 16px;
  }

  .group-settings-pop {
    top: calc(var(--mobile-safe-top) + 8px) !important;
    right: calc(8px + var(--mobile-safe-right));
    left: auto !important;
    max-height: calc(
      100dvh - var(--mobile-nav-height) - var(--mobile-safe-top) - var(--mobile-safe-bottom) - 16px
    );
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .rail {
    display: none;
  }

  .app-shell {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    padding-top: var(--mobile-safe-top);
    padding-bottom: calc(var(--mobile-nav-height) + var(--mobile-safe-bottom));
    overflow: hidden;
    box-sizing: border-box;
  }

  /* The shell owns bottom navigation and safe-area spacing on mobile. */
  .work-area {
    padding-bottom: 0;
  }

  .panel-list {
    min-height: 0;
    padding-top: 0;
    padding-bottom: 0;
  }

  .view-root {
    width: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
  }

  #app .module-card,
  #app .card,
  #app .task-table tr,
  #app .news-hero,
  #app .news-box,
  #app .art-frame-wrap,
  #app .va-side,
  #app .va-input,
  #app .va-upload,
  #app .va-result,
  #app .va-result .tabs,
  #app .va-meta-grid,
  #app .va-block p,
  #app .va-error,
  #app .gr-stat,
  #app .gr-sec,
  #app .gr-hcard,
  #modal-container .modal {
    border-radius: var(--ui-radius) !important;
  }

  .group-settings-pop,
  .call-widget,
  .mention-pop,
  .emoji-pop {
    border-radius: var(--ui-radius) !important;
  }

  .mobile-nav {
    display: grid;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    height: calc(var(--mobile-nav-height) + var(--mobile-safe-bottom));
    padding-top: 0;
    padding-right: calc(8px + var(--mobile-safe-right));
    padding-bottom: var(--mobile-safe-bottom);
    padding-left: calc(8px + var(--mobile-safe-left));
    border-top: 1px solid var(--border);
    background: #fff;
    box-shadow: 0 -1px 8px rgba(28, 45, 68, 0.08);
    box-sizing: border-box;
    z-index: 90;
  }

  .mobile-nav-item {
    min-width: 0;
    min-height: var(--mobile-touch);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    position: relative;
    padding: 5px 4px 4px;
    color: #5f6671;
    font-size: 11px;
    line-height: 1.15;
    border-radius: var(--ui-radius-compact);
  }

  .mobile-nav-item:hover,
  .mobile-nav-item:focus-visible {
    background: #f3f5f7;
  }

  .mobile-nav-item.active {
    color: var(--blue-dark);
    background: #edf5fd;
  }

  .mobile-nav-item .icon {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-nav-item svg {
    width: 22px;
    height: 22px;
    stroke-width: 2;
  }

  .mobile-nav-item > span:not(.icon):not(.badge) {
    display: block;
    width: 100%;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-nav-item .badge {
    position: absolute;
    top: 3px;
    left: calc(50% + 9px);
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border: 2px solid #fff;
    border-radius: var(--ui-radius);
    align-items: center;
    justify-content: center;
    background: var(--red);
    color: #fff;
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    line-height: 14px;
  }

  .settings-wrap {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
    background: #f5f7f9;
  }

  .settings-nav {
    width: 100%;
    flex: 0 0 auto;
    padding: 10px 12px 0;
    padding-right: calc(12px + var(--mobile-safe-right));
    padding-left: calc(12px + var(--mobile-safe-left));
    border-right: 0;
    border-bottom: 1px solid var(--border);
    background: #fff;
  }

  .settings-title {
    padding: 2px 4px 8px;
    font-size: 17px;
  }

  .settings-nav [role='tablist'] {
    display: flex;
    gap: 4px;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
  }

  .settings-nav [role='tablist']::-webkit-scrollbar {
    display: none;
  }

  .set-nav-item {
    flex: 0 0 auto;
    min-height: var(--mobile-touch);
    margin: 0;
    padding: 8px 12px;
    border-radius: var(--ui-radius-compact) var(--ui-radius-compact) 0 0;
    white-space: nowrap;
  }

  .set-nav-item.active {
    color: var(--blue-dark);
    background: #edf5fd;
  }

  .settings-main {
    width: 100%;
    min-width: 0;
    min-height: 0;
    padding: 16px 14px calc(24px + var(--mobile-safe-bottom));
    padding-right: calc(14px + var(--mobile-safe-right));
    padding-left: calc(14px + var(--mobile-safe-left));
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .set-h {
    margin-bottom: 12px;
    font-size: 17px;
  }

  .settings-main .set-card {
    max-width: none;
    padding: 16px;
    border-radius: var(--ui-radius);
    background: #fff;
  }

  .settings-main .settings-group {
    padding: 0;
  }

  .set-prof {
    align-items: center;
  }

  .set-prof-name {
    font-size: 17px;
    overflow-wrap: anywhere;
  }

  .set-prof-sub {
    line-height: 1.45;
    overflow-wrap: anywhere;
  }

  .set-prof-av {
    min-width: 72px;
    min-height: 72px;
  }

  .set-avatar,
  .set-avatar.txt {
    border-radius: var(--ui-radius);
  }

  .set-identity-control {
    align-items: stretch;
  }

  .set-input {
    min-width: 0;
  }

  .set-btn,
  .set-btn-line {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .settings-section-label {
    margin-top: 18px;
  }

  .settings-row {
    min-height: 56px;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 8px 12px;
  }

  .settings-row-copy {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .settings-row-action {
    grid-column: 3;
    grid-row: 1;
    max-width: 100%;
    justify-self: end;
    text-align: right;
  }

  .settings-company-current .settings-row-action {
    grid-column: 2 / -1;
    grid-row: 2;
    justify-self: start;
    text-align: left;
  }

  #modal-container .mask {
    padding-top: var(--mobile-safe-top);
    background: rgba(20, 27, 36, 0.46);
    backdrop-filter: none;
  }

  .settings-company-modal {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    max-height: min(72dvh, 620px);
    padding: 0;
    padding-right: var(--mobile-safe-right);
    padding-bottom: var(--mobile-safe-bottom);
    padding-left: var(--mobile-safe-left);
    border-radius: var(--ui-radius) var(--ui-radius) 0 0;
    box-shadow: 0 -6px 18px rgba(28, 45, 68, 0.14);
  }

  .settings-company-picker {
    max-height: calc(min(72dvh, 620px) - var(--mobile-safe-bottom));
  }

  .settings-company-picker-head {
    min-height: 56px;
    padding-left: 16px;
  }

  .settings-company-list {
    overflow-y: auto;
  }

  .settings-company-option {
    min-height: 58px;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    padding: 7px 12px;
  }

  .company-landing {
    min-height: 100vh;
    min-height: 100dvh;
    align-items: flex-start;
    padding: calc(24px + var(--mobile-safe-top)) 16px calc(24px + var(--mobile-safe-bottom));
    padding-right: calc(16px + var(--mobile-safe-right));
    padding-left: calc(16px + var(--mobile-safe-left));
  }

  .company-landing-content {
    width: 100%;
    max-width: 560px;
    margin: auto;
  }

  .company-identity-row {
    width: 100%;
    min-width: 0;
  }

  .company-identity-row code {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .company-choice b,
  .company-choice small {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .company-landing-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  .company-landing-actions button {
    width: 100%;
    min-width: 0;
    min-height: var(--mobile-touch);
    padding: 9px 12px;
  }

  .company-connection-recovery .company-landing-actions .btn-primary {
    min-height: 46px;
  }

  .login-page {
    min-width: 0;
    min-height: 100vh;
    min-height: 100dvh;
    padding: calc(20px + var(--mobile-safe-top)) 16px calc(20px + var(--mobile-safe-bottom));
    padding-right: calc(16px + var(--mobile-safe-right));
    padding-left: calc(16px + var(--mobile-safe-left));
    overflow-y: auto;
    background: #f4f6f8;
  }

  .login-card {
    width: min(100%, 380px);
    max-width: 100%;
    padding: 24px 20px;
    border-radius: var(--ui-radius);
    box-shadow: var(--ui-shadow-raised);
  }

  .login-card input:not([type]),
  .login-card input[type='text'],
  .login-card input[type='password'],
  .login-card input[type='email'] {
    min-height: var(--mobile-touch);
  }

  .login-card .btn-primary {
    min-height: 46px;
  }

  /* Module stylesheets own layout; this layer only closes shared mobile gaps. */
  .workbench-page .module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workbench-page .module-card {
    min-width: 0;
  }

  .workbench-page .module-card h3,
  .workbench-page .module-card p {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  [data-mobile-scroll='x'] {
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  [data-mobile-scroll='x']::-webkit-scrollbar {
    display: none;
  }

  .docs-page {
    overflow: hidden;
    background: #fff;
  }

  .docs-page .docs-topbar {
    flex-wrap: nowrap;
  }

  .docs-page .docs-topbar > * {
    flex: 0 0 auto;
  }

  .docs-page .docs-search {
    order: initial;
    width: min(220px, 70vw);
  }

  .docs-page .docs-main,
  .docs-page .docs-editor,
  .docs-page .docs-edbody {
    min-width: 0;
    min-height: 0;
  }

  .docs-page .docs-edhead {
    flex-wrap: nowrap;
  }

  .docs-page .docs-edhead > * {
    flex: 0 0 auto;
  }

  .docs-page .docs-edhead #doc-title {
    flex: 0 0 min(240px, 68vw);
    min-width: 160px;
  }

  .docs-page .docs-sheet-wrap {
    min-width: 0;
    min-height: 240px;
    max-width: 100%;
    overflow: auto;
    overscroll-behavior: contain;
    touch-action: pan-x pan-y;
    -webkit-overflow-scrolling: touch;
  }

  .docs-page .sheet-bottom {
    position: sticky;
    z-index: 6;
    bottom: 0;
    background: #fff;
  }

  #app .server-config-page {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh !important;
    padding: calc(16px + var(--mobile-safe-top)) calc(16px + var(--mobile-safe-right))
      calc(16px + var(--mobile-safe-bottom)) calc(16px + var(--mobile-safe-left)) !important;
    overflow-y: auto !important;
    align-items: flex-start !important;
    box-sizing: border-box;
    overscroll-behavior: contain;
  }

  #app .server-config-card {
    width: 100% !important;
    max-width: 360px !important;
    margin: auto 0;
    box-sizing: border-box;
  }

  #srv-url {
    width: 100% !important;
    max-width: 100%;
    min-height: var(--mobile-touch) !important;
    border-radius: var(--ui-radius) !important;
  }

  #srv-ok {
    width: 100% !important;
    min-height: 46px !important;
    height: 46px !important;
    border-radius: var(--ui-radius) !important;
  }

  #srv-back {
    width: 100% !important;
    min-height: var(--mobile-touch) !important;
    height: var(--mobile-touch) !important;
    border-radius: var(--ui-radius) !important;
  }
}

@media (max-width: 768px) and (max-height: 500px),
  (pointer: coarse) and (max-height: 500px) {
  #app .server-config-page {
    padding-top: calc(8px + var(--mobile-safe-top)) !important;
    padding-bottom: calc(8px + var(--mobile-safe-bottom)) !important;
  }

  #app .server-config-card {
    margin-top: 0;
    margin-bottom: 0;
  }
}

@media (min-width: 769px) and (pointer: fine),
  (min-width: 769px) and (min-height: 501px) {
  .settings-wrap {
    flex-direction: row;
  }

  .settings-nav {
    width: 220px;
  }

  .mobile-nav {
    display: none;
  }
}
