@layer app-frame {
  .app-frame {
    min-height: 100dvh;
    background: var(--bg-app);
  }

  .setae-brand {
    --setae-brand-icon-size: 28px;
    min-width: 0;
    max-width: 100%;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-primary);
  }

  .setae-brand-icon {
    width: var(--setae-brand-icon-size);
    height: var(--setae-brand-icon-size);
    display: block;
    flex: 0 0 var(--setae-brand-icon-size);
    background: currentColor;
    -webkit-mask: url('../icons/setae-brand-mark.png') center / contain no-repeat;
    mask: url('../icons/setae-brand-mark.png') center / contain no-repeat;
  }

  .setae-brand-copy {
    min-width: 0;
    display: grid;
    gap: var(--space-1);
  }

  .setae-brand-title {
    font-size: var(--type-workbench-section);
    font-weight: 740;
    line-height: 1;
  }

  .setae-brand-subtitle {
    color: var(--text-muted);
    font-size: var(--type-workbench-meta);
    line-height: var(--leading-tight);
  }

  .setae-brand.is-compact {
    --setae-brand-icon-size: 22px;
    gap: var(--space-2);
  }

  .setae-brand.is-compact .setae-brand-title,
  .setae-brand.is-compact .setae-brand-subtitle {
    font-size: var(--type-workbench-caption);
  }

  .setae-brand.is-prominent {
    --setae-brand-icon-size: 34px;
    gap: var(--space-3);
  }

  .setae-brand.is-prominent .setae-brand-title {
    font-size: var(--type-heading);
  }

  .boot-brand {
    justify-self: center;
  }

  .app-rail {
    display: none;
  }

  .mobile-app-bar {
    position: fixed;
    z-index: 35;
    top: 0;
    right: 0;
    left: 0;
    min-height: calc(var(--touch-target) + var(--safe-top));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--safe-top) max(var(--space-3), var(--safe-right)) 0 max(var(--space-3), var(--safe-left));
    border-bottom: 1px solid var(--border-default);
    background: var(--bg-app);
  }

  .mobile-app-brand {
    flex: 1;
    min-width: 0;
  }

  .mobile-app-brand .setae-brand-subtitle {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-app-actions {
    display: flex;
    align-items: center;
    gap: var(--space-1);
  }

  .mobile-app-status,
  .mobile-sync-button {
    display: none;
  }

  .app-workspace {
    min-width: 0;
    min-height: 100dvh;
    padding: calc(var(--touch-target) + var(--safe-top)) 0 calc(var(--bottom-nav-height) + var(--safe-bottom));
  }

  .app-frame-error {
    padding: var(--space-3) var(--space-4) 0;
  }

  .mobile-navigation {
    position: fixed;
    z-index: 40;
    right: 0;
    bottom: 0;
    left: 0;
    min-height: calc(var(--bottom-nav-height) + var(--safe-bottom));
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
    padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
    border-top: 1px solid var(--border-default);
    background: var(--bg-elevated);
  }

  .mobile-navigation.is-public {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mobile-navigation-item {
    min-width: 0;
    min-height: var(--bottom-nav-height);
    flex-direction: column;
    justify-content: center;
    gap: var(--space-1);
    padding: 0 var(--space-1);
    border-radius: 0;
    font-size: var(--type-workbench-meta);
    text-align: center;
  }

  .mobile-navigation-item .ui-icon {
    width: var(--space-5);
    height: var(--space-5);
  }

  .mobile-navigation-item.is-record-action {
    color: var(--accent);
    font-weight: 700;
  }

  @media (min-width: 768px) and (max-width: 1199px) {
    .mobile-app-status,
    .mobile-sync-button {
      display: inline-flex;
    }
  }

  @media (min-width: 1200px) {
    .app-frame {
      padding-left: var(--app-rail-width);
    }

    .app-rail {
      position: fixed;
      z-index: 30;
      inset: 0 auto 0 0;
      width: var(--app-rail-width);
      display: flex;
      flex-direction: column;
      padding: var(--space-5) var(--space-3) var(--space-4);
      border-right: 1px solid var(--border-default);
      background: var(--bg-app);
    }

    .app-rail-brand {
      display: inline-flex;
      align-items: center;
      gap: var(--space-2);
      padding: 0 var(--space-3) var(--space-5);
    }

    .app-rail-brand .setae-brand-title {
      font-size: var(--type-workbench-section);
      font-weight: 700;
    }

    .app-rail-brand .setae-brand-subtitle,
    .app-rail-section-label {
      color: var(--text-muted);
      font-size: var(--type-workbench-meta);
    }

    .app-rail-navigation,
    .app-rail-library,
    .app-rail-footer {
      display: grid;
      gap: var(--space-1);
    }

    .app-rail-library {
      margin-top: var(--space-5);
      padding-top: var(--space-4);
      border-top: 1px solid var(--border-default);
    }

    .app-rail-section-label {
      padding: 0 var(--space-3) var(--space-2);
      font-weight: 650;
    }

    .app-rail-link,
    .app-rail-sublink {
      position: relative;
      width: 100%;
    }

    .app-rail-link.is-active::before,
    .app-rail-sublink.is-active::before {
      position: absolute;
      top: var(--space-2);
      bottom: var(--space-2);
      left: 0;
      width: 2px;
      background: var(--accent);
      content: '';
    }

    .app-rail-sublink {
      min-height: var(--control-height);
      padding-left: var(--space-6);
      font-size: var(--type-workbench-caption);
    }

    .app-rail-spacer {
      min-height: var(--space-5);
      flex: 1;
    }

    .app-rail-footer {
      padding-top: var(--space-3);
      border-top: 1px solid var(--border-default);
    }

    .app-rail-account {
      min-height: var(--touch-target);
      display: flex;
      align-items: center;
      gap: var(--space-2);
      padding: 0 var(--space-3);
      overflow: hidden;
      color: var(--text-secondary);
      font-size: var(--type-workbench-caption);
    }

    .app-rail-account > span:last-child {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .app-rail-avatar {
      width: var(--space-6);
      height: var(--space-6);
      display: grid;
      flex: 0 0 var(--space-6);
      border: 1px solid var(--border-default);
      border-radius: var(--radius-round);
      background: var(--bg-surface);
      color: var(--text-primary);
      place-items: center;
    }

    .mobile-app-bar,
    .mobile-navigation {
      display: none;
    }

    .app-workspace {
      min-height: 100dvh;
      padding: 0;
    }

    .app-frame-error {
      padding: var(--space-4) var(--space-5) 0;
    }

    .toast {
      bottom: var(--space-5);
    }
  }
}
