/* Four IM spaces. Their layouts are shared across desktop and mobile. */
.app-shell { grid-template: 56px minmax(0, 1fr) / 76px 304px minmax(0, 1fr); }
.topbar { display: flex; justify-content: space-between; gap: 28px; padding: 0 24px; background: var(--surface); }
.topbar-brand { color: var(--ink); font-size: 16px; font-weight: 750; letter-spacing: -.3px; }
.topbar-brand small { margin-left: 16px; color: var(--muted); font-size: 12px; font-weight: 400; letter-spacing: 0; }
.global-search { width: min(380px, 44vw); }
.global-search input { min-height: 36px; text-align: left; }
.primary-nav { gap: 8px; padding: 16px 8px; background: var(--surface); border-right: 1px solid var(--line); }
.primary-nav-item { width: 60px; min-height: 64px; gap: 7px; border-radius: 12px; }
.primary-nav-item.active { box-shadow: none; background: var(--state-selected); }
.primary-nav-item span { font-size: 12px; }
.workspace-tile { margin-bottom: 20px; }
.sidebar { grid-template-rows: auto auto auto minmax(0, 1fr); background: var(--surface); }
.sidebar-header { min-height: 94px; padding: 16px 18px; border-bottom: 0; }
.sidebar-brand strong { font-size: 27px; font-weight: 750; }
.sidebar-brand small { margin-top: 6px; font-size: 12px; color: var(--muted); }
.sidebar-header .icon-button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; }
.mobile-search { position: relative; display: flex; margin: 0; padding: 0 16px 8px; color: var(--muted); background: transparent; }
.mobile-search svg { position: absolute; left: 29px; width: 18px; height: 18px; pointer-events: none; }
.mobile-search input { min-height: 44px; padding-left: 40px; border: 1px solid var(--line); color: var(--ink); background: var(--surface-soft); }
.mobile-search input::placeholder { color: var(--muted); }
.channels-heading { display: flex; align-items: center; justify-content: space-between; min-height: 56px; padding: 0 18px; color: var(--muted); }
.room-filters { display: flex; gap: 2px; }
.room-filters button { min-width: 44px; min-height: 44px; padding: 0 8px; color: var(--muted); background: transparent; font-size: 12px; }
.room-filters button[aria-pressed=true] { color: var(--ink); font-weight: 750; }
.room-list { padding: 0 10px 24px; }
.room-item { min-height: 80px; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; padding: 12px 10px; margin: 0 0 2px; border: 0; border-radius: 10px; }
.room-item.active { box-shadow: none; background: var(--state-selected); }
.room-item .conversation-avatar { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; background: var(--surface-soft) !important; color: var(--ink); font-size: 14px; font-weight: 750; }
.room-item .conversation-avatar::after { content: none; }
.room-copy { display: grid; gap: 6px; }
.room-copy strong { font-size: 15px; font-weight: 650; }
.room-copy small { display: block; font-size: 12px; }
.room-item-end { flex-direction: column; align-items: flex-end; align-self: start; gap: 10px; padding-top: 3px; font-size: 10px; }
.room-list-empty { padding: 60px 16px; text-align: center; }
.room-list-empty strong { color: var(--ink); font-size: 16px; }
.room-list-empty p { color: var(--muted); font-size: 13px; line-height: 1.8; }
.show-collection .sidebar { display: none; }
.collection-view { grid-area: 2 / 2 / 3 / -1; }
.collection-header { padding: 30px 36px 24px; border-bottom: 0; }
.collection-header h1 { font-size: 30px; letter-spacing: -.6px; }
.collection-header p { margin: 8px 0 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
.collection-content { padding: 0 36px 40px; }
.collection-content > .collection-list, .collection-content > .settings-heading, .collection-content > .account-profile-card { max-width: 860px; margin-left: auto; margin-right: auto; }
.collection-header #collectionBackButton { flex: 0 0 48px; width: 48px; height: 48px; }
.collection-empty { min-height: 42vh; }
.collection-empty p { max-width: 340px; line-height: 1.8; }
.collection-item.text-collection-item { grid-template-columns: minmax(0, 1fr); padding: 18px 4px; }
.text-collection-item .collection-item-main { min-width: 0; gap: 8px; }
.text-collection-item .collection-item-main > strong { font-size: 16px; line-height: 1.5; overflow-wrap: anywhere; }
.text-collection-item .collection-item-body { white-space: normal; line-height: 1.6; }
.text-collection-item .collection-item-title { flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.text-collection-item small { color: var(--muted); font-size: 12px; }
.record-toolbar { padding: 0 0 20px; max-width: 860px; margin: 0 auto; }
.supporting-copy { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.8; }
.loading-copy { padding: 32px 0; color: var(--muted); }
.quiet-button { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; padding: 0 12px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; text-decoration: none; font-size: 13px; }
.quiet-button:hover { color: var(--ink); background: var(--surface-hover); }
.world-content { max-width: 820px; margin: 0 auto; }
.world-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.segmented-control { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.segmented-control button { min-width: 84px; min-height: 44px; padding: 0 20px; }
.segmented-control button[aria-pressed=true] { color: var(--ink); background: var(--surface-raised); box-shadow: 0 1px 4px rgb(0 0 0 / .06); }
.world-search { margin-bottom: 12px; background: var(--surface-soft); }
/* Reading first: actions stay behind the row or in its contextual menu. */
.world-entry { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); }
.world-entry-surface { position: relative; z-index: 1; background: var(--surface); transition: transform 180ms ease; touch-action: pan-y pinch-zoom; }
.world-entry.swiping .world-entry-surface { transition: none; user-select: none; }
.world-entry-main { display: block; min-height: 96px; padding: 16px 0; color: var(--ink); text-decoration: none; }
.world-entry-main:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -3px; }
.world-entry-meta { display: flex; align-items: center; gap: 8px; padding-right: 40px; color: var(--muted); font-size: 11px; }
.world-entry-meta strong { flex-shrink: 0; max-width: 42%; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.world-entry-origin { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.world-entry-origin::before { content: '·'; margin-right: 8px; }
.world-entry-meta time { margin-left: auto; flex-shrink: 0; white-space: nowrap; }
.world-entry-title { margin: 8px 0 0; color: var(--ink); font-size: 18px; line-height: 1.5; font-weight: 600; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.world-entry-summary { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.7; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.world-entry-menu { position: absolute; top: 0; right: -8px; display: grid; place-items: center; width: 48px; height: 48px; padding: 0; opacity: 0; background: transparent; color: var(--muted); font-size: 20px; border-radius: 8px; }
.world-entry:hover .world-entry-menu, .world-entry:focus-within .world-entry-menu { opacity: 1; }
.world-swipe-action { position: absolute; top: 0; bottom: 0; width: 104px; min-height: 48px; padding: 16px 8px; color: var(--ink); background: var(--surface-soft); font-size: 13px; }
.world-swipe-follow { left: 0; }
.world-swipe-ai { right: 0; background: var(--state-selected); }
.world-swipe-hint { margin: 0 0 2px; color: var(--muted); font-size: 11px; }
.world-menu-actions { display: grid; margin-top: 12px; }
.world-menu-actions .quiet-button { justify-content: flex-start; min-height: 52px; padding: 0 4px; border-bottom: 1px solid var(--line); color: var(--ink); font-size: 15px; }
.world-action-dialog .dialog-card { max-width: 420px; }
@media (hover: none) { .world-entry-menu { opacity: .65; } }
@media (prefers-reduced-motion: reduce) { .world-entry-surface { transition: none; } }
.space-empty { display: grid; justify-items: center; padding: 64px 16px; text-align: center; }
.space-empty-mark { font-size: 48px; color: var(--muted); }
.space-empty h2 { margin: 20px 0 8px; font-size: 19px; }
.space-empty p { max-width: 320px; color: var(--muted); font-size: 14px; line-height: 1.9; }
.source-add-form { display: grid; gap: 12px; }
.source-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.source-row strong { min-width: 0; overflow-wrap: anywhere; font-size: 14px; }
.source-row button { flex-shrink: 0; }
.sources-dialog .dialog-card, .ai-request-dialog .dialog-card { max-height: calc(100dvh - 40px); overflow-y: auto; }
.ai-request-dialog textarea { min-height: 170px; }
.account-profile-card { margin-bottom: 24px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; padding: 12px 0 26px; }
.settings-heading { margin-top: 26px; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.settings-list { border: 0; border-radius: 0; background: transparent; }
.settings-list .collection-item { min-height: 76px; padding: 12px 2px; border-color: var(--line); }
.setting-icon { border: 1px solid var(--line); background: transparent !important; }
.channel-tabs button { min-height: 48px; }
.channel-tabs { height: 48px; }

@media (max-width: 760px), (max-height: 500px) and (max-width: 960px) {
  .topbar { display: none; }
  .primary-nav { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; height: calc(72px + env(safe-area-inset-bottom)); padding: 4px 10px env(safe-area-inset-bottom); border-right: 0; }
  .primary-nav-item { width: 100%; min-height: 62px; gap: 5px; border-radius: 12px; }
  .primary-nav-item.active { background: transparent; }
  .primary-nav-item.active svg { stroke-width: 2.2; }
  .sidebar { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .sidebar-header { min-height: calc(98px + env(safe-area-inset-top)); padding: max(20px, env(safe-area-inset-top)) 20px 14px; }
  .sidebar-brand strong { font-size: 30px; }
  .sidebar-header .icon-button { width: 48px; min-width: 48px; height: 48px; border-radius: 50%; color: var(--ink); background: var(--surface-soft); }
  .sidebar-header .icon-button::after { content: none; }
  .mobile-search { padding: 0 20px 6px; }
  .mobile-search svg { left: 33px; }
  .mobile-search input { min-height: 48px; font-size: 15px; }
  .channels-heading { min-height: 56px; padding: 0 20px; }
  .room-filters button { min-height: 48px; min-width: 48px; }
  .room-list { padding: 0 12px 20px; }
  .room-item { min-height: 88px; padding: 12px 8px; gap: 12px; grid-template-columns: 48px minmax(0, 1fr) auto; }
  .room-item .conversation-avatar { width: 48px; height: 48px; border-radius: 16px; }
  .room-copy strong { font-size: 16px; }
  .room-copy small { font-size: 13px; }
  .room-item-end { font-size: 10px; }
  .collection-view { inset: 0 0 calc(72px + env(safe-area-inset-bottom)); padding-bottom: 0; }
  .collection-header { min-height: calc(98px + env(safe-area-inset-top)); padding: max(20px, env(safe-area-inset-top)) 20px 20px; gap: 12px; align-items: flex-end; }
  .collection-header p { margin-top: 6px; font-size: 12px; }
  .collection-header h1 { font-size: 30px; }
  .collection-content { padding: 0 20px 28px; }
  .collection-action { min-height: 48px; padding: 0 12px; font-size: 13px; }
  .collection-view.room-subview .collection-header { align-items: center; gap: 8px; padding-left: 12px; }
  .collection-view.room-subview .collection-header h1 { font-size: 24px; }
  .collection-empty { min-height: 36vh; }
  .world-toolbar { margin-bottom: 12px; }
  .segmented-control button { min-height: 48px; }
  .world-entry-meta { gap: 8px; }
  .world-entry-meta time { font-size: 10px; }
  .world-entry-title { font-size: 17px; }
  .record-toolbar { gap: 8px; }
  .record-toolbar > * { min-width: 120px; }
  .record-toolbar button { flex-basis: 100%; }
  .settings-list .collection-item { min-height: 76px; }
  .account-profile-card { gap: 12px; padding-bottom: 24px; }
  .dialog-card { max-width: calc(100vw - 24px); }
}
